Update clear compiled tests

This commit is contained in:
uwetews
2016-09-19 22:25:57 +02:00
parent da69e4d7af
commit eebbecf603
3 changed files with 44 additions and 504 deletions

View File

@@ -148,8 +148,8 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
} }
if (!is_dir($dir . '/templates_c')) { if (!is_dir($dir . '/templates_c')) {
mkdir($dir . '/templates_c'); mkdir($dir . '/templates_c');
chmod($dir . '/templates_c', 0775);
} }
chmod($dir . '/templates_c', 0775);
if (!is_dir($dir . '/cache')) { if (!is_dir($dir . '/cache')) {
mkdir($dir . '/cache'); mkdir($dir . '/cache');
chmod($dir . '/cache', 0775); chmod($dir . '/cache', 0775);
@@ -173,6 +173,7 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
$this->smartyBC->setCacheDir(dirname(__FILE__) . '/cache'); $this->smartyBC->setCacheDir(dirname(__FILE__) . '/cache');
} }
} }
$smarty = $this->getSmartyObj();
} }
/** /**
@@ -267,10 +268,13 @@ KEY `expire` (`expire`)
*/ */
public function cleanCompileDir() public function cleanCompileDir()
{ {
if (isset($this->smarty)) { $smarty = $this->getSmartyObj();
$this->cleanDir($this->smarty->getCompileDir()); if (isset($smarty)) {
} elseif (isset($this->smartyBC)) { $dir = $smarty->getCompileDir();
$this->cleanDir($this->smartyBC->getCompileDir()); $this->cleanDir($dir);
if (method_exists($smarty, '_isNewRelease')) {
$smarty->_isNewRelease($dir);
}
} }
} }

View File

