From 5b91f12ab7256461ba16121e85b3e7e419a43b4a Mon Sep 17 00:00:00 2001 From: nikic Date: Sat, 2 Jul 2011 23:53:43 +0200 Subject: [PATCH] Update tests --- test/Twig/Tests/Node/Expression/GetAttrTest.php | 6 +++--- test/Twig/Tests/Node/Expression/NameTest.php | 2 +- test/Twig/Tests/Node/ForTest.php | 14 +++++++------- test/Twig/Tests/Node/IfTest.php | 10 +++++----- test/Twig/Tests/Node/SetTest.php | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/Twig/Tests/Node/Expression/GetAttrTest.php b/test/Twig/Tests/Node/Expression/GetAttrTest.php index 7b38e03..298b532 100644 --- a/test/Twig/Tests/Node/Expression/GetAttrTest.php +++ b/test/Twig/Tests/Node/Expression/GetAttrTest.php @@ -49,10 +49,10 @@ class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Tests_Node_TestCase $attr = new Twig_Node_Expression_Constant('bar', 0); $args = new Twig_Node(); $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ANY_CALL, 0); - $tests[] = array($node, '$this->getAttribute((isset($context[\'foo\']) ? $context[\'foo\'] : null), "bar", array(), "any", false)'); + $tests[] = array($node, '$this->getAttribute($this->getContext($context, \'foo\'), "bar", array(), "any", false)'); $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 0); - $tests[] = array($node, '$this->getAttribute((isset($context[\'foo\']) ? $context[\'foo\'] : null), "bar", array(), "array", false)'); + $tests[] = array($node, '$this->getAttribute($this->getContext($context, \'foo\'), "bar", array(), "array", false)'); $args = new Twig_Node(array( @@ -60,7 +60,7 @@ class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Tests_Node_TestCase new Twig_Node_Expression_Constant('bar', 0), )); $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::METHOD_CALL, 0); - $tests[] = array($node, '$this->getAttribute((isset($context[\'foo\']) ? $context[\'foo\'] : null), "bar", array((isset($context[\'foo\']) ? $context[\'foo\'] : null), "bar", ), "method", false)'); + $tests[] = array($node, '$this->getAttribute($this->getContext($context, \'foo\'), "bar", array($this->getContext($context, \'foo\'), "bar", ), "method", false)'); return $tests; } diff --git a/test/Twig/Tests/Node/Expression/NameTest.php b/test/Twig/Tests/Node/Expression/NameTest.php index 3d8e03a..b69707f 100644 --- a/test/Twig/Tests/Node/Expression/NameTest.php +++ b/test/Twig/Tests/Node/Expression/NameTest.php @@ -42,7 +42,7 @@ class Twig_Tests_Node_Expression_NameTest extends Twig_Tests_Node_TestCase return array( array($node, '$this->getContext($context, \'foo\')', $env), - array($node, '(isset($context[\'foo\']) ? $context[\'foo\'] : null)'), + array($node, '$this->getContext($context, \'foo\')'), array($self, '$this'), array($context, '$context'), ); diff --git a/test/Twig/Tests/Node/ForTest.php b/test/Twig/Tests/Node/ForTest.php index b1a1457..57f3fad 100644 --- a/test/Twig/Tests/Node/ForTest.php +++ b/test/Twig/Tests/Node/ForTest.php @@ -61,9 +61,9 @@ class Twig_Tests_Node_ForTest extends Twig_Tests_Node_TestCase $tests[] = array($node, <<getContext(\$context, 'items')); foreach (\$context['_seq'] as \$context['key'] => \$context['item']) { - echo (isset(\$context['foo']) ? \$context['foo'] : null); + echo \$this->getContext(\$context, 'foo'); } \$_parent = \$context['_parent']; unset(\$context['_seq'], \$context['_iterated'], \$context['key'], \$context['item'], \$context['_parent'], \$context['loop']); @@ -81,7 +81,7 @@ EOF $tests[] = array($node, <<getContext(\$context, 'values')); \$context['loop'] = array( 'parent' => \$context['_parent'], 'index0' => 0, @@ -96,7 +96,7 @@ if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_ \$context['loop']['last'] = 1 === \$length; } foreach (\$context['_seq'] as \$context['k'] => \$context['v']) { - echo (isset(\$context['foo']) ? \$context['foo'] : null); + echo \$this->getContext(\$context, 'foo'); ++\$context['loop']['index0']; ++\$context['loop']['index']; \$context['loop']['first'] = false; @@ -122,7 +122,7 @@ EOF $tests[] = array($node, <<getContext(\$context, 'values')); \$context['_iterated'] = false; \$context['loop'] = array( 'parent' => \$context['_parent'], @@ -138,7 +138,7 @@ if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_ \$context['loop']['last'] = 1 === \$length; } foreach (\$context['_seq'] as \$context['k'] => \$context['v']) { - echo (isset(\$context['foo']) ? \$context['foo'] : null); + echo \$this->getContext(\$context, 'foo'); \$context['_iterated'] = true; ++\$context['loop']['index0']; ++\$context['loop']['index']; @@ -150,7 +150,7 @@ foreach (\$context['_seq'] as \$context['k'] => \$context['v']) { } } if (!\$context['_iterated']) { - echo (isset(\$context['foo']) ? \$context['foo'] : null); + echo \$this->getContext(\$context, 'foo'); } \$_parent = \$context['_parent']; unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']); diff --git a/test/Twig/Tests/Node/IfTest.php b/test/Twig/Tests/Node/IfTest.php index ff252b5..4b9a048 100644 --- a/test/Twig/Tests/Node/IfTest.php +++ b/test/Twig/Tests/Node/IfTest.php @@ -55,7 +55,7 @@ class Twig_Tests_Node_IfTest extends Twig_Tests_Node_TestCase $tests[] = array($node, <<getContext(\$context, 'foo'); } EOF ); @@ -71,9 +71,9 @@ EOF $tests[] = array($node, <<getContext(\$context, 'foo'); } elseif (false) { - echo (isset(\$context['bar']) ? \$context['bar'] : null); + echo \$this->getContext(\$context, 'bar'); } EOF ); @@ -87,9 +87,9 @@ EOF $tests[] = array($node, <<getContext(\$context, 'foo'); } else { - echo (isset(\$context['bar']) ? \$context['bar'] : null); + echo \$this->getContext(\$context, 'bar'); } EOF ); diff --git a/test/Twig/Tests/Node/SetTest.php b/test/Twig/Tests/Node/SetTest.php index 6f61922..169ea40 100644 --- a/test/Twig/Tests/Node/SetTest.php +++ b/test/Twig/Tests/Node/SetTest.php @@ -59,7 +59,7 @@ EOF $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 0), new Twig_Node_Expression_Name('bar', 0)), array(), 0); $node = new Twig_Node_Set(false, $names, $values, 0); $tests[] = array($node, <<getContext(\$context, 'bar')); EOF ); -- 1.7.2.5