mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
Add test for Smarty::$extends_recursion property
This commit is contained in:
@@ -225,7 +225,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
|
|||||||
/**
|
/**
|
||||||
* test relative includes in {block}
|
* test relative includes in {block}
|
||||||
*
|
*
|
||||||
* @run InSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider data
|
* @dataProvider data
|
||||||
*/
|
*/
|
||||||
@@ -266,6 +266,60 @@ class ExtendsResourceTest extends PHPUnit_Smarty
|
|||||||
array(true, true, 8, 7, 7, 'caching, merge - exits'),
|
array(true, true, 8, 7, 7, 'caching, merge - exits'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* test relative includes in {block}
|
||||||
|
*
|
||||||
|
* @runInSeparateProcess
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider data2
|
||||||
|
*/
|
||||||
|
public function testCompileBlockExtendsRecursion_034($extends_recursion, $merge, $testNumber, $compileTestNumber,
|
||||||
|
$renderTestNumber, $testName)
|
||||||
|
{
|
||||||
|
if (!property_exists($this->smarty, 'extends_recursion')) {
|
||||||
|
$this->markTestSkipped('no extends_recursion');
|
||||||
|
} else {
|
||||||
|
$this->smarty->registerFilter('pre', array($this, 'compiledPrefilter'));
|
||||||
|
$this->smarty->assign('test', $testNumber);
|
||||||
|
$this->smarty->setExtendsRecursion($extends_recursion);
|
||||||
|
$this->smarty->setMergeCompiledIncludes($merge);
|
||||||
|
$cid = 0;
|
||||||
|
if ($merge) {
|
||||||
|
$cid = 1;
|
||||||
|
}
|
||||||
|
if ($extends_recursion) {
|
||||||
|
$cid += 2;
|
||||||
|
}
|
||||||
|
$this->smarty->setCompileId($cid);
|
||||||
|
$result = $this->smarty->fetch('extends:034_parent.tpl|034_grandchild.tpl');
|
||||||
|
$this->assertContains('grandchild - grandchild', $result, $testName . ' - grand');
|
||||||
|
$this->assertContains('parent - parent', $result, $testName . ' - grand');
|
||||||
|
$this->assertContains($extends_recursion ? 'child - child' : 'child - parent', $result,
|
||||||
|
$testName . ' - grand');
|
||||||
|
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}",
|
||||||
|
$result, $testName . ' - fetch() failure');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function data2(){
|
||||||
|
return array(
|
||||||
|
/*
|
||||||
|
* extends_recursion
|
||||||
|
* merging
|
||||||
|
* test nr
|
||||||
|
* result compile nr
|
||||||
|
* result render nr
|
||||||
|
* text
|
||||||
|
*/
|
||||||
|
array(false, false, 1, 1, 1, 'no EXTENDS; no merge - new'),
|
||||||
|
array(false, false, 2, 1, 2, 'no EXTENDS; no merge - exits'),
|
||||||
|
array(true, false, 3, 3, 3, 'EXTENDS; no merge - new'),
|
||||||
|
array(true, false, 4, 3, 4, 'EXTENDS; no merge - exits'),
|
||||||
|
array(false, true, 5, 5, 5, 'no EXTENDS; merge - new'),
|
||||||
|
array(false, true, 6, 5, 6, 'no EXTENDS; merge - exits'),
|
||||||
|
array(true, true, 7, 7, 7, 'EXTENDS; merge - new'),
|
||||||
|
array(true, true, 8, 7, 8, 'EXTENDS; merge - exits'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,3 @@
|
|||||||
|
{block 'grandchild'}grandchild - child{/block}
|
||||||
|
{block 'child'}child - child{/block}
|
||||||
|
|
@@ -0,0 +1,3 @@
|
|||||||
|
{extends '034_child.tpl'}
|
||||||
|
{block 'grandchild'}grandchild - grandchild{/block}
|
||||||
|
|
@@ -0,0 +1,4 @@
|
|||||||
|
test:{$test nocache} compiled:# rendered:{$test}
|
||||||
|
{block 'grandchild'}grandchild - parent{/block}
|
||||||
|
{block 'child'}child - parent{/block}
|
||||||
|
{block 'parent'}parent - parent{/block}
|
Reference in New Issue
Block a user