From 9a291b8da4f49383f272edf396ecbcf4f3f88568 Mon Sep 17 00:00:00 2001 From: uwetews Date: Fri, 11 Mar 2016 03:29:57 +0100 Subject: [PATCH] add clearCompiledTemplate() tests --- .../ResourceTests/Eval/EvalResourceTest.php | 9 +++++++ .../ResourceTests/Php/PhpResourceTest.php | 26 ++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php b/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php index cc73cc59..a3269cbb 100644 --- a/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php +++ b/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php @@ -176,4 +176,13 @@ class EvalResourceTest extends PHPUnit_Smarty $tpl = $this->smarty->createTemplate('eval:base64:eyJmb29iYXIifGVzY2FwZX0='); $this->assertEquals('foobar', $tpl->fetch()); } + + /** + * test clearCompiledTemplate() + */ + public function testClearCompiled() + { + $this->assertEquals(0, $this->smarty->clearCompiledTemplate('eval:hello world')); + } + } diff --git a/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php b/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php index 90e966c4..dd4f20f0 100644 --- a/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php +++ b/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php @@ -10,7 +10,7 @@ * class for PHP resource tests * * @runTestsInSeparateProcess - * @preserveGlobalState disabled + * @preserveGlobalState disabled * @backupStaticAttributes enabled */ class PhpResourceTest extends PHPUnit_Smarty @@ -20,11 +20,11 @@ class PhpResourceTest extends PHPUnit_Smarty $this->setUpSmarty(dirname(__FILE__)); } - public function testInit() { $this->cleanDirs(); } + protected function relative($path) { $path = str_replace(str_replace("\\", "/", dirname(__FILE__)), '.', str_replace("\\", "/", $path)); @@ -76,7 +76,7 @@ class PhpResourceTest extends PHPUnit_Smarty $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); $this->assertFalse($tpl->source->handler->recompiled); } - + /** * test mustCompile */ @@ -95,7 +95,8 @@ class PhpResourceTest extends PHPUnit_Smarty $this->smarty->caching = true; $this->smarty->cache_lifetime = 1000; $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); - $expected = $this->buildCachedPath($tpl, false, null, null, 'phphelloworld.php', 'php', $this->smarty->getTemplateDir(0), 'file'); + $expected = $this->buildCachedPath($tpl, false, null, null, 'phphelloworld.php', 'php', + $this->smarty->getTemplateDir(0), 'file'); $this->assertEquals($expected, $tpl->cached->filepath); } @@ -263,20 +264,22 @@ class PhpResourceTest extends PHPUnit_Smarty $this->smarty->cache_lifetime = 1000; $tpl = $this->smarty->createTemplate('php:[foo]helloworld.php'); $path = $tpl->cached->filepath; - $expected = $this->buildCachedPath($tpl, false, null, null, 'helloworld.php', 'php', $this->smarty->getTemplateDir('foo'), 'file'); + $expected = $this->buildCachedPath($tpl, false, null, null, 'helloworld.php', 'php', + $this->smarty->getTemplateDir('foo'), 'file'); $this->assertEquals($expected, $path); } /** - * test getRenderedTemplate + * test {include} php resource */ public function testIncludePhpTemplate() { $this->smarty->setAllowPhpTemplates(true); $this->assertContains('php hello world', $this->smarty->fetch('includephp.tpl')); } + /** - * test getRenderedTemplate + * test {include} php resource caching */ public function testIncludePhpTemplateCaching() { @@ -285,4 +288,13 @@ class PhpResourceTest extends PHPUnit_Smarty $this->assertContains('php hello world', $this->smarty->fetch('includephp.tpl')); } + /** + * test clearCompiledTemplate() + */ + public function testClearCompiled() + { + $this->smarty->setAllowPhpTemplates(true); + $this->assertEquals(0, $this->smarty->clearCompiledTemplate('php:phphelloworld.php')); + } + }