@@ -6,6 +6,7 @@
* @author Uwe Tews * @author Uwe Tews
* @author Rodney Rehm * @author Rodney Rehm
*/ */
include_once dirname(__FILE__) . './ClearCompiledTest.php';
/** /**
* class for delete compiled template tests * class for delete compiled template tests
@@ -14,7 +15,7 @@
* @preserveGlobalState disabled * @preserveGlobalState disabled
* @backupStaticAttributes enabled * @backupStaticAttributes enabled
*/ */
class ClearCompiledBCTest extends PHPUnit_Smarty class ClearCompiledBCTest extends ClearCompiledTest
{ {
public $loadSmartyBC = true; public $loadSmartyBC = true;
public $loadSmarty = false; public $loadSmarty = false;
@@ -23,453 +24,6 @@ class ClearCompiledBCTest extends PHPUnit_Smarty
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smartyBC->addTemplateDir('./templates_2/'); $this->smartyBC->addTemplateDir('./templates_2/');
} $this->methodName = 'clear_compiled_tpl';
public function testInit()
{
$this->cleanDirs();
}
// helpers
/**
* clear $smarty->compile_dir
*
* @return void
*/
protected function clearFiles()
{
$directory = realpath($this->smartyBC->getCompileDir());
if (!$directory) {
return;
}
$di = new RecursiveDirectoryIterator($directory);
// $it = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST | FilesystemIterator::SKIP_DOTS);
$it = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($it as $file) {
$_file = $file->__toString();
if (preg_match("#[\\\\/]\.#", $_file)) {
continue;
}
if ($file->isDir()) {
rmdir($_file);
} else {
unlink($_file);
}
}
}
/**
* list of compiled files
*
* @var array
*/
protected $_files = array();
/**
* generate compiled files
*
* @uses $_files to store references
* @return array list of files array( id => path )
*/
protected function makeFiles()
{
$this->_files = array();
$directory_length = strlen($this->smartyBC->getCompileDir());
$templates = array(
'helloworld.tpl' => array(null, 'compile1', 'compile2'),
'helloworld2.tpl' => array(null, 'compile1', 'compile2'),
'ambiguous/case1/foobar.tpl' => array(null, 'compile1', 'compile2'),
'[1]ambiguous/case1/foobar.tpl' => array(null, 'compile1', 'compile2'),
);
foreach ($templates as $template => $compile_ids) {
foreach ($compile_ids as $compile_id) {
$tpl = $this->smartyBC->createTemplate($template, null, $compile_id);
$tpl->fetch();
$this->_files[$template . '#' . $compile_id] = substr($tpl->compiled->filepath, $directory_length);
}
}
// TODO
//Smarty::$_resource_cache = array();
//$this->smartyBC->_cache['template_objects'] = array();
return $this->_files;
}
/**
* Transform $id to $path
*
* @param array $keys IDs like "template#compile_id"
*
* @return array list of (sorted) compiled file paths
*/
protected function expectFiles($keys)
{
$files = array();
foreach ($keys as $key) {
if (isset($this->_files[$key])) {
$files[] = $this->_files[$key];
}
}
sort($files);
return $files;
}
/**
* update mtime of compiled files
*
* @param array $keys IDs like "template#compile_id"
* @param string $offset time offset added to time()
*
* @return void
*/
protected function touchFiles($keys, $offset = 0)
{
$base = $this->smartyBC->getCompileDir();
$time = time();
foreach ($keys as $key) {
if (isset($this->_files[$key])) {
file_put_contents($base . $this->_files[$key], ' #');
touch($base . $this->_files[$key], $time + $offset);
}
}
clearstatcache();
}
/**
* find all compiled files
*
* @return array list of (sorted) compiled file paths
*/
protected function getFiles()
{
$directory = realpath($this->smartyBC->getCompileDir());
if (!$directory) {
return array();
}
$directory_length = strlen($directory);
$files = array();
$di = new RecursiveDirectoryIterator($directory);
$it = new RecursiveIteratorIterator($di);
foreach ($it as $file) {
$_file = $file->__toString();
// skip anything with a /. in it.
if (preg_match("#[\\\\/]\.#", $_file) || !$file->isFile()) {
continue;
}
$files[] = substr($file->__toString(), $directory_length + 1);
}
sort($files);
return $files;
}
// Smarty::clear_compiled_tpl(null, null, null)
public function testClearAll()
{
$this->runClearAll(false);
}
public function testSubsClearAll()
{
$this->runClearAll(true);
}
public function runClearAll($useSubDirs)
{
$this->smartyBC->setUseSubDirs($useSubDirs);
$this->clearFiles();
$this->makeFiles();
$expected = array();
$this->assertEquals(12, $this->smartyBC->clear_compiled_tpl());
$this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles();
}
// Smarty::clear_compiled_tpl($template, null, null)
public function testClearTemplate()
{
$this->runClearTemplate(false);
}
public function testSubsClearTemplate()
{
$this->runClearTemplate(true);
}
public function testClearOtherTemplate()
{
$this->runClearOtherTemplate(false);
}
public function testSubsClearOtherTemplate()
{
$this->runClearOtherTemplate(true);
}
public function runClearTemplate($useSubDirs)
{
$this->smartyBC->setUseSubDirs($useSubDirs);
$this->clearFiles();
$this->makeFiles();
$expected = array(
'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2',
'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2',
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
);
$this->assertEquals(3, $this->smartyBC->clear_compiled_tpl('helloworld.tpl'));
$this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles();
}
public function runClearOtherTemplate($useSubDirs)
{
$this->smartyBC->setUseSubDirs($useSubDirs);
$this->clearFiles();
$this->makeFiles();
$expected = array_keys($this->_files);
$this->assertEquals(0, $this->smartyBC->clear_compiled_tpl('foobar.tpl'));
$this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles();
}
// Smarty::clear_compiled_tpl(null, $cache_id, null)
public function testClearCompileid()
{
$this->runClearCompileid(false);
}
public function testSubsClearCompileid()
{
$this->runClearCompileid(true);
}
public function testClearOtherCompileid()
{
$this->runClearOtherCompileid(false);
}
public function testSubsClearOtherCompileid()
{
$this->runClearOtherCompileid(true);
}
public function runClearCompileid($useSubDirs)
{
$this->smartyBC->setUseSubDirs($useSubDirs);
$this->clearFiles();
$this->makeFiles();
$expected = array(
'helloworld.tpl#', 'helloworld.tpl#compile2',
'helloworld2.tpl#', 'helloworld2.tpl#compile2',
'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile2',
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile2',
);
$count = $this->smartyBC->clear_compiled_tpl(null, 'compile1');
$this->assertEquals(4, $count);
$this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles();
}
public function runClearOtherCompileid($useSubDirs)
{
$this->smartyBC->setUseSubDirs($useSubDirs);
$this->clearFiles();
$this->makeFiles();
$expected = array_keys($this->_files);
$this->assertEquals(0, $this->smartyBC->clear_compiled_tpl(null, 'other'));
$this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles();
}
// Smarty::clear_compiled_tpl(null, null, $expired)
public function testClearExpired()
{
$this->runClearExpired(false);
}
public function testSubsClearExpired()
{
$this->runClearExpired(true);
}
public function runClearExpired($useSubDirs)
{
$this->smartyBC->setUseSubDirs($useSubDirs);
$this->clearFiles();
$this->makeFiles();
$expected = array('helloworld.tpl#', 'helloworld2.tpl#');
$this->touchFiles(array_diff(array_keys($this->_files), $expected), - 1000);
$this->assertEquals(10, $this->smartyBC->clear_compiled_tpl(null, null, 500));
$this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles();
}
// Smarty::clear_compiled_tpl($template, null, $expired)
public function testClearTemplateExpired()
{
$this->runClearTemplateExpired(false);
}
public function testSubsClearTemplateExpired()
{
$this->runClearTemplateExpired(true);
}
public function runClearTemplateExpired($useSubDirs)
{
$this->smartyBC->setUseSubDirs($useSubDirs);
$this->clearFiles();
$this->makeFiles();
$expected = array(
'helloworld.tpl#', 'helloworld.tpl#compile2',
'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2',
'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2',
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
);
$this->touchFiles(array('helloworld.tpl#compile1'), - 1000);
$this->assertEquals(1, $this->smartyBC->clear_compiled_tpl("helloworld.tpl", null, 500));
$this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles();
}
// Smarty::clear_compiled_tpl($template, $cache_id, $expired)
public function testClearTemplateCacheidExpired()
{
$this->runClearTemplateCacheidExpired(false);
}
public function testSubsClearTemplateCacheidExpired()
{
$this->runClearTemplateCacheidExpired(true);
}
public function runClearTemplateCacheidExpired($useSubDirs)
{
$this->smartyBC->setUseSubDirs($useSubDirs);
$this->clearFiles();
$this->makeFiles();
$expected = array(
'helloworld.tpl#', 'helloworld.tpl#compile2',
'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2',
'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2',
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
);
$this->touchFiles(array('helloworld.tpl#compile1', 'helloworld.tpl#compile2'), - 1000);
$this->assertEquals(1, $this->smartyBC->clear_compiled_tpl("helloworld.tpl", "compile1", 500));
$this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles();
}
// Smarty::clear_compiled_tpl(null, $cache_id, $expired)
public function testClearCacheidExpired()
{
$this->runClearCacheidExpired(false);
}
public function testSubsClearCacheidExpired()
{
$this->runClearCacheidExpired(true);
}
public function runClearCacheidExpired($useSubDirs)
{
$this->smartyBC->setUseSubDirs($useSubDirs);
$this->clearFiles();
$this->makeFiles();
$expected = array(
'helloworld.tpl#', 'helloworld.tpl#compile2',
'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2',
'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2',
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
);
$this->touchFiles(array('helloworld.tpl#compile1'), - 1000);
$this->assertEquals(1, $this->smartyBC->clear_compiled_tpl(null, "compile1", 500));
$this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles();
}
// Smarty::clear_compiled_tpl($template, $cache_id, null)
public function testClearTemplateCacheid()
{
$this->runClearTemplateCacheid(false);
}
public function testSubsClearTemplateCacheid()
{
$this->runClearTemplateCacheid(true);
}
public function runClearTemplateCacheid($useSubDirs)
{
$this->smartyBC->setUseSubDirs($useSubDirs);
$this->clearFiles();
$this->makeFiles();
$expected = array(
'helloworld.tpl#', 'helloworld.tpl#compile2',
'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2',
'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2',
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
);
$this->assertEquals(1, $this->smartyBC->clear_compiled_tpl("helloworld.tpl", "compile1"));
$this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles();
}
public function testClearAmbiguousTemplate()
{
$this->runClearAmbiguousTemplate(false);
}
public function testSubsAmbiguousTemplate()
{
$this->runClearAmbiguousTemplate(true);
}
public function runClearAmbiguousTemplate($useSubDirs)
{
$this->smartyBC->setUseSubDirs($useSubDirs);
$this->clearFiles();
$this->makeFiles();
// TODO: uwe.tews - shouldn't clear_compiled_tpl("foo.tpl") remove "{$template_dir[0]}/foo.tpl" AND "{$template_dir[1]}/foo.tpl"?
// currently it kills only the first one found (through regular template file identification methods)
$expected = array(
'helloworld.tpl#', 'helloworld.tpl#compile1', 'helloworld.tpl#compile2',
'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2',
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
);
$this->assertEquals(3, $this->smartyBC->clear_compiled_tpl("ambiguous/case1/foobar.tpl"));
$this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles();
} }
} }

