mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
Update inheritance tests
This commit is contained in:
@@ -222,6 +222,31 @@ class ExtendsResourceTest extends PHPUnit_Smarty
|
||||
$this->assertContains('Grandchild Page Title', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test relative includes in {block}
|
||||
*
|
||||
* @run InSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider data
|
||||
*/
|
||||
public function testCompileBlockRelativeIncludes_033($caching, $merge, $testNumber, $compileTestNumber,
|
||||
$renderTestNumber, $testName)
|
||||
{
|
||||
$this->smarty->registerFilter('pre', array($this, 'compiledPrefilter'));
|
||||
$this->smarty->assign('test', $testNumber);
|
||||
$this->smarty->setCaching($caching);
|
||||
$this->smarty->setMergeCompiledIncludes($merge);
|
||||
if ($merge) {
|
||||
$this->smarty->setCompileId(1);
|
||||
}
|
||||
$result = $this->smarty->fetch('extends:./child/parent/033_parent.tpl|./child/033_child.tpl|033_grandchild.tpl');
|
||||
$this->assertContains('include grand:content include grand', $result, $testName . ' - grand');
|
||||
$this->assertContains('include child:content include child', $result, $testName . ' - grand');
|
||||
$this->assertContains('include parent:content include parent', $result, $testName . ' - grand');
|
||||
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
|
||||
$testName . ' - fetch() failure');
|
||||
}
|
||||
|
||||
public function data(){
|
||||
return array(
|
||||
/*
|
||||
|
@@ -0,0 +1 @@
|
||||
{block 'grand'}{include './include/include.tpl'}{/block}
|
@@ -0,0 +1 @@
|
||||
{block 'child'}{include './include/include.tpl'}{/block}
|
@@ -0,0 +1 @@
|
||||
include child:{include './include/include.tpl'}
|
@@ -0,0 +1 @@
|
||||
content include child
|
@@ -0,0 +1,4 @@
|
||||
test:{$test nocache} compiled:# rendered:{$test}
|
||||
{block 'grand'}{include './include/include.tpl'}{/block}
|
||||
{block 'child'}{include './include/include.tpl'}{/block}
|
||||
{block 'parent'}{include './include/include.tpl'}{/block}
|
@@ -0,0 +1 @@
|
||||
include parent:{include './include/include.tpl'}
|
@@ -0,0 +1 @@
|
||||
content include parent
|
@@ -0,0 +1 @@
|
||||
include grand:{include './include/include.tpl'}
|
@@ -0,0 +1 @@
|
||||
content include grand
|
@@ -921,4 +921,29 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
||||
$this->assertNotContains('bar in 032_included_parent.tpl', $result);
|
||||
$this->assertNotContains('foo in 032_parent.tpl', $result);
|
||||
}
|
||||
/**
|
||||
* test relative includes in {block}
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider data
|
||||
*/
|
||||
public function testCompileBlockRelativeIncludes_033($caching, $merge, $testNumber, $compileTestNumber,
|
||||
$renderTestNumber, $testName)
|
||||
{
|
||||
$this->smarty->registerFilter('pre', array($this, 'compiledPrefilter'));
|
||||
$this->smarty->assign('test', $testNumber);
|
||||
$this->smarty->setCaching($caching);
|
||||
$this->smarty->setMergeCompiledIncludes($merge);
|
||||
if ($merge) {
|
||||
$this->smarty->setCompileId(1);
|
||||
}
|
||||
$result = $this->smarty->fetch('033_grandchild.tpl');
|
||||
$this->assertContains('include grand:content include grand', $result, $testName . ' - grand');
|
||||
$this->assertContains('include child:content include child', $result, $testName . ' - grand');
|
||||
$this->assertContains('include parent:content include parent', $result, $testName . ' - grand');
|
||||
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
|
||||
$testName . ' - fetch() failure');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,2 @@
|
||||
{extends "./child/033_child.tpl"}
|
||||
{block 'grand'}{include './include/include.tpl'}{/block}
|
@@ -0,0 +1,2 @@
|
||||
{extends "./parent/033_parent.tpl"}
|
||||
{block 'child'}{include './include/include.tpl'}{/block}
|
@@ -0,0 +1 @@
|
||||
include child:{include './include/include.tpl'}
|
@@ -0,0 +1 @@
|
||||
content include child
|
@@ -0,0 +1,4 @@
|
||||
test:{$test nocache} compiled:# rendered:{$test}
|
||||
{block 'grand'}{include './include/include.tpl'}{/block}
|
||||
{block 'child'}{include './include/include.tpl'}{/block}
|
||||
{block 'parent'}{include './include/include.tpl'}{/block}
|
@@ -0,0 +1 @@
|
||||
include parent:{include './include/include.tpl'}
|
@@ -0,0 +1 @@
|
||||
content include parent
|
@@ -0,0 +1 @@
|
||||
include grand:{include './include/include.tpl'}
|
@@ -0,0 +1 @@
|
||||
content include grand
|
Reference in New Issue
Block a user