@@ -42,16 +42,16 @@ class SwitchUserListenerTest extends TestCase
4242 protected function setUp (): void
4343 {
4444 $ this ->tokenStorage = new TokenStorage ();
45- $ this ->userProvider = $ this ->getMockBuilder (' Symfony\Component\Security\Core\User\UserProviderInterface ' )->getMock ();
46- $ this ->userChecker = $ this ->getMockBuilder (' Symfony\Component\Security\Core\User\UserCheckerInterface ' )->getMock ();
47- $ this ->accessDecisionManager = $ this ->getMockBuilder (' Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface ' )->getMock ();
45+ $ this ->userProvider = $ this ->getMockBuilder (\ Symfony \Component \Security \Core \User \UserProviderInterface::class )->getMock ();
46+ $ this ->userChecker = $ this ->getMockBuilder (\ Symfony \Component \Security \Core \User \UserCheckerInterface::class )->getMock ();
47+ $ this ->accessDecisionManager = $ this ->getMockBuilder (\ Symfony \Component \Security \Core \Authorization \AccessDecisionManagerInterface::class )->getMock ();
4848 $ this ->request = new Request ();
4949 $ this ->event = new RequestEvent ($ this ->getMockBuilder (HttpKernelInterface::class)->getMock (), $ this ->request , HttpKernelInterface::MASTER_REQUEST );
5050 }
5151
5252 public function testFirewallNameIsRequired ()
5353 {
54- $ this ->expectException (' InvalidArgumentException ' );
54+ $ this ->expectException (\ InvalidArgumentException::class );
5555 $ this ->expectExceptionMessage ('$firewallName must not be empty ' );
5656 new SwitchUserListener ($ this ->tokenStorage , $ this ->userProvider , $ this ->userChecker , '' , $ this ->accessDecisionManager );
5757 }
@@ -67,7 +67,7 @@ public function testEventIsIgnoredIfUsernameIsNotPassedWithTheRequest()
6767
6868 public function testExitUserThrowsAuthenticationExceptionIfNoCurrentToken ()
6969 {
70- $ this ->expectException (' Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException ' );
70+ $ this ->expectException (\ Symfony \Component \Security \Core \Exception \AuthenticationCredentialsNotFoundException::class );
7171 $ this ->tokenStorage ->setToken (null );
7272 $ this ->request ->query ->set ('_switch_user ' , '_exit ' );
7373 $ listener = new SwitchUserListener ($ this ->tokenStorage , $ this ->userProvider , $ this ->userChecker , 'provider123 ' , $ this ->accessDecisionManager );
@@ -76,7 +76,7 @@ public function testExitUserThrowsAuthenticationExceptionIfNoCurrentToken()
7676
7777 public function testExitUserThrowsAuthenticationExceptionIfOriginalTokenCannotBeFound ()
7878 {
79- $ this ->expectException (' Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException ' );
79+ $ this ->expectException (\ Symfony \Component \Security \Core \Exception \AuthenticationCredentialsNotFoundException::class );
8080 $ token = new UsernamePasswordToken ('username ' , '' , 'key ' , ['ROLE_FOO ' ]);
8181
8282 $ this ->tokenStorage ->setToken ($ token );
@@ -98,15 +98,15 @@ public function testExitUserUpdatesToken()
9898
9999 $ this ->assertSame ([], $ this ->request ->query ->all ());
100100 $ this ->assertSame ('' , $ this ->request ->server ->get ('QUERY_STRING ' ));
101- $ this ->assertInstanceOf (' Symfony\Component\HttpFoundation\RedirectResponse ' , $ this ->event ->getResponse ());
101+ $ this ->assertInstanceOf (\ Symfony \Component \HttpFoundation \RedirectResponse::class , $ this ->event ->getResponse ());
102102 $ this ->assertSame ($ this ->request ->getUri (), $ this ->event ->getResponse ()->getTargetUrl ());
103103 $ this ->assertSame ($ originalToken , $ this ->tokenStorage ->getToken ());
104104 }
105105
106106 public function testExitUserDispatchesEventWithRefreshedUser ()
107107 {
108- $ originalUser = $ this ->getMockBuilder (' Symfony\Component\Security\Core\User\UserInterface ' )->getMock ();
109- $ refreshedUser = $ this ->getMockBuilder (' Symfony\Component\Security\Core\User\UserInterface ' )->getMock ();
108+ $ originalUser = $ this ->getMockBuilder (\ Symfony \Component \Security \Core \User \UserInterface::class )->getMock ();
109+ $ refreshedUser = $ this ->getMockBuilder (\ Symfony \Component \Security \Core \User \UserInterface::class )->getMock ();
110110 $ this
111111 ->userProvider
112112 ->expects ($ this ->any ())
@@ -156,7 +156,7 @@ public function testExitUserDoesNotDispatchEventWithStringUser()
156156
157157 public function testSwitchUserIsDisallowed ()
158158 {
159- $ this ->expectException (' Symfony\Component\Security\Core\Exception\AccessDeniedException ' );
159+ $ this ->expectException (\ Symfony \Component \Security \Core \Exception \AccessDeniedException::class );
160160 $ token = new UsernamePasswordToken ('username ' , '' , 'key ' , ['ROLE_FOO ' ]);
161161 $ user = new User ('username ' , 'password ' , []);
162162
@@ -178,7 +178,7 @@ public function testSwitchUserIsDisallowed()
178178
179179 public function testSwitchUserTurnsAuthenticationExceptionTo403 ()
180180 {
181- $ this ->expectException (' Symfony\Component\Security\Core\Exception\AccessDeniedException ' );
181+ $ this ->expectException (\ Symfony \Component \Security \Core \Exception \AccessDeniedException::class );
182182 $ token = new UsernamePasswordToken ('username ' , '' , 'key ' , ['ROLE_ALLOWED_TO_SWITCH ' ]);
183183
184184 $ this ->tokenStorage ->setToken ($ token );
@@ -220,7 +220,7 @@ public function testSwitchUser()
220220
221221 $ this ->assertSame ([], $ this ->request ->query ->all ());
222222 $ this ->assertSame ('' , $ this ->request ->server ->get ('QUERY_STRING ' ));
223- $ this ->assertInstanceOf (' Symfony\Component\Security\Core\Authentication\Token\ UsernamePasswordToken' , $ this ->tokenStorage ->getToken ());
223+ $ this ->assertInstanceOf (UsernamePasswordToken::class , $ this ->tokenStorage ->getToken ());
224224 }
225225
226226 public function testSwitchUserAlreadySwitched ()
@@ -280,7 +280,7 @@ public function testSwitchUserWorksWithFalsyUsernames()
280280
281281 $ this ->assertSame ([], $ this ->request ->query ->all ());
282282 $ this ->assertSame ('' , $ this ->request ->server ->get ('QUERY_STRING ' ));
283- $ this ->assertInstanceOf (' Symfony\Component\Security\Core\Authentication\Token\ UsernamePasswordToken' , $ this ->tokenStorage ->getToken ());
283+ $ this ->assertInstanceOf (UsernamePasswordToken::class , $ this ->tokenStorage ->getToken ());
284284 }
285285
286286 public function testSwitchUserKeepsOtherQueryStringParameters ()
@@ -310,7 +310,7 @@ public function testSwitchUserKeepsOtherQueryStringParameters()
310310 $ listener ($ this ->event );
311311
312312 $ this ->assertSame ('page=3§ion=2 ' , $ this ->request ->server ->get ('QUERY_STRING ' ));
313- $ this ->assertInstanceOf (' Symfony\Component\Security\Core\Authentication\Token\ UsernamePasswordToken' , $ this ->tokenStorage ->getToken ());
313+ $ this ->assertInstanceOf (UsernamePasswordToken::class , $ this ->tokenStorage ->getToken ());
314314 }
315315
316316 public function testSwitchUserWithReplacedToken ()
@@ -357,7 +357,7 @@ public function testSwitchUserWithReplacedToken()
357357
358358 public function testSwitchUserThrowsAuthenticationExceptionIfNoCurrentToken ()
359359 {
360- $ this ->expectException (' Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException ' );
360+ $ this ->expectException (\ Symfony \Component \Security \Core \Exception \AuthenticationCredentialsNotFoundException::class );
361361 $ this ->tokenStorage ->setToken (null );
362362 $ this ->request ->query ->set ('_switch_user ' , 'username ' );
363363 $ listener = new SwitchUserListener ($ this ->tokenStorage , $ this ->userProvider , $ this ->userChecker , 'provider123 ' , $ this ->accessDecisionManager );
@@ -386,7 +386,7 @@ public function testSwitchUserStateless()
386386 $ listener = new SwitchUserListener ($ this ->tokenStorage , $ this ->userProvider , $ this ->userChecker , 'provider123 ' , $ this ->accessDecisionManager , null , '_switch_user ' , 'ROLE_ALLOWED_TO_SWITCH ' , null , true );
387387 $ listener ($ this ->event );
388388
389- $ this ->assertInstanceOf (' Symfony\Component\Security\Core\Authentication\Token\ UsernamePasswordToken' , $ this ->tokenStorage ->getToken ());
389+ $ this ->assertInstanceOf (UsernamePasswordToken::class , $ this ->tokenStorage ->getToken ());
390390 $ this ->assertFalse ($ this ->event ->hasResponse ());
391391 }
392392}
0 commit comments