This commit is contained in:
Uwe Tews
2017-10-12 08:11:30 +02:00
parent df97b8a14d
commit f41afe355f
7 changed files with 85 additions and 4 deletions

View File

@@ -752,7 +752,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
/** /**
* @expectedException SmartyCompilerException * @expectedException SmartyCompilerException
* @expectedExceptionMessage tag {$smarty.block.child} used outside {block} tags * @expectedExceptionMessage "$smarty.block.child" used outside {block} tags
* test {$this->smarty.block.child} outside {block] * test {$this->smarty.block.child} outside {block]
*/ */
public function testSmartyBlockChildOutsideBlock_025() public function testSmartyBlockChildOutsideBlock_025()
@@ -762,7 +762,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
/** /**
* @expectedException SmartyCompilerException * @expectedException SmartyCompilerException
* @expectedExceptionMessage tag {$smarty.block.parent} used outside {block} tags * @expectedExceptionMessage "$smarty.block.parent" used outside {block} tags
* test {$this->smarty.block.parent} outside {block] * test {$this->smarty.block.parent} outside {block]
*/ */
public function testSmartyBlockParentOutsideBlock_026() public function testSmartyBlockParentOutsideBlock_026()
@@ -772,7 +772,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
/** /**
* @expectedException SmartyException * @expectedException SmartyException
* @expectedExceptionMessage illegal {$smarty.block.parent} * @expectedExceptionMessage illegal '$smarty.block.parent'
* test {$this->smarty.block.parent} in parent template * test {$this->smarty.block.parent} in parent template
*/ */
public function testSmartyBlockParentInParent_027() public function testSmartyBlockParentInParent_027()
@@ -873,6 +873,54 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
/**
* test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache}
*
* @runInSeparateProcess
* @preserveGlobalState disabled
* @dataProvider data
*/
public function testCompileBlockSmartyBlockParent_034($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('034_child.tpl');
$this->assertContains('parent b1', $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure');
}
/**
* test child/parent template chain with {$this->smarty.block.child)
*
* @runInSeparateProcess
* @preserveGlobalState disabled
* @dataProvider data
*/
public function testCompileBlockSmartyBlockChild_035($caching, $merge, $testNumber, $compileTestNumber,
$renderTestNumber, $testName)
{
$this->smarty->registerFilter('pre', array($this, 'compiledPrefilter'));
$this->smarty->assign('test', $testNumber);
$this->smarty->assign('parent', 'parent', true);
$this->smarty->assign('child', 'child', true);
$this->smarty->setCaching($caching);
$this->smarty->setMergeCompiledIncludes($merge);
if ($merge) {
$this->smarty->setCompileId(1);
}
$result = $this->smarty->fetch('035_child.tpl');
$this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result,
$testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure');
}
public function data() public function data()
{ {
@@ -945,5 +993,28 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
/**
*
* test smarty.block.foo
*
* @expectedException SmartyCompilerException
* @expectedExceptionMessage invalid "$smarty.block.foo" expected "$smarty.block.child" or "$smarty.block.parent"
*/
public function testSmartyBlockWrongBlockName_036()
{
$this->smarty->fetch('036_parent.tpl');
}
/**
*
* test smarty.block
*
* @expectedException SmartyCompilerException
* @expectedExceptionMessage invalid "$smarty.block" expected "$smarty.block.child" or "$smarty.block.parent"
*/
public function testSmartyBlockMissigBlockName_037()
{
$this->smarty->fetch('037_parent.tpl');
}
} }

View File

@@ -0,0 +1,2 @@
{extends '034_parent.tpl'}
{block 'b1'}{$foo=$smarty.block.parent}{$foo}{/block}

View File

@@ -0,0 +1,2 @@
test:{$test nocache} compiled:# rendered:{$test}
{block 'b1'}parent b1{/block}

View File

@@ -0,0 +1,2 @@
{extends file='035_parent.tpl'}
{block name='b'}(child|b)content {$child} b(child|/b){/block}

View File

@@ -0,0 +1,2 @@
test:{$test nocache} compiled:# rendered:{$test}
{block name='b'}(parent|b)content {$foo=$smarty.block.child}{$foo} b(parent|/b){/block}

View File

@@ -0,0 +1 @@
{block name='b'}{$smarty.block.foo}{/block}

View File

@@ -0,0 +1 @@
{block name='b'}{$smarty.block}{/block}