21 $this->fail(
'Expected exception not thrown',
'priority < min' );
22 }
catch ( \InvalidArgumentException $ex ) {
23 $this->assertSame(
'Invalid priority', $ex->getMessage(),
'priority < min' );
28 $this->fail(
'Expected exception not thrown',
'priority > max' );
29 }
catch ( \InvalidArgumentException $ex ) {
30 $this->assertSame(
'Invalid priority', $ex->getMessage(),
'priority > max' );
35 $this->fail(
'Expected exception not thrown',
'bad session ID' );
36 }
catch ( \InvalidArgumentException $ex ) {
37 $this->assertSame(
'Invalid session ID', $ex->getMessage(),
'bad session ID' );
42 $this->fail(
'Expected exception not thrown',
'bad userInfo' );
43 }
catch ( \InvalidArgumentException $ex ) {
44 $this->assertSame(
'Invalid userInfo', $ex->getMessage(),
'bad userInfo' );
49 $this->fail(
'Expected exception not thrown',
'no provider, no id' );
50 }
catch ( \InvalidArgumentException $ex ) {
51 $this->assertSame(
'Must supply an ID when no provider is given', $ex->getMessage(),
52 'no provider, no id' );
57 $this->fail(
'Expected exception not thrown',
'bad copyFrom' );
58 }
catch ( \InvalidArgumentException $ex ) {
59 $this->assertSame(
'Invalid copyFrom', $ex->getMessage(),
64 $provider = $this->getMockBuilder( SessionProvider::class )
65 ->setMethods( [
'persistsSessionId',
'canChangeUser',
'__toString' ] )
66 ->getMockForAbstractClass();
67 $provider->setManager( $manager );
68 $provider->expects( $this->
any() )->method(
'persistsSessionId' )
69 ->will( $this->returnValue(
true ) );
70 $provider->expects( $this->
any() )->method(
'canChangeUser' )
71 ->will( $this->returnValue(
true ) );
72 $provider->expects( $this->
any() )->method(
'__toString' )
73 ->will( $this->returnValue(
'Mock' ) );
75 $provider2 = $this->getMockBuilder( SessionProvider::class )
76 ->setMethods( [
'persistsSessionId',
'canChangeUser',
'__toString' ] )
77 ->getMockForAbstractClass();
78 $provider2->setManager( $manager );
79 $provider2->expects( $this->
any() )->method(
'persistsSessionId' )
80 ->will( $this->returnValue(
true ) );
81 $provider2->expects( $this->
any() )->method(
'canChangeUser' )
82 ->will( $this->returnValue(
true ) );
83 $provider2->expects( $this->
any() )->method(
'__toString' )
84 ->will( $this->returnValue(
'Mock2' ) );
88 'provider' => $provider,
89 'userInfo' => $anonInfo,
92 $this->fail(
'Expected exception not thrown',
'bad metadata' );
93 }
catch ( \InvalidArgumentException $ex ) {
94 $this->assertSame(
'Invalid metadata', $ex->getMessage(),
'bad metadata' );
98 'provider' => $provider,
99 'userInfo' => $anonInfo
101 $this->assertSame( $provider, $info->getProvider() );
102 $this->assertNotNull( $info->getId() );
104 $this->assertSame( $anonInfo, $info->getUserInfo() );
105 $this->assertTrue( $info->isIdSafe() );
106 $this->assertFalse( $info->forceUse() );
107 $this->assertFalse( $info->wasPersisted() );
108 $this->assertFalse( $info->wasRemembered() );
109 $this->assertFalse( $info->forceHTTPS() );
110 $this->assertNull( $info->getProviderMetadata() );
113 'provider' => $provider,
114 'userInfo' => $unverifiedUserInfo,
115 'metadata' => [
'Foo' ],
117 $this->assertSame( $provider, $info->getProvider() );
118 $this->assertNotNull( $info->getId() );
120 $this->assertSame( $unverifiedUserInfo, $info->getUserInfo() );
121 $this->assertTrue( $info->isIdSafe() );
122 $this->assertFalse( $info->forceUse() );
123 $this->assertFalse( $info->wasPersisted() );
124 $this->assertFalse( $info->wasRemembered() );
125 $this->assertFalse( $info->forceHTTPS() );
126 $this->assertSame( [
'Foo' ], $info->getProviderMetadata() );
129 'provider' => $provider,
130 'userInfo' => $userInfo
132 $this->assertSame( $provider, $info->getProvider() );
133 $this->assertNotNull( $info->getId() );
135 $this->assertSame( $userInfo, $info->getUserInfo() );
136 $this->assertTrue( $info->isIdSafe() );
137 $this->assertFalse( $info->forceUse() );
138 $this->assertFalse( $info->wasPersisted() );
139 $this->assertTrue( $info->wasRemembered() );
140 $this->assertFalse( $info->forceHTTPS() );
141 $this->assertNull( $info->getProviderMetadata() );
143 $id = $manager->generateSessionId();
146 'provider' => $provider,
149 'userInfo' => $anonInfo
151 $this->assertSame( $provider, $info->getProvider() );
152 $this->assertSame( $id, $info->getId() );
154 $this->assertSame( $anonInfo, $info->getUserInfo() );
155 $this->assertFalse( $info->isIdSafe() );
156 $this->assertFalse( $info->forceUse() );
157 $this->assertTrue( $info->wasPersisted() );
158 $this->assertFalse( $info->wasRemembered() );
159 $this->assertFalse( $info->forceHTTPS() );
160 $this->assertNull( $info->getProviderMetadata() );
163 'provider' => $provider,
165 'userInfo' => $userInfo
167 $this->assertSame( $provider, $info->getProvider() );
168 $this->assertSame( $id, $info->getId() );
170 $this->assertSame( $userInfo, $info->getUserInfo() );
171 $this->assertFalse( $info->isIdSafe() );
172 $this->assertFalse( $info->forceUse() );
173 $this->assertFalse( $info->wasPersisted() );
174 $this->assertTrue( $info->wasRemembered() );
175 $this->assertFalse( $info->forceHTTPS() );
176 $this->assertNull( $info->getProviderMetadata() );
181 'userInfo' => $userInfo,
182 'metadata' => [
'Foo' ],
184 $this->assertSame( $id, $info->getId() );
186 $this->assertSame( $userInfo, $info->getUserInfo() );
187 $this->assertFalse( $info->isIdSafe() );
188 $this->assertFalse( $info->forceUse() );
189 $this->assertTrue( $info->wasPersisted() );
190 $this->assertFalse( $info->wasRemembered() );
191 $this->assertFalse( $info->forceHTTPS() );
192 $this->assertNull( $info->getProviderMetadata() );
196 'remembered' =>
true,
197 'userInfo' => $userInfo,
199 $this->assertFalse( $info->wasRemembered(),
'no provider' );
202 'provider' => $provider,
204 'remembered' =>
true,
206 $this->assertFalse( $info->wasRemembered(),
'no user' );
209 'provider' => $provider,
211 'remembered' =>
true,
212 'userInfo' => $anonInfo,
214 $this->assertFalse( $info->wasRemembered(),
'anonymous user' );
217 'provider' => $provider,
219 'remembered' =>
true,
220 'userInfo' => $unverifiedUserInfo,
222 $this->assertFalse( $info->wasRemembered(),
'unverified user' );
225 'provider' => $provider,
227 'remembered' =>
false,
228 'userInfo' => $userInfo,
230 $this->assertFalse( $info->wasRemembered(),
'specific override' );
236 $this->assertSame( $id, $info->getId() );
238 $this->assertTrue( $info->isIdSafe() );
244 $this->assertFalse( $info->forceUse(),
'no provider' );
247 'provider' => $provider,
250 $this->assertFalse( $info->forceUse(),
'no id' );
253 'provider' => $provider,
257 $this->assertTrue( $info->forceUse(),
'correct use' );
263 $this->assertTrue( $info->forceHTTPS() );
267 'provider' => $provider,
268 'userInfo' => $userInfo,
272 'remembered' =>
true,
273 'forceHTTPS' =>
true,
274 'metadata' => [
'foo!' ],
277 'copyFrom' => $fromInfo,
279 $this->assertSame( $id .
'A', $info->getId() );
281 $this->assertSame( $provider, $info->getProvider() );
282 $this->assertSame( $userInfo, $info->getUserInfo() );
283 $this->assertTrue( $info->isIdSafe() );
284 $this->assertTrue( $info->forceUse() );
285 $this->assertTrue( $info->wasPersisted() );
286 $this->assertTrue( $info->wasRemembered() );
287 $this->assertTrue( $info->forceHTTPS() );
288 $this->assertSame( [
'foo!' ], $info->getProviderMetadata() );
292 'provider' => $provider2,
293 'userInfo' => $unverifiedUserInfo,
296 'persisted' =>
false,
297 'remembered' =>
false,
298 'forceHTTPS' =>
false,
300 'copyFrom' => $fromInfo,
302 $this->assertSame( $id .
'X', $info->getId() );
304 $this->assertSame( $provider2, $info->getProvider() );
305 $this->assertSame( $unverifiedUserInfo, $info->getUserInfo() );
306 $this->assertFalse( $info->isIdSafe() );
307 $this->assertFalse( $info->forceUse() );
308 $this->assertFalse( $info->wasPersisted() );
309 $this->assertFalse( $info->wasRemembered() );
310 $this->assertFalse( $info->forceHTTPS() );
311 $this->assertNull( $info->getProviderMetadata() );
323 'provider' => $provider,
326 'userInfo' => $userInfo
335 'provider' => $provider,
338 'userInfo' => $unverifiedUserInfo