Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 1598506

Browse files
derrabusnicolas-grekas
authored andcommitted
[Security] Fix return type declarations
1 parent 3511ba3 commit 1598506

11 files changed

+32
-10
lines changed

Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
class DaoAuthenticationProviderTest extends TestCase
2020
{
21+
/**
22+
* @group legacy
23+
*/
2124
public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface()
2225
{
2326
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');

Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public function testAuthenticateWhenUsernameIsNotFoundAndHideIsTrue()
6262
$provider->authenticate($this->getSupportedToken());
6363
}
6464

65+
/**
66+
* @group legacy
67+
*/
6568
public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()
6669
{
6770
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');

Guard/Tests/Provider/GuardAuthenticationProviderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
namespace Symfony\Component\Security\Guard\Tests\Provider;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1615
use Symfony\Component\Security\Core\User\UserInterface;
1716
use Symfony\Component\Security\Guard\AuthenticatorInterface;
1817
use Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider;
18+
use Symfony\Component\Security\Guard\Token\GuardTokenInterface;
1919
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
2020
use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken;
2121

@@ -68,7 +68,7 @@ public function testAuthenticate()
6868
->with($enteredCredentials, $mockedUser)
6969
// authentication works!
7070
->willReturn(true);
71-
$authedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
71+
$authedToken = $this->getMockBuilder(GuardTokenInterface::class)->getMock();
7272
$authenticatorB->expects($this->once())
7373
->method('createAuthenticatedToken')
7474
->with($mockedUser, $providerKey)
@@ -130,7 +130,7 @@ public function testLegacyAuthenticate()
130130
->with($enteredCredentials, $mockedUser)
131131
// authentication works!
132132
->willReturn(true);
133-
$authedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
133+
$authedToken = $this->getMockBuilder(GuardTokenInterface::class)->getMock();
134134
$authenticatorB->expects($this->once())
135135
->method('createAuthenticatedToken')
136136
->with($mockedUser, $providerKey)

Http/Authentication/AuthenticationSuccessHandlerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface AuthenticationSuccessHandlerInterface
3131
* is called by authentication listeners inheriting from
3232
* AbstractAuthenticationListener.
3333
*
34-
* @return Response never null
34+
* @return Response
3535
*/
3636
public function onAuthenticationSuccess(Request $request, TokenInterface $token);
3737
}

Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Http\Tests\Authentication;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\RedirectResponse;
1516
use Symfony\Component\HttpFoundation\Response;
1617
use Symfony\Component\HttpKernel\HttpKernelInterface;
1718
use Symfony\Component\Security\Core\Security;
@@ -62,7 +63,7 @@ public function testForward()
6263

6364
public function testRedirect()
6465
{
65-
$response = new Response();
66+
$response = new RedirectResponse('/login');
6667
$this->httpUtils->expects($this->once())
6768
->method('createRedirectResponse')->with($this->request, '/login')
6869
->willReturn($response);

Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Http\Tests\EntryPoint;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\RedirectResponse;
1516
use Symfony\Component\HttpFoundation\Response;
1617
use Symfony\Component\HttpKernel\HttpKernelInterface;
1718
use Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint;
@@ -21,7 +22,7 @@ class FormAuthenticationEntryPointTest extends TestCase
2122
public function testStart()
2223
{
2324
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
24-
$response = new Response();
25+
$response = new RedirectResponse('/the/login/path');
2526

2627
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
2728
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();

Http/Tests/Firewall/ExceptionListenerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public function getAuthenticationExceptionProvider()
7272
];
7373
}
7474

75+
/**
76+
* @group legacy
77+
*/
7578
public function testExceptionWhenEntryPointReturnsBadValue()
7679
{
7780
$event = $this->createEvent(new AuthenticationException());

Http/Tests/Firewall/LogoutListenerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public function testHandleMatchedPathWithoutSuccessHandlerAndCsrfValidation()
122122
$listener->handle($event);
123123
}
124124

125+
/**
126+
* @group legacy
127+
*/
125128
public function testSuccessHandlerReturnsNonResponse()
126129
{
127130
$this->expectException('RuntimeException');

Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Tests\Http\Firewall;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\RedirectResponse;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\HttpFoundation\Response;
1718
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@@ -40,6 +41,10 @@ public function testHandleWhenUsernameLength($username, $ok)
4041
->method('checkRequestPath')
4142
->willReturn(true)
4243
;
44+
$httpUtils
45+
->method('createRedirectResponse')
46+
->willReturn(new RedirectResponse('/hello'))
47+
;
4348

4449
$failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
4550
$failureHandler
@@ -52,7 +57,7 @@ public function testHandleWhenUsernameLength($username, $ok)
5257
$authenticationManager
5358
->expects($ok ? $this->once() : $this->never())
5459
->method('authenticate')
55-
->willReturn(new Response())
60+
->willReturnArgument(0)
5661
;
5762

5863
$listener = new UsernamePasswordFormAuthenticationListener(
@@ -61,7 +66,7 @@ public function testHandleWhenUsernameLength($username, $ok)
6166
$this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(),
6267
$httpUtils,
6368
'TheProviderKey',
64-
$this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(),
69+
new DefaultAuthenticationSuccessHandler($httpUtils),
6570
$failureHandler,
6671
['require_previous_session' => false]
6772
);

Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
namespace Symfony\Component\Security\Http\Tests\Logout;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\HttpFoundation\Response;
15+
use Symfony\Component\HttpFoundation\RedirectResponse;
1616
use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler;
1717

1818
class DefaultLogoutSuccessHandlerTest extends TestCase
1919
{
2020
public function testLogout()
2121
{
2222
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
23-
$response = new Response();
23+
$response = new RedirectResponse('/dashboard');
2424

2525
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
2626
$httpUtils->expects($this->once())

0 commit comments

Comments
 (0)