Browse files

updated unit tests for Twig 1.4

  • Loading branch information...
1 parent d5851b9 commit 61469a22194b04539af5a748dbfe4773d7deec16 @fabpot fabpot committed Nov 23, 2011
Showing with 7 additions and 7 deletions.
  1. +3 −3 test/Twig/Tests/Node/DebugTest.php
  2. +4 −4 test/Twig/Tests/Node/TransTest.php
View
6 test/Twig/Tests/Node/DebugTest.php
@@ -55,12 +55,12 @@ public function getTests()
$expr = new Twig_Node_Expression_Name('foo', 0);
$node = new Twig_Extensions_Node_Debug($expr, 0);
- $tests[] = array($node, <<<EOF
+ $tests[] = array($node, sprintf(<<<EOF
if (\$this->env->isDebug()) {
- var_dump((isset(\$context['foo']) ? \$context['foo'] : null));
+ var_dump(%s);
}
EOF
- );
+ , $this->getVariableGetter('foo')));
return $tests;
}
View
8 test/Twig/Tests/Node/TransTest.php
@@ -42,7 +42,7 @@ public function getTests()
$body = new Twig_Node_Expression_Name('foo', 0);
$node = new Twig_Extensions_Node_Trans($body, null, null, 0);
- $tests[] = array($node, 'echo gettext((isset($context[\'foo\']) ? $context[\'foo\'] : null));');
+ $tests[] = array($node, sprintf('echo gettext(%s);', $this->getVariableGetter('foo')));
$body = new Twig_Node_Expression_Constant('Hello', 0);
$node = new Twig_Extensions_Node_Trans($body, null, null, 0);
@@ -60,7 +60,7 @@ public function getTests()
new Twig_Node_Text(' pommes', 0),
), array(), 0);
$node = new Twig_Extensions_Node_Trans($body, null, null, 0);
- $tests[] = array($node, 'echo strtr(gettext("J\'ai %foo% pommes"), array("%foo%" => (isset($context[\'foo\']) ? $context[\'foo\'] : null), ));');
+ $tests[] = array($node, sprintf('echo strtr(gettext("J\'ai %%foo%% pommes"), array("%%foo%%" => %s, ));', $this->getVariableGetter('foo')));
$count = new Twig_Node_Expression_Constant(12, 0);
$body = new Twig_Node(array(
@@ -76,7 +76,7 @@ public function getTests()
new Twig_Node_Text(' apples', 0),
), array(), 0);
$node = new Twig_Extensions_Node_Trans($body, $plural, $count, 0);
- $tests[] = array($node, 'echo strtr(ngettext("Hey %name%, I have one apple", "Hey %name%, I have %count% apples", abs(12)), array("%name%" => (isset($context[\'name\']) ? $context[\'name\'] : null), "%name%" => (isset($context[\'name\']) ? $context[\'name\'] : null), "%count%" => abs(12), ));');
+ $tests[] = array($node, sprintf('echo strtr(ngettext("Hey %%name%%, I have one apple", "Hey %%name%%, I have %%count%% apples", abs(12)), array("%%name%%" => %s, "%%name%%" => %s, "%%count%%" => abs(12), ));', $this->getVariableGetter('name'), $this->getVariableGetter('name')));
// with escaper extension set to on
$body = new Twig_Node(array(
@@ -86,7 +86,7 @@ public function getTests()
), array(), 0);
$node = new Twig_Extensions_Node_Trans($body, null, null, 0);
- $tests[] = array($node, 'echo strtr(gettext("J\'ai %foo% pommes"), array("%foo%" => (isset($context[\'foo\']) ? $context[\'foo\'] : null), ));');
+ $tests[] = array($node, sprintf('echo strtr(gettext("J\'ai %%foo%% pommes"), array("%%foo%%" => %s, ));', $this->getVariableGetter('foo')));
return $tests;
}

0 comments on commit 61469a2

Please sign in to comment.