diff --git a/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php b/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php index 8c6a74f3..e58fb63b 100644 --- a/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php +++ b/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php @@ -368,7 +368,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4)); } /** - * Test + * Test caching * @runInSeparateProcess * @preserveGlobalState disabled * @dataProvider data @@ -478,7 +478,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty } /** * - * @run InSeparateProcess + * @runInSeparateProcess * @preserveGlobalState disabled * */ @@ -503,4 +503,40 @@ class CacheResourceTestCommon extends PHPUnit_Smarty $this->assertEquals('cache resource test:51 compiled:50 rendered:51', $this->smarty->fetch($tpl), 'fetch()'); } + /** + * Test caching + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataDir + * + */ + public function testCachingTemplateDir($folder, $iscached, $merge, $result) + { + $this->smarty->setCaching(true); + if ($folder == 0) { + $this->smarty->setTemplateDir(array(__DIR__ . '/../_shared/templates', __DIR__ . '/../_shared/templates/a')); + } else { + $this->smarty->setTemplateDir(array(__DIR__ . '/../_shared/templates', __DIR__ . '/../_shared/templates/b')); + } + if ($merge) { + $this->smarty->setCompileId(1); + $this->smarty->setMergeCompiledIncludes(true); + } + $tpl = $this->smarty->createTemplate('templatedir.tpl', $this->smarty); + $this->assertEquals($iscached, $tpl->isCached()); + $this->assertContains($result, $tpl->fetch()); + } + + public function dataDir(){ + return array( + array(0,false,0, 'include a'), + array(0,true,0, 'include a'), + array(1,false,0, 'include b'), + array(1,true,0, 'include b'), + array(0,false,1, 'include a'), + array(0,true,1, 'include a'), + array(1,false,1, 'include b'), + array(1,true,1, 'include b'), + ); + } } diff --git a/tests/UnitTests/CacheResourceTests/_shared/templates/a/include.tpl b/tests/UnitTests/CacheResourceTests/_shared/templates/a/include.tpl new file mode 100644 index 00000000..9f7fedbf --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/templates/a/include.tpl @@ -0,0 +1 @@ +include a diff --git a/tests/UnitTests/CacheResourceTests/_shared/templates/b/include.tpl b/tests/UnitTests/CacheResourceTests/_shared/templates/b/include.tpl new file mode 100644 index 00000000..a7766351 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/templates/b/include.tpl @@ -0,0 +1 @@ +include b diff --git a/tests/UnitTests/CacheResourceTests/_shared/templates/templatedir.tpl b/tests/UnitTests/CacheResourceTests/_shared/templates/templatedir.tpl new file mode 100644 index 00000000..adb7ed8f --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/templates/templatedir.tpl @@ -0,0 +1 @@ +{include 'include.tpl'} \ No newline at end of file