Added Tests to prevent future regression

This commit is contained in:
Grégoire Pineau
2013-09-01 01:06:11 +02:00
committed by Fabien Potencier
parent 3db6b6aeb9
commit 8410f8caa9
3 changed files with 22 additions and 0 deletions
+16
View File
@@ -124,4 +124,20 @@ class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase
// get index.html from the main namespace
$this->assertEquals("path\n", $loader->getSource('index.html'));
}
public function testLoadTemplateAndRenderBlockWithCache()
{
$loader = new Twig_Loader_Filesystem(array());
$loader->addPath(dirname(__FILE__).'/Fixtures/themes/theme2');
$loader->addPath(dirname(__FILE__).'/Fixtures/themes/theme1');
$loader->addPath(dirname(__FILE__).'/Fixtures/themes/theme1', 'default_theme');
$twig = new Twig_Environment($loader);
$template = $twig->loadTemplate('blocks.html.twig');
$this->assertSame('block from theme 1', $template->renderBlock('b1', array()));
$template = $twig->loadTemplate('blocks.html.twig');
$this->assertSame('block from theme 2', $template->renderBlock('b2', array()));
}
}
@@ -0,0 +1,3 @@
{% block b1 %}block from theme 1{% endblock %}
{% block b2 %}block from theme 1{% endblock %}
@@ -0,0 +1,3 @@
{% use '@default_theme/blocks.html.twig' %}
{% block b2 %}block from theme 2{% endblock %}