@@ -256,7 +256,7 @@ public function testIfTokenIsDeauthenticatedTriggersDeprecations()
256
256
{
257
257
$ tokenStorage = new TokenStorage ();
258
258
$ refreshedUser = new User ('foobar ' , 'baz ' );
259
- $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (), new SupportingUserProvider ($ refreshedUser )]);
259
+ $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (true ), new NotSupportingUserProvider ( false ), new SupportingUserProvider ($ refreshedUser )]);
260
260
261
261
$ this ->assertSame ($ refreshedUser , $ tokenStorage ->getToken ()->getUser ());
262
262
}
@@ -265,7 +265,7 @@ public function testIfTokenIsDeauthenticated()
265
265
{
266
266
$ tokenStorage = new TokenStorage ();
267
267
$ refreshedUser = new User ('foobar ' , 'baz ' );
268
- $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (), new SupportingUserProvider ($ refreshedUser )], null , true );
268
+ $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (true ), new NotSupportingUserProvider ( false ), new SupportingUserProvider ($ refreshedUser )], null , true );
269
269
270
270
$ this ->assertNull ($ tokenStorage ->getToken ());
271
271
}
@@ -287,7 +287,7 @@ public function testRememberMeGetsCanceledIfTokenIsDeauthenticated()
287
287
$ rememberMeServices = $ this ->createMock (RememberMeServicesInterface::class);
288
288
$ rememberMeServices ->expects ($ this ->once ())->method ('loginFail ' );
289
289
290
- $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (), new SupportingUserProvider ($ refreshedUser )], null , true , $ rememberMeServices );
290
+ $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (true ), new NotSupportingUserProvider ( false ), new SupportingUserProvider ($ refreshedUser )], null , true , $ rememberMeServices );
291
291
292
292
$ this ->assertNull ($ tokenStorage ->getToken ());
293
293
}
@@ -296,7 +296,7 @@ public function testTryAllUserProvidersUntilASupportingUserProviderIsFound()
296
296
{
297
297
$ tokenStorage = new TokenStorage ();
298
298
$ refreshedUser = new User ('foobar ' , 'baz ' );
299
- $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (), new SupportingUserProvider ($ refreshedUser )], $ refreshedUser );
299
+ $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (true ), new NotSupportingUserProvider ( false ), new SupportingUserProvider ($ refreshedUser )], $ refreshedUser );
300
300
301
301
$ this ->assertSame ($ refreshedUser , $ tokenStorage ->getToken ()->getUser ());
302
302
}
@@ -313,22 +313,22 @@ public function testNextSupportingUserProviderIsTriedIfPreviousSupportingUserPro
313
313
public function testTokenIsSetToNullIfNoUserWasLoadedByTheRegisteredUserProviders ()
314
314
{
315
315
$ tokenStorage = new TokenStorage ();
316
- $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (), new SupportingUserProvider ()]);
316
+ $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (true ), new NotSupportingUserProvider ( false ), new SupportingUserProvider ()]);
317
317
318
318
$ this ->assertNull ($ tokenStorage ->getToken ());
319
319
}
320
320
321
321
public function testRuntimeExceptionIsThrownIfNoSupportingUserProviderWasRegistered ()
322
322
{
323
323
$ this ->expectException ('RuntimeException ' );
324
- $ this ->handleEventWithPreviousSession (new TokenStorage (), [new NotSupportingUserProvider (), new NotSupportingUserProvider ()]);
324
+ $ this ->handleEventWithPreviousSession (new TokenStorage (), [new NotSupportingUserProvider (false ), new NotSupportingUserProvider (true )]);
325
325
}
326
326
327
327
public function testAcceptsProvidersAsTraversable ()
328
328
{
329
329
$ tokenStorage = new TokenStorage ();
330
330
$ refreshedUser = new User ('foobar ' , 'baz ' );
331
- $ this ->handleEventWithPreviousSession ($ tokenStorage , new \ArrayObject ([new NotSupportingUserProvider (), new SupportingUserProvider ($ refreshedUser )]), $ refreshedUser );
331
+ $ this ->handleEventWithPreviousSession ($ tokenStorage , new \ArrayObject ([new NotSupportingUserProvider (true ), new NotSupportingUserProvider ( false ), new SupportingUserProvider ($ refreshedUser )]), $ refreshedUser );
332
332
333
333
$ this ->assertSame ($ refreshedUser , $ tokenStorage ->getToken ()->getUser ());
334
334
}
@@ -383,14 +383,26 @@ private function handleEventWithPreviousSession(TokenStorageInterface $tokenStor
383
383
384
384
class NotSupportingUserProvider implements UserProviderInterface
385
385
{
386
+ /** @var bool */
387
+ private $ throwsUnsupportedException ;
388
+
389
+ public function __construct ($ throwsUnsupportedException )
390
+ {
391
+ $ this ->throwsUnsupportedException = $ throwsUnsupportedException ;
392
+ }
393
+
386
394
public function loadUserByUsername ($ username )
387
395
{
388
396
throw new UsernameNotFoundException ();
389
397
}
390
398
391
399
public function refreshUser (UserInterface $ user )
392
400
{
393
- throw new UnsupportedUserException ();
401
+ if ($ this ->throwsUnsupportedException ) {
402
+ throw new UnsupportedUserException ();
403
+ }
404
+
405
+ return $ user ;
394
406
}
395
407
396
408
public function supportsClass ($ class )
0 commit comments