diff --git a/Tests/Authenticator/FormLoginAuthenticatorTest.php b/Tests/Authenticator/FormLoginAuthenticatorTest.php index 2b7f25f..bab0d70 100644 --- a/Tests/Authenticator/FormLoginAuthenticatorTest.php +++ b/Tests/Authenticator/FormLoginAuthenticatorTest.php @@ -36,7 +36,7 @@ public function testAuthenticationFailureWithoutSession() { $failureResponse = $this->authenticator->onAuthenticationFailure($this->requestWithoutSession, new AuthenticationException()); - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse); $this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl()); } @@ -48,7 +48,7 @@ public function testAuthenticationFailureWithSession() $failureResponse = $this->authenticator->onAuthenticationFailure($this->requestWithSession, new AuthenticationException()); - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse); $this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl()); } @@ -63,7 +63,7 @@ public function testStartWithoutSession() { $failureResponse = $this->authenticator->start($this->requestWithoutSession, new AuthenticationException()); - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse); $this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl()); } @@ -71,7 +71,7 @@ public function testStartWithSession() { $failureResponse = $this->authenticator->start($this->requestWithSession, new AuthenticationException()); - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse); $this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl()); } @@ -80,7 +80,7 @@ protected function setUp(): void $this->requestWithoutSession = new Request([], [], [], [], [], []); $this->requestWithSession = new Request([], [], [], [], [], []); - $session = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface') + $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class) ->disableOriginalConstructor() ->getMock(); $this->requestWithSession->setSession($session); diff --git a/Tests/Firewall/GuardAuthenticationListenerTest.php b/Tests/Firewall/GuardAuthenticationListenerTest.php index c5e1c92..7167ba3 100644 --- a/Tests/Firewall/GuardAuthenticationListenerTest.php +++ b/Tests/Firewall/GuardAuthenticationListenerTest.php @@ -234,7 +234,7 @@ public function testSupportsReturnFalseSkipAuth() public function testReturnNullFromGetCredentials() { - $this->expectException('UnexpectedValueException'); + $this->expectException(\UnexpectedValueException::class); $authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); $providerKey = 'my_firewall4'; @@ -262,17 +262,17 @@ public function testReturnNullFromGetCredentials() protected function setUp(): void { - $this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager') + $this->authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager::class) ->disableOriginalConstructor() ->getMock(); - $this->guardAuthenticatorHandler = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorHandler') + $this->guardAuthenticatorHandler = $this->getMockBuilder(\Symfony\Component\Security\Guard\GuardAuthenticatorHandler::class) ->disableOriginalConstructor() ->getMock(); $this->request = new Request([], [], [], [], [], []); - $this->event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\RequestEvent') + $this->event = $this->getMockBuilder(\Symfony\Component\HttpKernel\Event\RequestEvent::class) ->disableOriginalConstructor() ->setMethods(['getRequest']) ->getMock(); @@ -281,8 +281,8 @@ protected function setUp(): void ->method('getRequest') ->willReturn($this->request); - $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $this->rememberMeServices = $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock(); + $this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $this->rememberMeServices = $this->getMockBuilder(\Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface::class)->getMock(); } protected function tearDown(): void diff --git a/Tests/GuardAuthenticatorHandlerTest.php b/Tests/GuardAuthenticatorHandlerTest.php index 5a6c3c2..e115891 100644 --- a/Tests/GuardAuthenticatorHandlerTest.php +++ b/Tests/GuardAuthenticatorHandlerTest.php @@ -193,7 +193,7 @@ protected function tearDown(): void private function configurePreviousSession() { - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); + $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock(); $session->expects($this->any()) ->method('getName') ->willReturn('test_session_name'); diff --git a/Tests/Provider/GuardAuthenticationProviderTest.php b/Tests/Provider/GuardAuthenticationProviderTest.php index e00fb12..5ecf12e 100644 --- a/Tests/Provider/GuardAuthenticationProviderTest.php +++ b/Tests/Provider/GuardAuthenticationProviderTest.php @@ -125,7 +125,7 @@ public function testCheckCredentialsReturningFalseFailsAuthentication() */ public function testCheckCredentialsReturningNonTrueFailsAuthentication() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(BadCredentialsException::class); $providerKey = 'my_uncool_firewall'; $authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); @@ -140,7 +140,7 @@ public function testCheckCredentialsReturningNonTrueFailsAuthentication() ->method('getCredentials') ->willReturn('non-null-value'); - $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $mockedUser = $this->getMockBuilder(UserInterface::class)->getMock(); $authenticator->expects($this->once()) ->method('getUser') ->willReturn($mockedUser); @@ -156,12 +156,12 @@ public function testCheckCredentialsReturningNonTrueFailsAuthentication() public function testGuardWithNoLongerAuthenticatedTriggersLogout() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationExpiredException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationExpiredException::class); $providerKey = 'my_firewall_abc'; // create a token and mark it as NOT authenticated anymore // this mimics what would happen if a user "changed" between request - $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $mockedUser = $this->getMockBuilder(UserInterface::class)->getMock(); $token = new PostAuthenticationGuardToken($mockedUser, $providerKey, ['ROLE_USER']); $token->setAuthenticated(false); @@ -175,7 +175,7 @@ public function testSupportsChecksGuardAuthenticatorsTokenOrigin() $authenticatorB = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); $authenticators = [$authenticatorA, $authenticatorB]; - $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $mockedUser = $this->getMockBuilder(UserInterface::class)->getMock(); $provider = new GuardAuthenticationProvider($authenticators, $this->userProvider, 'first_firewall', $this->userChecker); $token = new PreAuthenticationGuardToken($mockedUser, 'first_firewall_1'); @@ -189,12 +189,12 @@ public function testSupportsChecksGuardAuthenticatorsTokenOrigin() public function testAuthenticateFailsOnNonOriginatingToken() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationException::class); $this->expectExceptionMessageMatches('/second_firewall_0/'); $authenticatorA = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); $authenticators = [$authenticatorA]; - $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $mockedUser = $this->getMockBuilder(UserInterface::class)->getMock(); $provider = new GuardAuthenticationProvider($authenticators, $this->userProvider, 'first_firewall', $this->userChecker); $token = new PreAuthenticationGuardToken($mockedUser, 'second_firewall_0'); @@ -203,9 +203,9 @@ public function testAuthenticateFailsOnNonOriginatingToken() protected function setUp(): void { - $this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); - $this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); - $this->preAuthenticationToken = $this->getMockBuilder('Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken') + $this->userProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock(); + $this->userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); + $this->preAuthenticationToken = $this->getMockBuilder(PreAuthenticationGuardToken::class) ->disableOriginalConstructor() ->getMock(); }