Add test for Smarty::$extends_recursion property

This commit is contained in:
uwetews
2016-09-29 03:44:49 +02:00
parent e1ad0ece66
commit 48a954e2e5
4 changed files with 65 additions and 1 deletions

View File

@@ -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'),
);
}
} }

View File

@@ -0,0 +1,3 @@
{block 'grandchild'}grandchild - child{/block}
{block 'child'}child - child{/block}

View File

@@ -0,0 +1,3 @@
{extends '034_child.tpl'}
{block 'grandchild'}grandchild - grandchild{/block}

View File

@@ -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}