From: Fabien Potencier Date: Tue, 3 Apr 2012 07:45:11 +0000 (+0200) Subject: made usage of mergeContextWithGlobals in macros X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=8f242ca8585e41c297e63b019344a8f1736f88c7;p=konrad%2Ftwig.git made usage of mergeContextWithGlobals in macros --- diff --git a/lib/Twig/Node/Macro.php b/lib/Twig/Node/Macro.php index 5db1bf1..11f388b 100644 --- a/lib/Twig/Node/Macro.php +++ b/lib/Twig/Node/Macro.php @@ -44,7 +44,7 @@ class Twig_Node_Macro extends Twig_Node $compiler->write("\$context = \$this->env->getGlobals();\n\n"); } else { $compiler - ->write("\$context = array_merge(\$this->env->getGlobals(), array(\n") + ->write("\$context = \$this->mergeContextWithGlobals(array(\n") ->indent() ; diff --git a/test/Twig/Tests/Fixtures/functions/dump.test b/test/Twig/Tests/Fixtures/functions/dump.test index 1b3c453..cf6acf8 100644 --- a/test/Twig/Tests/Fixtures/functions/dump.test +++ b/test/Twig/Tests/Fixtures/functions/dump.test @@ -9,11 +9,13 @@ return array('foo' => 'foo', 'bar' => 'bar') --CONFIG-- return array('debug' => true, 'autoescape' => false); --EXPECT-- -array(2) { +array(3) { ["foo"]=> string(3) "foo" ["bar"]=> string(3) "bar" + ["global"]=> + string(6) "global" } string(3) "foo" diff --git a/test/Twig/Tests/Fixtures/tags/include/only.test b/test/Twig/Tests/Fixtures/tags/include/only.test index 22e3d0f..77760a0 100644 --- a/test/Twig/Tests/Fixtures/tags/include/only.test +++ b/test/Twig/Tests/Fixtures/tags/include/only.test @@ -10,7 +10,7 @@ --DATA-- return array('foo' => 'bar') --EXPECT-- -foo,_parent, -_parent, -foo,foo1,_parent, -foo1,_parent, +foo,global,_parent, +global,_parent, +foo,global,foo1,_parent, +foo1,global,_parent, diff --git a/test/Twig/Tests/Node/MacroTest.php b/test/Twig/Tests/Node/MacroTest.php index ddb67d1..f61c698 100644 --- a/test/Twig/Tests/Node/MacroTest.php +++ b/test/Twig/Tests/Node/MacroTest.php @@ -46,7 +46,7 @@ class Twig_Tests_Node_MacroTest extends Twig_Tests_Node_TestCase array($node, <<env->getGlobals(), array( + \$context = \$this->mergeContextWithGlobals(array( "foo" => \$foo, )); diff --git a/test/Twig/Tests/integrationTest.php b/test/Twig/Tests/integrationTest.php index cb60a82..866e86c 100644 --- a/test/Twig/Tests/integrationTest.php +++ b/test/Twig/Tests/integrationTest.php @@ -70,6 +70,7 @@ class Twig_Tests_IntegrationTest extends PHPUnit_Framework_TestCase $twig->addExtension(new Twig_Extension_Debug()); $policy = new Twig_Sandbox_SecurityPolicy(array(), array(), array(), array(), array()); $twig->addExtension(new Twig_Extension_Sandbox($policy, false)); + $twig->addGlobal('global', 'global'); try { $template = $twig->loadTemplate('index.twig');