Added unit test for bug when calling getGlobals() before addGlobal() on Twig_Environment.

This commit is contained in:
Jesper Ek
2013-02-08 00:08:43 +01:00
parent c6445fb5cd
commit 667b274b0d
+6
View File
@@ -81,6 +81,12 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
$globals = $twig->getGlobals();
$this->assertEquals('bar', $globals['foo']);
$twig = new Twig_Environment(new Twig_Loader_String());
$twig->getGlobals();
$twig->addGlobal('foo', 'bar');
$template = $twig->loadTemplate('{{foo}}');
$this->assertEquals('bar', $template->render(array()));
/* to be uncomment in Twig 2.0
// globals cannot be added after runtime init
$twig = new Twig_Environment(new Twig_Loader_String());