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=');
$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
*
* @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'));
}
}