Skip to content

Commit

Permalink
Use ::class keyword when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 11, 2021
1 parent 4953ed1 commit cee6b60
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions Tests/Authenticator/FormLoginAuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand All @@ -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());
}

Expand All @@ -63,15 +63,15 @@ 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());
}

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());
}

Expand All @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions Tests/Firewall/GuardAuthenticationListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Tests/GuardAuthenticatorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
20 changes: 10 additions & 10 deletions Tests/Provider/GuardAuthenticationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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);

Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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();
}
Expand Down

0 comments on commit cee6b60

Please sign in to comment.