mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 03:16:34 +00:00
made the tests semantically more correct
This commit is contained in:
@@ -54,11 +54,11 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
|
||||
$globals = $twig->getGlobals();
|
||||
$this->assertEquals('bar', $globals['foo']);
|
||||
|
||||
// globals can be modified after runtime init
|
||||
// globals can be modified after a template has been loaded
|
||||
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
|
||||
$twig->addGlobal('foo', 'foo');
|
||||
$twig->getGlobals();
|
||||
$twig->initRuntime();
|
||||
$twig->loadTemplate('index');
|
||||
$twig->addGlobal('foo', 'bar');
|
||||
$globals = $twig->getGlobals();
|
||||
$this->assertEquals('bar', $globals['foo']);
|
||||
@@ -72,12 +72,12 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
|
||||
$globals = $twig->getGlobals();
|
||||
$this->assertEquals('bar', $globals['foo']);
|
||||
|
||||
// globals can be modified after extensions and runtime init
|
||||
// globals can be modified after extensions and a template has been loaded
|
||||
$twig = new Twig_Environment($loader = new Twig_Loader_Array(array('index' => '{{foo}}')));
|
||||
$twig->addGlobal('foo', 'foo');
|
||||
$twig->getGlobals();
|
||||
$twig->getFunctions();
|
||||
$twig->initRuntime();
|
||||
$twig->loadTemplate('index');
|
||||
$twig->addGlobal('foo', 'bar');
|
||||
$globals = $twig->getGlobals();
|
||||
$this->assertEquals('bar', $globals['foo']);
|
||||
@@ -89,11 +89,11 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('bar', $template->render(array()));
|
||||
|
||||
/* to be uncomment in Twig 2.0
|
||||
// globals cannot be added after runtime init
|
||||
// globals cannot be added after a template has been loaded
|
||||
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
|
||||
$twig->addGlobal('foo', 'foo');
|
||||
$twig->getGlobals();
|
||||
$twig->initRuntime();
|
||||
$twig->loadTemplate('index');
|
||||
try {
|
||||
$twig->addGlobal('bar', 'bar');
|
||||
$this->fail();
|
||||
@@ -113,12 +113,12 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
|
||||
}
|
||||
|
||||
// globals cannot be added after extensions and runtime init
|
||||
// globals cannot be added after extensions and a template has been loaded
|
||||
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
|
||||
$twig->addGlobal('foo', 'foo');
|
||||
$twig->getGlobals();
|
||||
$twig->getFunctions();
|
||||
$twig->initRuntime();
|
||||
$twig->loadTemplate('index');
|
||||
try {
|
||||
$twig->addGlobal('bar', 'bar');
|
||||
$this->fail();
|
||||
@@ -126,9 +126,9 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
|
||||
}
|
||||
|
||||
// test adding globals after initRuntime without call to getGlobals
|
||||
// test adding globals after a template has been loaded without call to getGlobals
|
||||
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
|
||||
$twig->initRuntime();
|
||||
$twig->loadTemplate('index');
|
||||
try {
|
||||
$twig->addGlobal('bar', 'bar');
|
||||
$this->fail();
|
||||
|
||||
Reference in New Issue
Block a user