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(),
65 ->setMethods( [
'persistsSessionId',
'canChangeUser',
'__toString' ] )
66 ->getMockForAbstractClass();
67 $provider->setManager( $manager );
68 $provider->expects( $this->
any() )->method(
'persistsSessionId' )
70 $provider->expects( $this->
any() )->method(
'canChangeUser' )
72 $provider->expects( $this->
any() )->method(
'__toString' )
76 ->setMethods( [
'persistsSessionId',
'canChangeUser',
'__toString' ] )
77 ->getMockForAbstractClass();
78 $provider2->setManager( $manager );
79 $provider2->expects( $this->
any() )->method(
'persistsSessionId' )
81 $provider2->expects( $this->
any() )->method(
'canChangeUser' )
83 $provider2->expects( $this->
any() )->method(
'__toString' )
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() );
104 $this->
assertSame( $anonInfo, $info->getUserInfo() );
110 $this->
assertNull( $info->getProviderMetadata() );
113 'provider' => $provider,
114 'userInfo' => $unverifiedUserInfo,
115 'metadata' => [
'Foo' ],
117 $this->
assertSame( $provider, $info->getProvider() );
120 $this->
assertSame( $unverifiedUserInfo, $info->getUserInfo() );
126 $this->
assertSame( [
'Foo' ], $info->getProviderMetadata() );
129 'provider' => $provider,
130 'userInfo' => $userInfo
132 $this->
assertSame( $provider, $info->getProvider() );
135 $this->
assertSame( $userInfo, $info->getUserInfo() );
141 $this->
assertNull( $info->getProviderMetadata() );
143 $id = $manager->generateSessionId();
146 'provider' => $provider,
149 'userInfo' => $anonInfo
151 $this->
assertSame( $provider, $info->getProvider() );
154 $this->
assertSame( $anonInfo, $info->getUserInfo() );
160 $this->
assertNull( $info->getProviderMetadata() );
163 'provider' => $provider,
165 'userInfo' => $userInfo
167 $this->
assertSame( $provider, $info->getProvider() );
170 $this->
assertSame( $userInfo, $info->getUserInfo() );
176 $this->
assertNull( $info->getProviderMetadata() );
181 'userInfo' => $userInfo,
182 'metadata' => [
'Foo' ],
186 $this->
assertSame( $userInfo, $info->getUserInfo() );
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' );
244 $this->
assertFalse( $info->forceUse(),
'no provider' );
247 'provider' => $provider,
253 'provider' => $provider,
257 $this->
assertTrue( $info->forceUse(),
'correct use' );
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() );
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() );
311 $this->
assertNull( $info->getProviderMetadata() );
323 'provider' => $provider,
326 'userInfo' => $userInfo
335 'provider' => $provider,
338 'userInfo' => $unverifiedUserInfo