minor #23567 [TwigBridge] fix tests (xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[TwigBridge] fix tests

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

~The changed test did not pass locally. I do probably miss something important, but I fail to see why this did not occur when running the tests on Travis CI.~ Never mind, I was looking at the wrong build. It fails on Travis CI too.

Commits
-------

62410b6b7e [TwigBridge] fix tests
This commit is contained in:
Fabien Potencier 2017-07-18 12:28:19 +02:00
commit ab661bd29a

View File

@ -13,6 +13,9 @@ namespace Symfony\Bridge\Twig\Tests\Node;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Twig\Node\FormThemeNode;
use Symfony\Bridge\Twig\Tests\Extension\RuntimeLoaderProvider;
use Symfony\Component\Form\FormRenderer;
use Symfony\Component\Form\FormRendererEngineInterface;
use Twig\Compiler;
use Twig\Environment;
use Twig\Node\Expression\ArrayExpression;
@ -22,6 +25,8 @@ use Twig\Node\Node;
class FormThemeTest extends TestCase
{
use RuntimeLoaderProvider;
public function testConstructor()
{
$form = new NameExpression('form', 0);
@ -48,11 +53,14 @@ class FormThemeTest extends TestCase
$node = new FormThemeNode($form, $resources, 0);
$compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()));
$environment = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock());
$formRenderer = new FormRenderer($this->getMockBuilder(FormRendererEngineInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $formRenderer);
$compiler = new Compiler($environment);
$this->assertEquals(
sprintf(
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->setTheme(%s, array(0 => "tpl1", 1 => "tpl2"));',
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, array(0 => "tpl1", 1 => "tpl2"));',
$this->getVariableGetter('form')
),
trim($compiler->compile($node)->getSource())
@ -64,7 +72,7 @@ class FormThemeTest extends TestCase
$this->assertEquals(
sprintf(
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->setTheme(%s, "tpl1");',
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, "tpl1");',
$this->getVariableGetter('form')
),
trim($compiler->compile($node)->getSource())