Skip to content

Commit d148fe2

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Use ::class keyword when possible
2 parents 9fd2f54 + 4a63853 commit d148fe2

31 files changed

+269
-269
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/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

Tests/Firewall/AbstractPreAuthenticatedListenerTest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public function testHandleWithValidValues()
2626

2727
$request = new Request([], [], [], [], [], []);
2828

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

31-
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
31+
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
3232
$tokenStorage
3333
->expects($this->any())
3434
->method('getToken')
@@ -40,15 +40,15 @@ public function testHandleWithValidValues()
4040
->with($this->equalTo($token))
4141
;
4242

43-
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
43+
$authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock();
4444
$authenticationManager
4545
->expects($this->once())
4646
->method('authenticate')
47-
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
47+
->with($this->isInstanceOf(PreAuthenticatedToken::class))
4848
->willReturn($token)
4949
;
5050

51-
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [
51+
$listener = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener::class, [
5252
$tokenStorage,
5353
$authenticationManager,
5454
'TheProviderKey',
@@ -74,7 +74,7 @@ public function testHandleWhenAuthenticationFails()
7474

7575
$request = new Request([], [], [], [], [], []);
7676

77-
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
77+
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
7878
$tokenStorage
7979
->expects($this->any())
8080
->method('getToken')
@@ -86,15 +86,15 @@ public function testHandleWhenAuthenticationFails()
8686
;
8787

8888
$exception = new AuthenticationException('Authentication failed.');
89-
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
89+
$authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock();
9090
$authenticationManager
9191
->expects($this->once())
9292
->method('authenticate')
93-
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
93+
->with($this->isInstanceOf(PreAuthenticatedToken::class))
9494
->willThrowException($exception)
9595
;
9696

97-
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [
97+
$listener = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener::class, [
9898
$tokenStorage,
9999
$authenticationManager,
100100
'TheProviderKey',
@@ -122,7 +122,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken()
122122

123123
$request = new Request([], [], [], [], [], []);
124124

125-
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
125+
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
126126
$tokenStorage
127127
->expects($this->any())
128128
->method('getToken')
@@ -134,15 +134,15 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken()
134134
;
135135

136136
$exception = new AuthenticationException('Authentication failed.');
137-
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
137+
$authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock();
138138
$authenticationManager
139139
->expects($this->once())
140140
->method('authenticate')
141-
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
141+
->with($this->isInstanceOf(PreAuthenticatedToken::class))
142142
->willThrowException($exception)
143143
;
144144

145-
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [
145+
$listener = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener::class, [
146146
$tokenStorage,
147147
$authenticationManager,
148148
'TheProviderKey',
@@ -170,20 +170,20 @@ public function testHandleWithASimilarAuthenticatedToken()
170170

171171
$token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', ['ROLE_FOO']);
172172

173-
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
173+
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
174174
$tokenStorage
175175
->expects($this->any())
176176
->method('getToken')
177177
->willReturn($token)
178178
;
179179

180-
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
180+
$authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock();
181181
$authenticationManager
182182
->expects($this->never())
183183
->method('authenticate')
184184
;
185185

186-
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [
186+
$listener = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener::class, [
187187
$tokenStorage,
188188
$authenticationManager,
189189
'TheProviderKey',
@@ -211,7 +211,7 @@ public function testHandleWithAnInvalidSimilarToken()
211211

212212
$token = new PreAuthenticatedToken('AnotherUser', 'TheCredentials', 'TheProviderKey', ['ROLE_FOO']);
213213

214-
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
214+
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
215215
$tokenStorage
216216
->expects($this->any())
217217
->method('getToken')
@@ -224,15 +224,15 @@ public function testHandleWithAnInvalidSimilarToken()
224224
;
225225

226226
$exception = new AuthenticationException('Authentication failed.');
227-
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
227+
$authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock();
228228
$authenticationManager
229229
->expects($this->once())
230230
->method('authenticate')
231-
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
231+
->with($this->isInstanceOf(PreAuthenticatedToken::class))
232232
->willThrowException($exception)
233233
;
234234

235-
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [
235+
$listener = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener::class, [
236236
$tokenStorage,
237237
$authenticationManager,
238238
'TheProviderKey',

0 commit comments

Comments
 (0)