Skip to content

Commit 0c69372

Browse files
derrabusnicolas-grekas
authored andcommitted
[Security] Fix return type declarations
1 parent a90feab commit 0c69372

8 files changed

+23
-7
lines changed

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
}

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);

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();

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());

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');

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
);

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())

Tests/RememberMe/AbstractRememberMeServicesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public function testAutoLoginReturnsNullWhenNoCookie()
3939
$this->assertNull($service->autoLogin(new Request()));
4040
}
4141

42+
/**
43+
* @group legacy
44+
*/
4245
public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserInterface()
4346
{
4447
$this->expectException('RuntimeException');

0 commit comments

Comments
 (0)