Skip to content

[FrameworkBundle][Security] Remove useless mocks #19736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;

use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine;
use Symfony\Component\HttpFoundation\Response;

class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -60,7 +61,7 @@ public function testGetInvalidEngine()

public function testRenderResponseWithFrameworkEngine()
{
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
$response = new Response();
$engine = $this->getFrameworkEngineMock('template.php', true);
$engine->expects($this->once())
->method('renderResponse')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;

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

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

public function testRedirect()
{
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
$response = new Response();
$this->httpUtils->expects($this->once())
->method('createRedirectResponse')->with($this->request, '/login')
->will($this->returnValue($response));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

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

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler;

class DefaultAuthenticationSuccessHandlerTest extends \PHPUnit_Framework_TestCase
Expand Down Expand Up @@ -157,8 +158,7 @@ public function testRefererTargetPathIsIgnoredByDefault()

private function expectRedirectResponse($path)
{
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');

$response = new Response();
$this->httpUtils->expects($this->once())
->method('createRedirectResponse')
->with($this->request, $path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Security\Http\Tests;

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

$this->response = $this->getMock('Symfony\Component\HttpFoundation\Response');
$this->response = new Response();
}

public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNotASuccessHandler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

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

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint;
use Symfony\Component\HttpKernel\HttpKernelInterface;

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

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

$httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
$httpUtils
Expand Down
5 changes: 3 additions & 2 deletions src/Symfony/Component/Security/Http/Tests/FirewallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

namespace Symfony\Component\Security\Http\Tests;

use Symfony\Component\Security\Http\Firewall;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Http\Firewall;

class FirewallTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -46,7 +47,7 @@ public function testOnKernelRequestRegistersExceptionListener()

public function testOnKernelRequestStopsWhenThereIsAResponse()
{
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
$response = new Response();

$first = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface');
$first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@

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

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler;

class DefaultLogoutSuccessHandlerTest extends \PHPUnit_Framework_TestCase
{
public function testLogout()
{
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
$response = new Response();

$httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
$httpUtils->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Security\Http\RememberMe\ResponseListener;
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpKernel\KernelEvents;

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

private function getResponse()
{
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
$response = new Response();
$response->headers = $this->getMock('Symfony\Component\HttpFoundation\ResponseHeaderBag');

return $response;
Expand Down