diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php index 050037df..5bf78b95 100644 --- a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php @@ -752,7 +752,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty /** * @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] */ public function testSmartyBlockChildOutsideBlock_025() @@ -762,7 +762,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty /** * @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] */ public function testSmartyBlockParentOutsideBlock_026() @@ -772,7 +772,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty /** * @expectedException SmartyException - * @expectedExceptionMessage illegal {$smarty.block.parent} + * @expectedExceptionMessage illegal '$smarty.block.parent' * test {$this->smarty.block.parent} in parent template */ public function testSmartyBlockParentInParent_027() @@ -858,7 +858,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty * @dataProvider data */ public function testCompileBlockGrandChildNestedRelative_030($caching, $merge, $testNumber, $compileTestNumber, - $renderTestNumber, $testName) + $renderTestNumber, $testName) { $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); $this->smarty->assign('test', $testNumber); @@ -873,6 +873,54 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $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() { @@ -945,5 +993,28 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $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'); + } } diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_child.tpl new file mode 100644 index 00000000..ebbb9b6d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_child.tpl @@ -0,0 +1,2 @@ +{extends '034_parent.tpl'} +{block 'b1'}{$foo=$smarty.block.parent}{$foo}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_parent.tpl new file mode 100644 index 00000000..1f3bc7f5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block 'b1'}parent b1{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_child.tpl new file mode 100644 index 00000000..494b114f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_child.tpl @@ -0,0 +1,2 @@ +{extends file='035_parent.tpl'} +{block name='b'}(child|b)content {$child} b(child|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_parent.tpl new file mode 100644 index 00000000..856269bb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_parent.tpl @@ -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} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_parent.tpl new file mode 100644 index 00000000..8e3ed9da --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{$smarty.block.foo}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/037_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/037_parent.tpl new file mode 100644 index 00000000..96a2a583 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/037_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{$smarty.block}{/block} \ No newline at end of file