@@ -256,7 +256,7 @@ public function testIfTokenIsDeauthenticatedTriggersDeprecations()
256256 {
257257 $ tokenStorage = new TokenStorage ();
258258 $ 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 )]);
260260
261261 $ this ->assertSame ($ refreshedUser , $ tokenStorage ->getToken ()->getUser ());
262262 }
@@ -265,7 +265,7 @@ public function testIfTokenIsDeauthenticated()
265265 {
266266 $ tokenStorage = new TokenStorage ();
267267 $ 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 );
269269
270270 $ this ->assertNull ($ tokenStorage ->getToken ());
271271 }
@@ -287,7 +287,7 @@ public function testRememberMeGetsCanceledIfTokenIsDeauthenticated()
287287 $ rememberMeServices = $ this ->createMock (RememberMeServicesInterface::class);
288288 $ rememberMeServices ->expects ($ this ->once ())->method ('loginFail ' );
289289
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 );
291291
292292 $ this ->assertNull ($ tokenStorage ->getToken ());
293293 }
@@ -296,7 +296,7 @@ public function testTryAllUserProvidersUntilASupportingUserProviderIsFound()
296296 {
297297 $ tokenStorage = new TokenStorage ();
298298 $ 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 );
300300
301301 $ this ->assertSame ($ refreshedUser , $ tokenStorage ->getToken ()->getUser ());
302302 }
@@ -313,22 +313,22 @@ public function testNextSupportingUserProviderIsTriedIfPreviousSupportingUserPro
313313 public function testTokenIsSetToNullIfNoUserWasLoadedByTheRegisteredUserProviders ()
314314 {
315315 $ tokenStorage = new TokenStorage ();
316- $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (), new SupportingUserProvider ()]);
316+ $ this ->handleEventWithPreviousSession ($ tokenStorage , [new NotSupportingUserProvider (true ), new NotSupportingUserProvider ( false ), new SupportingUserProvider ()]);
317317
318318 $ this ->assertNull ($ tokenStorage ->getToken ());
319319 }
320320
321321 public function testRuntimeExceptionIsThrownIfNoSupportingUserProviderWasRegistered ()
322322 {
323323 $ this ->expectException ('RuntimeException ' );
324- $ this ->handleEventWithPreviousSession (new TokenStorage (), [new NotSupportingUserProvider (), new NotSupportingUserProvider ()]);
324+ $ this ->handleEventWithPreviousSession (new TokenStorage (), [new NotSupportingUserProvider (false ), new NotSupportingUserProvider (true )]);
325325 }
326326
327327 public function testAcceptsProvidersAsTraversable ()
328328 {
329329 $ tokenStorage = new TokenStorage ();
330330 $ 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 );
332332
333333 $ this ->assertSame ($ refreshedUser , $ tokenStorage ->getToken ()->getUser ());
334334 }
@@ -383,14 +383,26 @@ private function handleEventWithPreviousSession(TokenStorageInterface $tokenStor
383383
384384class NotSupportingUserProvider implements UserProviderInterface
385385{
386+ /** @var bool */
387+ private $ throwsUnsupportedException ;
388+
389+ public function __construct ($ throwsUnsupportedException )
390+ {
391+ $ this ->throwsUnsupportedException = $ throwsUnsupportedException ;
392+ }
393+
386394 public function loadUserByUsername ($ username )
387395 {
388396 throw new UsernameNotFoundException ();
389397 }
390398
391399 public function refreshUser (UserInterface $ user )
392400 {
393- throw new UnsupportedUserException ();
401+ if ($ this ->throwsUnsupportedException ) {
402+ throw new UnsupportedUserException ();
403+ }
404+
405+ return $ user ;
394406 }
395407
396408 public function supportsClass ($ class )
0 commit comments