8000 fix controller tests by xabbuh · Pull Request #18282 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

fix controller tests #18282

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
Mar 23, 2016
Merged
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 @@ -18,6 +18,8 @@
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\User\User;
Expand Down Expand Up @@ -270,15 +272,15 @@ public function testGenerateUrl()
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container->expects($this->at(0))->method('get')->will($this->returnValue($router));

$controller = new Controller();
$controller = new TestController();
$controller->setContainer($container);

$this->assertEquals('/foo', $controller->generateUrl('foo'));
}

public function testRedirect()
{
$controller = new Controller();
$controller = new TestController();
$response = $controller->redirect('http://dunglas.fr', 301);

$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
Expand All @@ -295,7 +297,7 @@ public function testRenderViewTemplating()
$container->expects($this->at(0))->method('has')->willReturn(true);
$container->expects($this->at(1))->method('get')->will($this->returnValue($templating));

$controller = new Controller();
$controller = new TestController();
$controller->setContainer($container);

$this->assertEquals('bar', $controller->renderView('foo'));
Expand All @@ -310,7 +312,7 @@ public function testRenderTemplating()
$container->expects($this->at(0))->method('has')->willReturn(true);
$container->expects($this->at(1))->method('get')->will($this->returnValue($templating));

$controller = new Controller();
$controller = new TestController();
$controller->setContainer($container);

$this->assertEquals('bar', $controller->render('foo')->getContent());
Expand All @@ -324,15 +326,15 @@ public function testStreamTemplating()
$container->expects($this->at(0))->method('has')->willReturn(true);
$container->expects($this->at(1))->method('get')->will($this->returnValue($templating));

$controller = new Controller();
$controller = new TestController();
$controller->setContainer($container);

$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $controller->stream('foo'));
}

public function testCreateNotFoundException()
{
$controller = new Controller();
$controller = new TestController();

$this->assertInstanceOf('Symfony\Component\HttpKernel\Exception\NotFoundHttpException', $controller->createNotFoundException());
}
Expand All @@ -347,7 +349,7 @@ public function testCreateForm()
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container->expects($this->at(0))->method('get')->will($this->returnValue($formFactory));

$controller = new Controller();
$controller = new TestController();
$controller->setContainer($container);

$this->assertEquals($form, $controller->createForm('foo'));
Expand All @@ -363,7 +365,7 @@ public function testCreateFormBuilder()
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container->expects($this->at(0))->method('get')->will($this->returnValue($formFactory));

$controller = new Controller();
$controller = new TestController();
$controller->setContainer($container);

$this->assertEquals($formBuilder, $controller->createFormBuilder('foo'));
Expand All @@ -377,7 +379,7 @@ public function testGetDoctrine()
$container->expects($this->at(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($doctrine));

$controller = new Controller();
$controller = new TestController();
$controller->setContainer($container);

$this->assertEquals($doctrine, $controller->getDoctrine());
Expand All @@ -386,6 +388,16 @@ public function testGetDoctrine()

class TestController extends Controller
{
public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
{
return parent::generateUrl($route, $parameters, $referenceType);
}

public function redirect($url, $status = 302)
{
return parent::redirect($url, $status);
}

public function forward($controller, array $path = array(), array $query = array())
{
return parent::forward($controller, $path, $query);
Expand Down Expand Up @@ -420,4 +432,44 @@ public function isCsrfTokenValid($id, $token)
{
return parent::isCsrfTokenValid($id, $token);
}

public function renderView($view, array $parameters = array())
{
return parent::renderView($view, $parameters);
}

public function render($view, array $parameters = array(), Response $response = null)
{
return parent::render($view, $parameters, $response);
}

public function stream($view, array $parameters = array(), StreamedResponse $response = null)
{
return parent::stream($view, $parameters, $response);
}

public function createNotFoundException($message = 'Not Found', \Exception $previous = null)
{
return parent::createNotFoundException($message, $previous);
}

public function createAccessDeniedException($message = 'Access Denied.', \Exception $previous = null)
{
return parent::createAccessDeniedException($message, $previous);
}

public function createForm($type, $data = null, array $options = array())
{
return parent::createForm($type, $data, $options);
}

public function createFormBuilder($data = null, array $options = array())
{
return parent::createFormBuilder($data, $options);
}

public function getDoctrine()
{
return parent::getDoctrine();
}
}
0