Skip to content

Commit 05344d0

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: "export-ignore" contracts and phpunit-bridge [Console][Command] Fix Closure code binding when it is a static anonymous function Use class const in test [Security] [HttpFoundation] Use class const in test [PropertyInfo] Fix breaking change with has*(arguments...) methods
2 parents cd22c52 + 7547260 commit 05344d0

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Tests/Authenticator/FormLoginAuthenticatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1617
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1718
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1819
use Symfony\Component\Security\Core\Security;
@@ -165,7 +166,7 @@ private function setUpAuthenticator(array $options = [])
165166

166167
private function createSession()
167168
{
168-
return $this->createMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
169+
return $this->createMock(SessionInterface::class);
169170
}
170171
}
171172

Tests/Firewall/AccessListenerTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
use Symfony\Component\Security\Core\Authentication\Token\NullToken;
2020
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
2121
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
22+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
2223
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
2324
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
2425
use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
2526
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
27+
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
2628
use Symfony\Component\Security\Core\User\User;
2729
use Symfony\Component\Security\Http\AccessMapInterface;
2830
use Symfony\Component\Security\Http\Event\LazyResponseEvent;
@@ -32,7 +34,7 @@ class AccessListenerTest extends TestCase
3234
{
3335
public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
3436
{
35-
$this->expectException(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class);
37+
$this->expectException(AccessDeniedException::class);
3638
$request = new Request();
3739

3840
$accessMap = $this->getMockBuilder(AccessMapInterface::class)->getMock();
@@ -43,7 +45,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
4345
->willReturn([['foo' => 'bar'], null])
4446
;
4547

46-
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
48+
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
4749
$token
4850
->expects($this->any())
4951
->method('isAuthenticated')
@@ -87,14 +89,14 @@ public function testHandleWhenTheTokenIsNotAuthenticated()
8789
->willReturn([['foo' => 'bar'], null])
8890
;
8991

90-
$notAuthenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
92+
$notAuthenticatedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
9193
$notAuthenticatedToken
9294
->expects($this->any())
9395
->method('isAuthenticated')
9496
->willReturn(false)
9597
;
9698

97-
$authenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
99+
$authenticatedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
98100
$authenticatedToken
99101
->expects($this->any())
100102
->method('isAuthenticated')
@@ -151,7 +153,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest()
151153
->willReturn([null, null])
152154
;
153155

154-
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
156+
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
155157
$token
156158
->expects($this->never())
157159
->method('isAuthenticated')
@@ -206,7 +208,7 @@ public function testHandleWhenAccessMapReturnsEmptyAttributes()
206208

207209
public function testHandleWhenTheSecurityTokenStorageHasNoToken()
208210
{
209-
$this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException::class);
211+
$this->expectException(AuthenticationCredentialsNotFoundException::class);
210212
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
211213
$tokenStorage
212214
->expects($this->any())
@@ -336,7 +338,7 @@ public function testHandleMWithultipleAttributesShouldBeHandledAsAnd()
336338
->willReturn([['foo' => 'bar', 'bar' => 'baz'], null])
337339
;
338340

339-
$authenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
341+
$authenticatedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
340342
$authenticatedToken
341343
->expects($this->any())
342344
->method('isAuthenticated')
@@ -358,7 +360,7 @@ public function testHandleMWithultipleAttributesShouldBeHandledAsAnd()
358360
$tokenStorage,
359361
$accessDecisionManager,
360362
$accessMap,
361-
$this->createMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')
363+
$this->createMock(AuthenticationManagerInterface::class)
362364
);
363365

364366
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));

Tests/Firewall/LogoutListenerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\HttpKernel\Event\RequestEvent;
2020
use Symfony\Component\Security\Http\Event\LogoutEvent;
2121
use Symfony\Component\Security\Http\Firewall\LogoutListener;
22+
use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
2223
use Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface;
2324

2425
class LogoutListenerTest extends TestCase
@@ -183,7 +184,7 @@ public function testLegacyLogoutHandlers()
183184
$response = new Response();
184185
$logoutSuccessHandler->expects($this->any())->method('onLogoutSuccess')->willReturn($response);
185186

186-
$handler = $this->createMock('Symfony\Component\Security\Http\Logout\LogoutHandlerInterface');
187+
$handler = $this->createMock(LogoutHandlerInterface::class);
187188
$handler->expects($this->once())->method('logout')->with($request, $response, $token);
188189
$listener->addHandler($handler);
189190

0 commit comments

Comments
 (0)