add clearCompiledTemplate() tests

This commit is contained in:
uwetews
2016-03-11 03:29:57 +01:00
parent d744c408fe
commit 9a291b8da4
2 changed files with 28 additions and 7 deletions

View File

@@ -176,4 +176,13 @@ class EvalResourceTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('eval:base64:eyJmb29iYXIifGVzY2FwZX0='); $tpl = $this->smarty->createTemplate('eval:base64:eyJmb29iYXIifGVzY2FwZX0=');
$this->assertEquals('foobar', $tpl->fetch()); $this->assertEquals('foobar', $tpl->fetch());
} }
/**
* test clearCompiledTemplate()
*/
public function testClearCompiled()
{
$this->assertEquals(0, $this->smarty->clearCompiledTemplate('eval:hello world'));
}
} }

View File

@@ -10,7 +10,7 @@
* class for PHP resource tests * class for PHP resource tests
* *
* @runTestsInSeparateProcess * @runTestsInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* @backupStaticAttributes enabled * @backupStaticAttributes enabled
*/ */
class PhpResourceTest extends PHPUnit_Smarty class PhpResourceTest extends PHPUnit_Smarty
@@ -20,11 +20,11 @@ class PhpResourceTest extends PHPUnit_Smarty
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }
public function testInit() public function testInit()
{ {
$this->cleanDirs(); $this->cleanDirs();
} }
protected function relative($path) protected function relative($path)
{ {
$path = str_replace(str_replace("\\", "/", dirname(__FILE__)), '.', str_replace("\\", "/", $path)); $path = str_replace(str_replace("\\", "/", dirname(__FILE__)), '.', str_replace("\\", "/", $path));
@@ -95,7 +95,8 @@ class PhpResourceTest extends PHPUnit_Smarty
$this->smarty->caching = true; $this->smarty->caching = true;
$this->smarty->cache_lifetime = 1000; $this->smarty->cache_lifetime = 1000;
$tpl = $this->smarty->createTemplate('php:phphelloworld.php'); $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); $this->assertEquals($expected, $tpl->cached->filepath);
} }
@@ -263,20 +264,22 @@ class PhpResourceTest extends PHPUnit_Smarty
$this->smarty->cache_lifetime = 1000; $this->smarty->cache_lifetime = 1000;
$tpl = $this->smarty->createTemplate('php:[foo]helloworld.php'); $tpl = $this->smarty->createTemplate('php:[foo]helloworld.php');
$path = $tpl->cached->filepath; $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); $this->assertEquals($expected, $path);
} }
/** /**
* test getRenderedTemplate * test {include} php resource
*/ */
public function testIncludePhpTemplate() public function testIncludePhpTemplate()
{ {
$this->smarty->setAllowPhpTemplates(true); $this->smarty->setAllowPhpTemplates(true);
$this->assertContains('php hello world', $this->smarty->fetch('includephp.tpl')); $this->assertContains('php hello world', $this->smarty->fetch('includephp.tpl'));
} }
/** /**
* test getRenderedTemplate * test {include} php resource caching
*/ */
public function testIncludePhpTemplateCaching() public function testIncludePhpTemplateCaching()
{ {
@@ -285,4 +288,13 @@ class PhpResourceTest extends PHPUnit_Smarty
$this->assertContains('php hello world', $this->smarty->fetch('includephp.tpl')); $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'));
}
} }