use Twig\Loader\LoaderInterface;
use Twig\Node\Expression\NameExpression;
use Twig\Node\TextNode;
/**
* @author Asmir Mustafic <goetas@gmail.com>
*/
class TransNodeTest extends TestCase
{ public function testCompileStrict() { $body =
new TextNode('trans %var%', 0
);
$vars =
new NameExpression('foo', 0
);
$node =
new TransNode($body, null, null,
$vars);
$env =
new Environment($this->
createMock(LoaderInterface::
class),
['strict_variables' => true
]);
$compiler =
new Compiler($env);
$this->
assertEquals( sprintf( 'echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans("trans %%var%%", array_merge(["%%var%%" => %s], %s), "messages");',
$this->
getVariableGetterWithoutStrictCheck('var'
),
$this->
getVariableGetterWithStrictCheck('foo'
) ),