Skip to content

Commit 796cdf6

Browse files
committed
minor #19736 [FrameworkBundle][Security] Remove useless mocks (Ener-Getick)
This PR was merged into the 2.7 branch. Discussion ---------- [FrameworkBundle][Security] Remove useless mocks | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Removes mocks causing issues in symfony/symfony#19734. Commits ------- fcd3345 [FrameworkBundle][Security] Remove useless mocks
2 parents d87f163 + 10c0459 commit 796cdf6

7 files changed

+17
-11
lines changed

Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php

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

1414
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler;
1515
use Symfony\Component\Security\Core\Security;
16+
use Symfony\Component\HttpFoundation\Response;
1617
use Symfony\Component\HttpKernel\HttpKernelInterface;
1718

1819
class DefaultAuthenticationFailureHandlerTest extends \PHPUnit_Framework_TestCase
@@ -52,7 +53,7 @@ public function testForward()
5253
->method('createRequest')->with($this->request, '/login')
5354
->will($this->returnValue($subRequest));
5455

55-
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
56+
$response = new Response();
5657
$this->httpKernel->expects($this->once())
5758
->method('handle')->with($subRequest, HttpKernelInterface::SUB_REQUEST)
5859
->will($this->returnValue($response));
@@ -65,7 +66,7 @@ public function testForward()
6566

6667
public function testRedirect()
6768
{
68-
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
69+
$response = new Response();
6970
$this->httpUtils->expects($this->once())
7071
->method('createRedirectResponse')->with($this->request, '/login')
7172
->will($this->returnValue($response));

Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Http\Tests\Authentication;
1313

14+
use Symfony\Component\HttpFoundation\Response;
1415
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler;
1516

1617
class DefaultAuthenticationSuccessHandlerTest extends \PHPUnit_Framework_TestCase
@@ -157,8 +158,7 @@ public function testRefererTargetPathIsIgnoredByDefault()
157158

158159
private function expectRedirectResponse($path)
159160
{
160-
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
161-
161+
$response = new Response();
162162
$this->httpUtils->expects($this->once())
163163
->method('createRedirectResponse')
164164
->with($this->request, $path)

Tests/Authentication/SimpleAuthenticationHandlerTest.php

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

1212
namespace Symfony\Component\Security\Http\Tests;
1313

14+
use Symfony\Component\HttpFoundation\Response;
1415
use Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface;
1516
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1617
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
@@ -41,7 +42,7 @@ protected function setUp()
4142
// No methods are invoked on the exception; we just assert on its class
4243
$this->authenticationException = new AuthenticationException();
4344

44-
$this->response = $this->getMock('Symfony\Component\HttpFoundation\Response');
45+
$this->response = new Response();
4546
}
4647

4748
public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNotASuccessHandler()

Tests/EntryPoint/FormAuthenticationEntryPointTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Http\Tests\EntryPoint;
1313

14+
use Symfony\Component\HttpFoundation\Response;
1415
use Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint;
1516
use Symfony\Component\HttpKernel\HttpKernelInterface;
1617

@@ -19,7 +20,7 @@ class FormAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
1920
public function testStart()
2021
{
2122
$request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
22-
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
23+
$response = new Response();
2324

2425
$httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
2526
$httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
@@ -39,7 +40,7 @@ public function testStartWithUseForward()
3940
{
4041
$request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
4142
$subRequest = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
42-
$response = new \Symfony\Component\HttpFoundation\Response('', 200);
43+
$response = new Response('', 200);
4344

4445
$httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
4546
$httpUtils

Tests/FirewallTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
namespace Symfony\Component\Security\Http\Tests;
1313

14-
use Symfony\Component\Security\Http\Firewall;
14+
use Symfony\Component\HttpFoundation\Response;
1515
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
1616
use Symfony\Component\HttpKernel\HttpKernelInterface;
17+
use Symfony\Component\Security\Http\Firewall;
1718

1819
class FirewallTest extends \PHPUnit_Framework_TestCase
1920
{
@@ -46,7 +47,7 @@ public function testOnKernelRequestRegistersExceptionListener()
4647

4748
public function testOnKernelRequestStopsWhenThereIsAResponse()
4849
{
49-
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
50+
$response = new Response();
5051

5152
$first = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface');
5253
$first

Tests/Logout/DefaultLogoutSuccessHandlerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111

1212
namespace Symfony\Component\Security\Http\Tests\Logout;
1313

14+
use Symfony\Component\HttpFoundation\Response;
1415
use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler;
1516

1617
class DefaultLogoutSuccessHandlerTest extends \PHPUnit_Framework_TestCase
1718
{
1819
public function testLogout()
1920
{
2021
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
21-
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
22+
$response = new Response();
2223

2324
$httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
2425
$httpUtils->expects($this->once())

Tests/RememberMe/ResponseListenerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Security\Http\RememberMe\ResponseListener;
1616
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
1717
use Symfony\Component\HttpFoundation\Request;
18+
use Symfony\Component\HttpFoundation\Response;
1819
use Symfony\Component\HttpFoundation\Cookie;
1920
use Symfony\Component\HttpKernel\KernelEvents;
2021

@@ -81,7 +82,7 @@ private function getRequest(array $attributes = array())
8182

8283
private function getResponse()
8384
{
84-
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
85+
$response = new Response();
8586
$response->headers = $this->getMock('Symfony\Component\HttpFoundation\ResponseHeaderBag');
8687

8788
return $response;

0 commit comments

Comments
 (0)