Skip to content

Commit cee6b60

Browse files
committed
Use ::class keyword when possible
1 parent 4953ed1 commit cee6b60

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

Tests/Authenticator/FormLoginAuthenticatorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testAuthenticationFailureWithoutSession()
3636
{
3737
$failureResponse = $this->authenticator->onAuthenticationFailure($this->requestWithoutSession, new AuthenticationException());
3838

39-
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse);
39+
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse);
4040
$this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl());
4141
}
4242

@@ -48,7 +48,7 @@ public function testAuthenticationFailureWithSession()
4848

4949
$failureResponse = $this->authenticator->onAuthenticationFailure($this->requestWithSession, new AuthenticationException());
5050

51-
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse);
51+
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse);
5252
$this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl());
5353
}
5454

@@ -63,15 +63,15 @@ public function testStartWithoutSession()
6363
{
6464
$failureResponse = $this->authenticator->start($this->requestWithoutSession, new AuthenticationException());
6565

66-
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse);
66+
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse);
6767
$this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl());
6868
}
6969

7070
public function testStartWithSession()
7171
{
7272
$failureResponse = $this->authenticator->start($this->requestWithSession, new AuthenticationException());
7373

74-
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse);
74+
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse);
7575
$this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl());
7676
}
7777

@@ -80,7 +80,7 @@ protected function setUp(): void
8080
$this->requestWithoutSession = new Request([], [], [], [], [], []);
8181
$this->requestWithSession = new Request([], [], [], [], [], []);
8282

83-
$session = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface')
83+
$session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)
8484
->disableOriginalConstructor()
8585
->getMock();
8686
$this->requestWithSession->setSession($session);

Tests/Firewall/GuardAuthenticationListenerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function testSupportsReturnFalseSkipAuth()
234234

235235
public function testReturnNullFromGetCredentials()
236236
{
237-
$this->expectException('UnexpectedValueException');
237+
$this->expectException(\UnexpectedValueException::class);
238238
$authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
239239
$providerKey = 'my_firewall4';
240240

@@ -262,17 +262,17 @@ public function testReturnNullFromGetCredentials()
262262

263263
protected function setUp(): void
264264
{
265-
$this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager')
265+
$this->authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager::class)
266266
->disableOriginalConstructor()
267267
->getMock();
268268

269-
$this->guardAuthenticatorHandler = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorHandler')
269+
$this->guardAuthenticatorHandler = $this->getMockBuilder(\Symfony\Component\Security\Guard\GuardAuthenticatorHandler::class)
270270
->disableOriginalConstructor()
271271
->getMock();
272272

273273
$this->request = new Request([], [], [], [], [], []);
274274

275-
$this->event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\RequestEvent')
275+
$this->event = $this->getMockBuilder(\Symfony\Component\HttpKernel\Event\RequestEvent::class)
276276
->disableOriginalConstructor()
277277
->setMethods(['getRequest'])
278278
->getMock();
@@ -281,8 +281,8 @@ protected function setUp(): void
281281
->method('getRequest')
282282
->willReturn($this->request);
283283

284-
$this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
285-
$this->rememberMeServices = $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock();
284+
$this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
285+
$this->rememberMeServices = $this->getMockBuilder(\Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface::class)->getMock();
286286
}
287287

288288
protected function tearDown(): void

Tests/GuardAuthenticatorHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ protected function tearDown(): void
193193

194194
private function configurePreviousSession()
195195
{
196-
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
196+
$session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock();
197197
$session->expects($this->any())
198198
->method('getName')
199199
->willReturn('test_session_name');

Tests/Provider/GuardAuthenticationProviderTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function testCheckCredentialsReturningFalseFailsAuthentication()
125125
*/
126126
public function testCheckCredentialsReturningNonTrueFailsAuthentication()
127127
{
128-
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
128+
$this->expectException(BadCredentialsException::class);
129129
$providerKey = 'my_uncool_firewall';
130130

131131
$authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
@@ -140,7 +140,7 @@ public function testCheckCredentialsReturningNonTrueFailsAuthentication()
140140
->method('getCredentials')
141141
->willReturn('non-null-value');
142142

143-
$mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
143+
$mockedUser = $this->getMockBuilder(UserInterface::class)->getMock();
144144
$authenticator->expects($this->once())
145145
->method('getUser')
146146
->willReturn($mockedUser);
@@ -156,12 +156,12 @@ public function testCheckCredentialsReturningNonTrueFailsAuthentication()
156156

157157
public function testGuardWithNoLongerAuthenticatedTriggersLogout()
158158
{
159-
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationExpiredException');
159+
$this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationExpiredException::class);
160160
$providerKey = 'my_firewall_abc';
161161

162162
// create a token and mark it as NOT authenticated anymore
163163
// this mimics what would happen if a user "changed" between request
164-
$mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
164+
$mockedUser = $this->getMockBuilder(UserInterface::class)->getMock();
165165
$token = new PostAuthenticationGuardToken($mockedUser, $providerKey, ['ROLE_USER']);
166166
$token->setAuthenticated(false);
167167

@@ -175,7 +175,7 @@ public function testSupportsChecksGuardAuthenticatorsTokenOrigin()
175175
$authenticatorB = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
176176
$authenticators = [$authenticatorA, $authenticatorB];
177177

178-
$mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
178+
$mockedUser = $this->getMockBuilder(UserInterface::class)->getMock();
179179
$provider = new GuardAuthenticationProvider($authenticators, $this->userProvider, 'first_firewall', $this->userChecker);
180180

181181
$token = new PreAuthenticationGuardToken($mockedUser, 'first_firewall_1');
@@ -189,12 +189,12 @@ public function testSupportsChecksGuardAuthenticatorsTokenOrigin()
189189

190190
public function testAuthenticateFailsOnNonOriginatingToken()
191191
{
192-
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException');
192+
$this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationException::class);
193193
$this->expectExceptionMessageMatches('/second_firewall_0/');
194194
$authenticatorA = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
195195
$authenticators = [$authenticatorA];
196196

197-
$mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
197+
$mockedUser = $this->getMockBuilder(UserInterface::class)->getMock();
198198
$provider = new GuardAuthenticationProvider($authenticators, $this->userProvider, 'first_firewall', $this->userChecker);
199199

200200
$token = new PreAuthenticationGuardToken($mockedUser, 'second_firewall_0');
@@ -203,9 +203,9 @@ public function testAuthenticateFailsOnNonOriginatingToken()
203203

204204
protected function setUp(): void
205205
{
206-
$this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
207-
$this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
208-
$this->preAuthenticationToken = $this->getMockBuilder('Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken')
206+
$this->userProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock();
207+
$this->userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock();
208+
$this->preAuthenticationToken = $this->getMockBuilder(PreAuthenticationGuardToken::class)
209209
->disableOriginalConstructor()
210210
->getMock();
211211
}

0 commit comments

Comments
 (0)