add nocache teste

This commit is contained in:
uwetews
2016-01-03 08:18:52 +01:00
parent 7bfe828d70
commit 2b7615e23d
2 changed files with 16 additions and 12 deletions

View File

@@ -262,17 +262,18 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
* *
*/ */
public function testCache($isCached, $caching, $cachable, $testNumber, $compileTestNumber, $renderTestNumber, public function testCache($isCached, $caching, $cachable, $testNumber, $compileTestNumber, $renderTestNumber,
$resultNumber, $testName) $resultNumber, $nocache, $compileid, $testName)
{ {
$this->smarty->registerFilter('pre', array($this, 'prefilterTest')); $this->smarty->registerFilter('pre', array($this, 'prefilterTest'));
$this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'cachetest', 'myblockplugintest2', $cachable); $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'cachetest', 'myblockplugintest2', $cachable);
if ($testNumber == 13) { if ($testNumber == 13) {
$i = 0; $i = 0;
} }
$this->smarty->compile_id = $cachable ? 0 : 1; $this->smarty->compile_id = $compileid;
$this->smarty->caching = $caching; $this->smarty->caching = $caching;
$this->smarty->cache_lifetime = 1000; $this->smarty->cache_lifetime = 1000;
$this->smarty->assign('test', $testNumber); $this->smarty->assign('test', $testNumber);
$this->smarty->assign('var', $testNumber, $nocache);
$tpl = $this->smarty->createTemplate('caching.tpl', null, null, $this->smarty); $tpl = $this->smarty->createTemplate('caching.tpl', null, null, $this->smarty);
if (isset($isCached)) { if (isset($isCached)) {
$this->assertEquals($isCached, $tpl->isCached(), $testName . ' - isCached()'); $this->assertEquals($isCached, $tpl->isCached(), $testName . ' - isCached()');
@@ -285,15 +286,18 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
public function data() public function data()
{ {
return array(array(false, false, false, 1, 1, 1, 1, 'no cacheing'), return array(array(false, false, false, 1, 1, 1, 1, false, 0, 'no cacheing'),
array(false, false, false, 2, 1, 2, 2, 'no cacheing'), array(false, false, false, 2, 1, 2, 2, false, 0, 'no cacheing'),
array(false, false, true, 3, 3, 3, 3, 'cacheable'), array(false, false, true, 3, 3, 3, 3, false, 1, 'cacheable'),
array(false, true, true, 4, 4, 4, 4, 'cachable Caching'), array(false, true, true, 4, 4, 4, 4, false, 1, 'cachable Caching'),
array(true, true, true, 5, 4, 4, 4, 'cachable isCached'), array(true, true, true, 5, 4, 4, 4, false, 1, 'cachable isCached'),
array(true, true, true, 6, 4, 4, 4, 'cachable isCached'), array(true, true, true, 6, 4, 4, 4, false, 1, 'cachable isCached'),
array(false, true, false, 7, 7, 7, 7, 'not cachable'), array(false, true, false, 7, 7, 7, 7, false, 2, 'not cachable'),
array(true, true, false, 8, 7, 7, 8, 'not cachable isCached'), array(true, true, false, 8, 7, 7, 8, false, 2, 'not cachable isCached'),
array(true, true, false, 9, 7, 7, 9, 'not cachable isCached'),); array(true, true, false, 9, 7, 7, 9, false, 2, 'not cachable isCached'),
array(false, true, true, 10, 10, 10, 10, true, 3, 'not cachable nocache var'),
array(true, true, true, 11, 10, 10, 11, true, 3, 'not cachable isCached'),
array(true, true, true, 12, 10, 10, 12, true, 3, 'not cachable isCached'),);
} }
} }

View File

@@ -1 +1 @@
#test#{cachetest var=$test}hello world{/cachetest} #test#{cachetest var=$var}hello world{/cachetest}