Skip to content

Commit 4a63853

Browse files
committed
Use ::class keyword when possible
1 parent 9f0e18b commit 4a63853

36 files changed

+336
-336
lines changed

Tests/AccessMapTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class AccessMapTest extends TestCase
1818
{
1919
public function testReturnsFirstMatchedPattern()
2020
{
21-
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
21+
$request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
2222
$requestMatcher1 = $this->getRequestMatcher($request, false);
2323
$requestMatcher2 = $this->getRequestMatcher($request, true);
2424

@@ -31,7 +31,7 @@ public function testReturnsFirstMatchedPattern()
3131

3232
public function testReturnsEmptyPatternIfNoneMatched()
3333
{
34-
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
34+
$request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
3535
$requestMatcher = $this->getRequestMatcher($request, false);
3636

3737
$map = new AccessMap();
@@ -42,7 +42,7 @@ public function testReturnsEmptyPatternIfNoneMatched()
4242

4343
private function getRequestMatcher($request, $matches)
4444
{
45-
$requestMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcherInterface')->getMock();
45+
$requestMatcher = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestMatcherInterface::class)->getMock();
4646
$requestMatcher->expects($this->once())
4747
->method('matches')->with($request)
4848
->willReturn($matches);

Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ class DefaultAuthenticationFailureHandlerTest extends TestCase
2929

3030
protected function setUp(): void
3131
{
32-
$this->httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
33-
$this->httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
34-
$this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
32+
$this->httpKernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
33+
$this->httpUtils = $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)->getMock();
34+
$this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
3535

36-
$this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
37-
$this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
36+
$this->session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock();
37+
$this->request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
3838
$this->request->expects($this->any())->method('getSession')->willReturn($this->session);
39-
$this->exception = $this->getMockBuilder('Symfony\Component\Security\Core\Exception\AuthenticationException')->setMethods(['getMessage'])->getMock();
39+
$this->exception = $this->getMockBuilder(\Symfony\Component\Security\Core\Exception\AuthenticationException::class)->setMethods(['getMessage'])->getMock();
4040
}
4141

4242
public function testForward()
@@ -183,8 +183,8 @@ public function testFailurePathParameterCanBeOverwritten()
183183

184184
private function getRequest()
185185
{
186-
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
187-
$request->attributes = $this->getMockBuilder('Symfony\Component\HttpFoundation\ParameterBag')->getMock();
186+
$request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
187+
$request->attributes = $this->getMockBuilder(\Symfony\Component\HttpFoundation\ParameterBag::class)->getMock();
188188

189189
return $request;
190190
}

Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class DefaultAuthenticationSuccessHandlerTest extends TestCase
2323
*/
2424
public function testRequestRedirections(Request $request, $options, $redirectedUrl)
2525
{
26-
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
26+
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
2727
$urlGenerator->expects($this->any())->method('generate')->willReturn('http://localhost/login');
2828
$httpUtils = new HttpUtils($urlGenerator);
29-
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
29+
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
3030
$handler = new DefaultAuthenticationSuccessHandler($httpUtils, $options);
3131
if ($request->hasSession()) {
3232
$handler->setProviderKey('admin');
@@ -36,7 +36,7 @@ public function testRequestRedirections(Request $request, $options, $redirectedU
3636

3737
public function getRequestRedirections()
3838
{
39-
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
39+
$session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock();
4040
$session->expects($this->once())->method('get')->with('_security.admin.target_path')->willReturn('/admin/dashboard');
4141
$session->expects($this->once())->method('remove')->with('_security.admin.target_path');
4242
$requestWithSession = Request::create('/');

Tests/Authentication/SimpleAuthenticationHandlerTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class SimpleAuthenticationHandlerTest extends TestCase
3838

3939
protected function setUp(): void
4040
{
41-
$this->successHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock();
42-
$this->failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
41+
$this->successHandler = $this->getMockBuilder(AuthenticationSuccessHandlerInterface::class)->getMock();
42+
$this->failureHandler = $this->getMockBuilder(AuthenticationFailureHandlerInterface::class)->getMock();
4343

44-
$this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
45-
$this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
44+
$this->request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
45+
$this->token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
4646
// No methods are invoked on the exception; we just assert on its class
4747
$this->authenticationException = new AuthenticationException();
4848

@@ -51,7 +51,7 @@ protected function setUp(): void
5151

5252
public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNotASuccessHandler()
5353
{
54-
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
54+
$authenticator = $this->getMockBuilder(SimpleAuthenticatorInterface::class)->getMock();
5555

5656
$this->successHandler->expects($this->once())
5757
->method('onAuthenticationSuccess')
@@ -69,7 +69,7 @@ public function testOnAuthenticationSuccessCallsSimpleAuthenticator()
6969
$this->successHandler->expects($this->never())
7070
->method('onAuthenticationSuccess');
7171

72-
$authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface');
72+
$authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface::class);
7373
$authenticator->expects($this->once())
7474
->method('onAuthenticationSuccess')
7575
->with($this->request, $this->token)
@@ -83,12 +83,12 @@ public function testOnAuthenticationSuccessCallsSimpleAuthenticator()
8383

8484
public function testOnAuthenticationSuccessThrowsAnExceptionIfNonResponseIsReturned()
8585
{
86-
$this->expectException('UnexpectedValueException');
86+
$this->expectException(\UnexpectedValueException::class);
8787
$this->expectExceptionMessage('onAuthenticationSuccess()" method must return null to use the default success handler, or a Response object');
8888
$this->successHandler->expects($this->never())
8989
->method('onAuthenticationSuccess');
9090

91-
$authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface');
91+
$authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface::class);
9292
$authenticator->expects($this->once())
9393
->method('onAuthenticationSuccess')
9494
->with($this->request, $this->token)
@@ -105,7 +105,7 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfNullIsRetu
105105
->with($this->request, $this->token)
106106
->willReturn($this->response);
107107

108-
$authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface');
108+
$authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface::class);
109109
$authenticator->expects($this->once())
110110
->method('onAuthenticationSuccess')
111111
->with($this->request, $this->token)
@@ -119,7 +119,7 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfNullIsRetu
119119

120120
public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNotAFailureHandler()
121121
{
122-
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
122+
$authenticator = $this->getMockBuilder(SimpleAuthenticatorInterface::class)->getMock();
123123

124124
$this->failureHandler->expects($this->once())
125125
->method('onAuthenticationFailure')
@@ -137,7 +137,7 @@ public function testOnAuthenticationFailureCallsSimpleAuthenticator()
137137
$this->failureHandler->expects($this->never())
138138
->method('onAuthenticationFailure');
139139

140-
$authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface');
140+
$authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface::class);
141141
$authenticator->expects($this->once())
142142
->method('onAuthenticationFailure')
143143
->with($this->request, $this->authenticationException)
@@ -151,12 +151,12 @@ public function testOnAuthenticationFailureCallsSimpleAuthenticator()
151151

152152
public function testOnAuthenticationFailureThrowsAnExceptionIfNonResponseIsReturned()
153153
{
154-
$this->expectException('UnexpectedValueException');
154+
$this->expectException(\UnexpectedValueException::class);
155155
$this->expectExceptionMessage('onAuthenticationFailure()" method must return null to use the default failure handler, or a Response object');
156156
$this->failureHandler->expects($this->never())
157157
->method('onAuthenticationFailure');
158158

159-
$authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface');
159+
$authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface::class);
160160
$authenticator->expects($this->once())
161161
->method('onAuthenticationFailure')
162162
->with($this->request, $this->authenticationException)
@@ -173,7 +173,7 @@ public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfNullIsRetu
173173
->with($this->request, $this->authenticationException)
174174
->willReturn($this->response);
175175

176-
$authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface');
176+
$authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface::class);
177177
$authenticator->expects($this->once())
178178
->method('onAuthenticationFailure')
179179
->with($this->request, $this->authenticationException)

Tests/EntryPoint/BasicAuthenticationEntryPointTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class BasicAuthenticationEntryPointTest extends TestCase
1919
{
2020
public function testStart()
2121
{
22-
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
22+
$request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
2323

2424
$authException = new AuthenticationException('The exception message');
2525

@@ -32,7 +32,7 @@ public function testStart()
3232

3333
public function testStartWithoutAuthException()
3434
{
35-
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
35+
$request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
3636

3737
$entryPoint = new BasicAuthenticationEntryPoint('TheRealmName');
3838

Tests/EntryPoint/FormAuthenticationEntryPointTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class FormAuthenticationEntryPointTest extends TestCase
2121
{
2222
public function testStart()
2323
{
24-
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
24+
$request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock();
2525
$response = new RedirectResponse('/the/login/path');
2626

27-
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
28-
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
27+
$httpKernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
28+
$httpUtils = $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)->getMock();
2929
$httpUtils
3030
->expects($this->once())
3131
->method('createRedirectResponse')
@@ -40,19 +40,19 @@ public function testStart()
4040

4141
public function testStartWithUseForward()
4242
{
43-
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
44-
$subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
43+
$request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock();
44+
$subRequest = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock();
4545
$response = new Response('', 200);
4646

47-
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
47+
$httpUtils = $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)->getMock();
4848
$httpUtils
4949
->expects($this->once())
5050
->method('createRequest')
5151
->with($this->equalTo($request), $this->equalTo('/the/login/path'))
5252
->willReturn($subRequest)
5353
;
5454

55-
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
55+
$httpKernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
5656
$httpKernel
5757
->expects($this->once())
5858
->method('handle')

Tests/EntryPoint/RetryAuthenticationEntryPointTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ public function testStart($httpPort, $httpsPort, $request, $expectedUrl)
2525
$entryPoint = new RetryAuthenticationEntryPoint($httpPort, $httpsPort);
2626
$response = $entryPoint->start($request);
2727

28-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
28+
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $response);
2929
$this->assertEquals($expectedUrl, $response->headers->get('Location'));
3030
}
3131

3232
public function dataForStart()
3333
{
34-
if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
34+
if (!class_exists(Request::class)) {
3535
return [[]];
3636
}
3737

0 commit comments

Comments
 (0)