From e9e473da65cb297fa0c09ee323a0c1402c1710cb Mon Sep 17 00:00:00 2001 From: uwetews Date: Fri, 18 Dec 2015 03:58:53 +0100 Subject: [PATCH] add test for chained prepend --- .../BockExtend/CompileBlockExtendsTest.php | 23 +++++++++++++++++-- .../templates/013_2_child_prepend.tpl | 2 ++ .../templates/013_2_grandchild_prepend.tpl | 2 ++ .../BockExtend/templates/013_child.tpl | 2 +- .../BockExtend/templates/013_parent.tpl | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_2_child_prepend.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_2_grandchild_prepend.tpl diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php index 8b53418f..dd8d2e48 100644 --- a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php @@ -292,7 +292,26 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty $this->smarty->compile_id = 1; } $result = $this->smarty->fetch('013_grandchild_prepend.tpl'); - $this->assertContains('grandchild prepend - Page Title', $result, $testName . ' - content'); + $this->assertContains('grandchild prepend - child', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $testName . ' - fetch() failure'); + } + /** + * test grandchild/child/parent template chain prepend + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockGrandChildPrepend_013_2($caching, $merge, $testNumber, $compileTestNumber, $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->caching = $caching; + $this->smarty->merge_compiled_includes = $merge; + if ($merge) { + $this->smarty->compile_id = 1; + } + $result = $this->smarty->fetch('013_2_grandchild_prepend.tpl'); + $this->assertContains('grandchild prepend - child prepend - parent', $result, $testName . ' - content'); $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $testName . ' - fetch() failure'); } @@ -446,7 +465,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty /** * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} - * @runInSeparateProcess + * @run InSeparateProcess * @preserveGlobalState disabled * @dataProvider data */ diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_2_child_prepend.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_2_child_prepend.tpl new file mode 100644 index 00000000..636035aa --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_2_child_prepend.tpl @@ -0,0 +1,2 @@ +{extends file='013_parent.tpl'} +{block name='title' prepend}child prepend - {/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_2_grandchild_prepend.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_2_grandchild_prepend.tpl new file mode 100644 index 00000000..a960f0da --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_2_grandchild_prepend.tpl @@ -0,0 +1,2 @@ +{extends file='013_2_child_prepend.tpl'} +{block name='title' prepend}grandchild prepend - {/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_child.tpl index c90c1024..6abee6d3 100644 --- a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_child.tpl +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_child.tpl @@ -1,2 +1,2 @@ {extends file='013_parent.tpl'} -{block name='title'}Page Title{/block} +{block name='title'}child{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_parent.tpl index afcf7d7c..bf4de3ab 100644 --- a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_parent.tpl +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/013_parent.tpl @@ -1,2 +1,2 @@ test:{$test nocache} compiled:# rendered:{$test} -{block name='title'}Default Title{/block} +{block name='title'}parent{/block}