From 8410f8caa932c1b2254176b7df1858b2729786c5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Pineau?= Date: Sun, 1 Sep 2013 01:06:11 +0200 Subject: [PATCH] Added Tests to prevent future regression --- test/Twig/Tests/Loader/FilesystemTest.php | 16 ++++++++++++++++ .../Loader/Fixtures/themes/theme1/blocks.html.twig | 3 +++ .../Loader/Fixtures/themes/theme2/blocks.html.twig | 3 +++ 3 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 test/Twig/Tests/Loader/Fixtures/themes/theme1/blocks.html.twig create mode 100644 test/Twig/Tests/Loader/Fixtures/themes/theme2/blocks.html.twig 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 %} -- 1.7.2.5