From: Grégoire Pineau Date: Sat, 31 Aug 2013 23:06:11 +0000 (+0200) Subject: Added Tests to prevent future regression X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=8410f8caa932c1b2254176b7df1858b2729786c5;p=web%2Fkonrad%2Ftwig.git Added Tests to prevent future regression --- diff --git a/test/Twig/Tests/Loader/FilesystemTest.php b/test/Twig/Tests/Loader/FilesystemTest.php index 3ca580b..13849b3 100644 --- a/test/Twig/Tests/Loader/FilesystemTest.php +++ b/test/Twig/Tests/Loader/FilesystemTest.php @@ -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())); + } } diff --git a/test/Twig/Tests/Loader/Fixtures/themes/theme1/blocks.html.twig b/test/Twig/Tests/Loader/Fixtures/themes/theme1/blocks.html.twig new file mode 100644 index 0000000..dd0cbc2 --- /dev/null +++ b/test/Twig/Tests/Loader/Fixtures/themes/theme1/blocks.html.twig @@ -0,0 +1,3 @@ +{% block b1 %}block from theme 1{% endblock %} + +{% block b2 %}block from theme 1{% endblock %} diff --git a/test/Twig/Tests/Loader/Fixtures/themes/theme2/blocks.html.twig b/test/Twig/Tests/Loader/Fixtures/themes/theme2/blocks.html.twig new file mode 100644 index 0000000..07cf9db --- /dev/null +++ b/test/Twig/Tests/Loader/Fixtures/themes/theme2/blocks.html.twig @@ -0,0 +1,3 @@ +{% use '@default_theme/blocks.html.twig' %} + +{% block b2 %}block from theme 2{% endblock %}