Skip to content

Commit be11fb4

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: Use ::class keyword when possible
2 parents 2fe42d8 + c25a04f commit be11fb4

File tree

4 files changed

+28
-24
lines changed

4 files changed

+28
-24
lines changed

Tests/EventListener/SessionStrategyListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function createEvent($firewallName)
6868

6969
private function configurePreviousSession()
7070
{
71-
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
71+
$session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock();
7272
$session->expects($this->any())
7373
->method('getName')
7474
->willReturn('test_session_name');

Tests/Firewall/LogoutListenerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function testHandleMatchedPathWithoutCsrfValidation()
121121

122122
public function testNoResponseSet()
123123
{
124-
$this->expectException('RuntimeException');
124+
$this->expectException(\RuntimeException::class);
125125

126126
[$listener, , $httpUtils, $options] = $this->getListener();
127127

@@ -137,7 +137,7 @@ public function testNoResponseSet()
137137

138138
public function testCsrfValidationFails()
139139
{
140-
$this->expectException('Symfony\Component\Security\Core\Exception\LogoutException');
140+
$this->expectException(\Symfony\Component\Security\Core\Exception\LogoutException::class);
141141
$tokenManager = $this->getTokenManager();
142142

143143
[$listener, , $httpUtils, $options] = $this->getListener(null, $tokenManager);
@@ -194,12 +194,12 @@ public function testLegacyLogoutHandlers()
194194

195195
private function getTokenManager()
196196
{
197-
return $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock();
197+
return $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock();
198198
}
199199

200200
private function getTokenStorage()
201201
{
202-
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
202+
return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
203203
}
204204

205205
private function getGetResponseEvent()
@@ -217,7 +217,7 @@ private function getGetResponseEvent()
217217

218218
private function getHttpUtils()
219219
{
220-
return $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')
220+
return $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)
221221
->disableOriginalConstructor()
222222
->getMock();
223223
}
@@ -247,6 +247,6 @@ private function getEventDispatcher()
247247

248248
private function getToken()
249249
{
250-
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
250+
return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
251251
}
252252
}

Tests/FirewallTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
namespace Symfony\Component\Security\Http\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
16+
use Symfony\Component\HttpFoundation\Request;
1517
use Symfony\Component\HttpKernel\Event\RequestEvent;
1618
use Symfony\Component\HttpKernel\HttpKernelInterface;
1719
use Symfony\Component\Security\Http\Firewall;
20+
use Symfony\Component\Security\Http\Firewall\ExceptionListener;
21+
use Symfony\Component\Security\Http\FirewallMapInterface;
1822

1923
class FirewallTest extends TestCase
2024
{

Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testAutoLoginThrowsExceptionOnNonExistentToken()
6262
$tokenValue = 'foovalue',
6363
]));
6464

65-
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
65+
$tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
6666
$tokenProvider
6767
->expects($this->once())
6868
->method('loadTokenBySeries')
@@ -81,7 +81,7 @@ public function testAutoLoginReturnsNullOnNonExistentUser()
8181
$request = new Request();
8282
$request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue']));
8383

84-
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
84+
$tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
8585
$tokenProvider
8686
->expects($this->once())
8787
->method('loadTokenBySeries')
@@ -106,7 +106,7 @@ public function testAutoLoginThrowsExceptionOnStolenCookieAndRemovesItFromThePer
106106
$request = new Request();
107107
$request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue']));
108108

109-
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
109+
$tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
110110
$service->setTokenProvider($tokenProvider);
111111

112112
$tokenProvider
@@ -137,7 +137,7 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie()
137137
$request = new Request();
138138
$request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue']));
139139

140-
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
140+
$tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
141141
$tokenProvider
142142
->expects($this->once())
143143
->method('loadTokenBySeries')
@@ -156,7 +156,7 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie()
156156
*/
157157
public function testAutoLogin(bool $hashTokenValue)
158158
{
159-
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
159+
$user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock();
160160
$user
161161
->expects($this->once())
162162
->method('getRoles')
@@ -175,7 +175,7 @@ public function testAutoLogin(bool $hashTokenValue)
175175
$request = new Request();
176176
$request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue']));
177177

178-
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
178+
$tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
179179
$tokenValue = $hashTokenValue ? $this->generateHash('foovalue') : 'foovalue';
180180
$tokenProvider
181181
->expects($this->once())
@@ -187,7 +187,7 @@ public function testAutoLogin(bool $hashTokenValue)
187187

188188
$returnedToken = $service->autoLogin($request);
189189

190-
$this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', $returnedToken);
190+
$this->assertInstanceOf(\Symfony\Component\Security\Core\Authentication\Token\RememberMeToken::class, $returnedToken);
191191
$this->assertSame($user, $returnedToken->getUser());
192192
$this->assertEquals('foosecret', $returnedToken->getSecret());
193193
$this->assertTrue($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME));
@@ -199,9 +199,9 @@ public function testLogout()
199199
$request = new Request();
200200
$request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue']));
201201
$response = new Response();
202-
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
202+
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
203203

204-
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
204+
$tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
205205
$tokenProvider
206206
->expects($this->once())
207207
->method('deleteTokenBySeries')
@@ -225,9 +225,9 @@ public function testLogoutSimplyIgnoresNonSetRequestCookie()
225225
$service = $this->getService(null, ['name' => 'foo', 'path' => null, 'domain' => null]);
226226
$request = new Request();
227227
$response = new Response();
228-
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
228+
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
229229

230-
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
230+
$tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
231231
$tokenProvider
232232
->expects($this->never())
233233
->method('deleteTokenBySeries')
@@ -248,9 +248,9 @@ public function testLogoutSimplyIgnoresInvalidCookie()
248248
$request = new Request();
249249
$request->cookies->set('foo', 'somefoovalue');
250250
$response = new Response();
251-
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
251+
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
252252

253-
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
253+
$tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
254254
$tokenProvider
255255
->expects($this->never())
256256
->method('deleteTokenBySeries')
@@ -278,20 +278,20 @@ public function testLoginSuccessSetsCookieWhenLoggedInWithNonRememberMeTokenInte
278278
$request = new Request();
279279
$response = new Response();
280280

281-
$account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
281+
$account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock();
282282
$account
283283
->expects($this->once())
284284
->method('getUsername')
285285
->willReturn('foo')
286286
;
287-
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
287+
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
288288
$token
289289
->expects($this->any())
290290
->method('getUser')
291291
->willReturn($account)
292292
;
293293

294-
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
294+
$tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
295295
$tokenProvider
296296
->expects($this->once())
297297
->method('createNewToken')
@@ -334,7 +334,7 @@ protected function getService($userProvider = null, $options = [], $logger = nul
334334

335335
protected function getProvider()
336336
{
337-
$provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
337+
$provider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock();
338338
$provider
339339
->expects($this->any())
340340
->method('supportsClass')

0 commit comments

Comments
 (0)