View File

@@ -16,10 +16,12 @@
*/ */
class ClearCompiledTest extends PHPUnit_Smarty class ClearCompiledTest extends PHPUnit_Smarty
{ {
public $methodName = null;
public function setUp() public function setUp()
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addTemplateDir('./templates_2/'); $this->smarty->addTemplateDir('./templates_2/');
$this->methodName = 'clearCompiledTemplate';
} }
@@ -35,27 +37,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
*/ */
protected function clearFiles() protected function clearFiles()
{ {
$directory = realpath($this->smarty->getCompileDir()); $this->cleanCompileDir();
if (!$directory) {
return;
}
$di = new RecursiveDirectoryIterator($directory);
// $it = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST | FilesystemIterator::SKIP_DOTS);
$it = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($it as $file) {
$_file = $file->__toString();
if (preg_match("#[\\\\/]\.#", $_file)) {
continue;
}
if ($file->isDir()) {
rmdir($_file);
} else {
unlink($_file);
}
}
} }
/** /**
@@ -74,7 +56,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
protected function makeFiles() protected function makeFiles()
{ {
$this->_files = array(); $this->_files = array();
$directory_length = strlen($this->smarty->getCompileDir()); $directory_length = strlen($this->getSmartyObj()->getCompileDir());
$templates = array( $templates = array(
'helloworld.tpl' => array(null, 'compile1', 'compile2'), 'helloworld.tpl' => array(null, 'compile1', 'compile2'),
'helloworld2.tpl' => array(null, 'compile1', 'compile2'), 'helloworld2.tpl' => array(null, 'compile1', 'compile2'),
@@ -84,14 +66,14 @@ class ClearCompiledTest extends PHPUnit_Smarty
foreach ($templates as $template => $compile_ids) { foreach ($templates as $template => $compile_ids) {
foreach ($compile_ids as $compile_id) { foreach ($compile_ids as $compile_id) {
$tpl = $this->smarty->createTemplate($template, null, $compile_id); $tpl = $this->getSmartyObj()->createTemplate($template, null, $compile_id);
$tpl->fetch(); $tpl->fetch();
$this->_files[$template . '#' . $compile_id] = substr($tpl->compiled->filepath, $directory_length); $this->_files[$template . '#' . $compile_id] = substr($tpl->compiled->filepath, $directory_length);
} }
} }
// TODO // TODO
//Smarty::$_resource_cache = array(); //Smarty::$_resource_cache = array();
//$this->smarty->_cache['template_objects'] = array(); //$this->getSmartyObj()->_cache['template_objects'] = array();
return $this->_files; return $this->_files;
} }
@@ -126,7 +108,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
*/ */
protected function touchFiles($keys, $offset = 0) protected function touchFiles($keys, $offset = 0)
{ {
$base = $this->smarty->getCompileDir(); $base = $this->getSmartyObj()->getCompileDir();
$time = time(); $time = time();
foreach ($keys as $key) { foreach ($keys as $key) {
if (isset($this->_files[$key])) { if (isset($this->_files[$key])) {
@@ -144,7 +126,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
*/ */
protected function getFiles() protected function getFiles()
{ {
$directory = realpath($this->smarty->getCompileDir()); $directory = realpath($this->getSmartyObj()->getCompileDir());
if (!$directory) { if (!$directory) {
return array(); return array();
} }
@@ -157,7 +139,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
foreach ($it as $file) { foreach ($it as $file) {
$_file = $file->__toString(); $_file = $file->__toString();
// skip anything with a /. in it. // skip anything with a /. in it.
if (preg_match("#[\\\\/]\.#", $_file) || !$file->isFile()) { if (preg_match("#[\\\\/]\.#", $_file) || substr((string)$file,-4) === '.txt' || !$file->isFile()) {
continue; continue;
} }
@@ -181,12 +163,12 @@ class ClearCompiledTest extends PHPUnit_Smarty
public function runClearAll($useSubDirs) public function runClearAll($useSubDirs)
{ {
$this->smarty->setUseSubDirs($useSubDirs); $this->getSmartyObj()->setUseSubDirs($useSubDirs);
$this->clearFiles(); $this->clearFiles();
$this->makeFiles(); $this->makeFiles();
$expected = array(); $expected = array();
$this->assertEquals(12, $this->smarty->clearCompiledTemplate()); $this->assertEquals(12, $this->getSmartyObj()->{$this->methodName}());
$this->assertEquals($this->expectFiles($expected), $this->getFiles()); $this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles(); $this->clearFiles();
@@ -215,7 +197,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
public function runClearTemplate($useSubDirs) public function runClearTemplate($useSubDirs)
{ {
$this->smarty->setUseSubDirs($useSubDirs); $this->getSmartyObj()->setUseSubDirs($useSubDirs);
$this->clearFiles(); $this->clearFiles();
$this->makeFiles(); $this->makeFiles();
@@ -224,7 +206,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2', 'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2',
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
); );
$this->assertEquals(3, $this->smarty->clearCompiledTemplate('helloworld.tpl')); $this->assertEquals(3, $this->getSmartyObj()->{$this->methodName}('helloworld.tpl'));
$this->assertEquals($this->expectFiles($expected), $this->getFiles()); $this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles(); $this->clearFiles();
@@ -232,12 +214,12 @@ class ClearCompiledTest extends PHPUnit_Smarty
public function runClearOtherTemplate($useSubDirs) public function runClearOtherTemplate($useSubDirs)
{ {
$this->smarty->setUseSubDirs($useSubDirs); $this->getSmartyObj()->setUseSubDirs($useSubDirs);
$this->clearFiles(); $this->clearFiles();
$this->makeFiles(); $this->makeFiles();
$expected = array_keys($this->_files); $expected = array_keys($this->_files);
$this->assertEquals(0, $this->smarty->clearCompiledTemplate('foobar.tpl')); $this->assertEquals(0, $this->getSmartyObj()->{$this->methodName}('foobar.tpl'));
$this->assertEquals($this->expectFiles($expected), $this->getFiles()); $this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles(); $this->clearFiles();
@@ -266,7 +248,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
public function runClearCompileid($useSubDirs) public function runClearCompileid($useSubDirs)
{ {
$this->smarty->setUseSubDirs($useSubDirs); $this->getSmartyObj()->setUseSubDirs($useSubDirs);
$this->clearFiles(); $this->clearFiles();
$this->makeFiles(); $this->makeFiles();
@@ -276,7 +258,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile2', 'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile2',
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile2', '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile2',
); );
$count = $this->smarty->clearCompiledTemplate(null, 'compile1'); $count = $this->getSmartyObj()->{$this->methodName}(null, 'compile1');
$this->assertEquals(4, $count); $this->assertEquals(4, $count);
$this->assertEquals($this->expectFiles($expected), $this->getFiles()); $this->assertEquals($this->expectFiles($expected), $this->getFiles());
@@ -285,12 +267,12 @@ class ClearCompiledTest extends PHPUnit_Smarty
public function runClearOtherCompileid($useSubDirs) public function runClearOtherCompileid($useSubDirs)
{ {
$this->smarty->setUseSubDirs($useSubDirs); $this->getSmartyObj()->setUseSubDirs($useSubDirs);
$this->clearFiles(); $this->clearFiles();
$this->makeFiles(); $this->makeFiles();
$expected = array_keys($this->_files); $expected = array_keys($this->_files);
$this->assertEquals(0, $this->smarty->clearCompiledTemplate(null, 'other')); $this->assertEquals(0, $this->getSmartyObj()->{$this->methodName}(null, 'other'));
$this->assertEquals($this->expectFiles($expected), $this->getFiles()); $this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles(); $this->clearFiles();
@@ -309,13 +291,13 @@ class ClearCompiledTest extends PHPUnit_Smarty
public function runClearExpired($useSubDirs) public function runClearExpired($useSubDirs)
{ {
$this->smarty->setUseSubDirs($useSubDirs); $this->getSmartyObj()->setUseSubDirs($useSubDirs);
$this->clearFiles(); $this->clearFiles();
$this->makeFiles(); $this->makeFiles();
$expected = array('helloworld.tpl#', 'helloworld2.tpl#'); $expected = array('helloworld.tpl#', 'helloworld2.tpl#');
$this->touchFiles(array_diff(array_keys($this->_files), $expected), - 1000); $this->touchFiles(array_diff(array_keys($this->_files), $expected), - 1000);
$this->assertEquals(10, $this->smarty->clearCompiledTemplate(null, null, 500)); $this->assertEquals(10, $this->getSmartyObj()->{$this->methodName}(null, null, 500));
$this->assertEquals($this->expectFiles($expected), $this->getFiles()); $this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles(); $this->clearFiles();
@@ -334,7 +316,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
public function runClearTemplateExpired($useSubDirs) public function runClearTemplateExpired($useSubDirs)
{ {
$this->smarty->setUseSubDirs($useSubDirs); $this->getSmartyObj()->setUseSubDirs($useSubDirs);
$this->clearFiles(); $this->clearFiles();
$this->makeFiles(); $this->makeFiles();
@@ -345,7 +327,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
); );
$this->touchFiles(array('helloworld.tpl#compile1'), - 1000); $this->touchFiles(array('helloworld.tpl#compile1'), - 1000);
$this->assertEquals(1, $this->smarty->clearCompiledTemplate("helloworld.tpl", null, 500)); $this->assertEquals(1, $this->getSmartyObj()->{$this->methodName}("helloworld.tpl", null, 500));
$this->assertEquals($this->expectFiles($expected), $this->getFiles()); $this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles(); $this->clearFiles();
@@ -364,7 +346,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
public function runClearTemplateCacheidExpired($useSubDirs) public function runClearTemplateCacheidExpired($useSubDirs)
{ {
$this->smarty->setUseSubDirs($useSubDirs); $this->getSmartyObj()->setUseSubDirs($useSubDirs);
$this->clearFiles(); $this->clearFiles();
$this->makeFiles(); $this->makeFiles();
@@ -375,7 +357,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
); );
$this->touchFiles(array('helloworld.tpl#compile1', 'helloworld.tpl#compile2'), - 1000); $this->touchFiles(array('helloworld.tpl#compile1', 'helloworld.tpl#compile2'), - 1000);
$this->assertEquals(1, $this->smarty->clearCompiledTemplate("helloworld.tpl", "compile1", 500)); $this->assertEquals(1, $this->getSmartyObj()->{$this->methodName}("helloworld.tpl", "compile1", 500));
$this->assertEquals($this->expectFiles($expected), $this->getFiles()); $this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles(); $this->clearFiles();
@@ -394,7 +376,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
public function runClearCacheidExpired($useSubDirs) public function runClearCacheidExpired($useSubDirs)
{ {
$this->smarty->setUseSubDirs($useSubDirs); $this->getSmartyObj()->setUseSubDirs($useSubDirs);
$this->clearFiles(); $this->clearFiles();
$this->makeFiles(); $this->makeFiles();
@@ -405,7 +387,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
); );
$this->touchFiles(array('helloworld.tpl#compile1'), - 1000); $this->touchFiles(array('helloworld.tpl#compile1'), - 1000);
$this->assertEquals(1, $this->smarty->clearCompiledTemplate(null, "compile1", 500)); $this->assertEquals(1, $this->getSmartyObj()->{$this->methodName}(null, "compile1", 500));
$this->assertEquals($this->expectFiles($expected), $this->getFiles()); $this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles(); $this->clearFiles();
@@ -424,7 +406,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
public function runClearTemplateCacheid($useSubDirs) public function runClearTemplateCacheid($useSubDirs)
{ {
$this->smarty->setUseSubDirs($useSubDirs); $this->getSmartyObj()->setUseSubDirs($useSubDirs);
$this->clearFiles(); $this->clearFiles();
$this->makeFiles(); $this->makeFiles();
@@ -434,7 +416,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2', 'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2',
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
); );
$this->assertEquals(1, $this->smarty->clearCompiledTemplate("helloworld.tpl", "compile1")); $this->assertEquals(1, $this->getSmartyObj()->{$this->methodName}("helloworld.tpl", "compile1"));
$this->assertEquals($this->expectFiles($expected), $this->getFiles()); $this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles(); $this->clearFiles();
@@ -452,7 +434,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
public function runClearAmbiguousTemplate($useSubDirs) public function runClearAmbiguousTemplate($useSubDirs)
{ {
$this->smarty->setUseSubDirs($useSubDirs); $this->getSmartyObj()->setUseSubDirs($useSubDirs);
$this->clearFiles(); $this->clearFiles();
$this->makeFiles(); $this->makeFiles();
@@ -464,7 +446,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2', 'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2',
'[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2',
); );
$this->assertEquals(3, $this->smarty->clearCompiledTemplate("ambiguous/case1/foobar.tpl")); $this->assertEquals(3, $this->getSmartyObj()->{$this->methodName}("ambiguous/case1/foobar.tpl"));
$this->assertEquals($this->expectFiles($expected), $this->getFiles()); $this->assertEquals($this->expectFiles($expected), $this->getFiles());
$this->clearFiles(); $this->clearFiles();