Skip to content

Commit

Permalink
Avoid passing arguments to new FormExtension()
Browse files Browse the repository at this point in the history
This fixes a twig bridge deprecation.
  • Loading branch information
greg0ire authored and soullivaneuh committed Nov 4, 2017
1 parent c7c292b commit 03d0add
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Tests/Controller/CRUDControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ protected function setUp()

$twigRenderer = $this->createMock('Symfony\Bridge\Twig\Form\TwigRendererInterface');

$formExtension = new FormExtension($twigRenderer);
if (method_exists('Symfony\Bridge\Twig\AppVariable', 'getToken')) {
$formExtension = new FormExtension();
} else {
// Remove this else clause when dropping sf < 3.2
$formExtension = new FormExtension($twigRenderer);
}

$twig->expects($this->any())
->method('getExtension')
Expand Down
11 changes: 9 additions & 2 deletions Tests/Controller/HelperControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,10 @@ public function testappendFormFieldElementAction($validatorInterface)
->will($this->returnValue(new Response()));

$twig = new \Twig_Environment($this->createMock('\Twig_LoaderInterface'));
$twig->addExtension(new FormExtension($mockRenderer));

// Remove the condition when dropping sf < 3.2
if (method_exists('Symfony\Bridge\Twig\AppVariable', 'getToken')) {
$twig->addExtension(new FormExtension());
$runtimeLoader = $this
->getMockBuilder('Twig_RuntimeLoaderInterface')
->getMock();
Expand All @@ -352,6 +353,8 @@ public function testappendFormFieldElementAction($validatorInterface)
->will($this->returnValue($mockRenderer));

$twig->addRuntimeLoader($runtimeLoader);
} else {
$twig->addExtension(new FormExtension($mockRenderer));
}

$request = new Request([
Expand Down Expand Up @@ -453,8 +456,10 @@ public function testRetrieveFormFieldElementAction($validatorInterface)
->will($this->returnValue(new Response()));

$twig = new \Twig_Environment($this->createMock('\Twig_LoaderInterface'));
$twig->addExtension(new FormExtension($mockRenderer));

// Remove the condition when dropping sf < 3.2
if (method_exists('Symfony\Bridge\Twig\AppVariable', 'getToken')) {
$twig->addExtension(new FormExtension());
$runtimeLoader = $this
->getMockBuilder('Twig_RuntimeLoaderInterface')
->getMock();
Expand All @@ -465,6 +470,8 @@ public function testRetrieveFormFieldElementAction($validatorInterface)
->will($this->returnValue($mockRenderer));

$twig->addRuntimeLoader($runtimeLoader);
} else {
$twig->addExtension(new FormExtension($mockRenderer));
}

$pool = new Pool($container, 'title', 'logo');
Expand Down

0 comments on commit 03d0add

Please sign in to comment.