From 8a8c0cd08133d36288aa5dcdaeb1c84009b7df53 Mon Sep 17 00:00:00 2001 From: uwetews Date: Sun, 1 May 2016 23:49:04 +0200 Subject: [PATCH] Update inheritance tests --- .../Extends/ExtendsResourceTest.php | 25 +++++++++++++++++++ .../Extends/templates/033_grandchild.tpl | 1 + .../Extends/templates/child/033_child.tpl | 1 + .../templates/child/include/include.tpl | 1 + .../child/include/include/include.tpl | 1 + .../templates/child/parent/033_parent.tpl | 4 +++ .../child/parent/include/include.tpl | 1 + .../child/parent/include/include/include.tpl | 1 + .../Extends/templates/include/include.tpl | 1 + .../templates/include/include/include.tpl | 1 + .../BockExtend/CompileBlockExtendsTest.php | 25 +++++++++++++++++++ .../BockExtend/templates/033_grandchild.tpl | 2 ++ .../BockExtend/templates/child/033_child.tpl | 2 ++ .../templates/child/include/include.tpl | 1 + .../child/include/include/include.tpl | 1 + .../templates/child/parent/033_parent.tpl | 4 +++ .../child/parent/include/include.tpl | 1 + .../child/parent/include/include/include.tpl | 1 + .../BockExtend/templates/include/include.tpl | 1 + .../templates/include/include/include.tpl | 1 + 20 files changed, 76 insertions(+) create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/033_grandchild.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/child/033_child.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/child/include/include.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/child/include/include/include.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/child/parent/033_parent.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/child/parent/include/include.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/child/parent/include/include/include.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/include/include.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/include/include/include.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/033_grandchild.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/033_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include/include.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/033_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include/include.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include/include.tpl diff --git a/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php b/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php index 2be211b8..dd6f548f 100644 --- a/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php +++ b/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php @@ -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( /* diff --git a/tests/UnitTests/ResourceTests/Extends/templates/033_grandchild.tpl b/tests/UnitTests/ResourceTests/Extends/templates/033_grandchild.tpl new file mode 100644 index 00000000..e536554b --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/033_grandchild.tpl @@ -0,0 +1 @@ +{block 'grand'}{include './include/include.tpl'}{/block} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/child/033_child.tpl b/tests/UnitTests/ResourceTests/Extends/templates/child/033_child.tpl new file mode 100644 index 00000000..d7001535 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/child/033_child.tpl @@ -0,0 +1 @@ +{block 'child'}{include './include/include.tpl'}{/block} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/child/include/include.tpl b/tests/UnitTests/ResourceTests/Extends/templates/child/include/include.tpl new file mode 100644 index 00000000..3360d880 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/child/include/include.tpl @@ -0,0 +1 @@ +include child:{include './include/include.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Extends/templates/child/include/include/include.tpl b/tests/UnitTests/ResourceTests/Extends/templates/child/include/include/include.tpl new file mode 100644 index 00000000..021312d2 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/child/include/include/include.tpl @@ -0,0 +1 @@ +content include child \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Extends/templates/child/parent/033_parent.tpl b/tests/UnitTests/ResourceTests/Extends/templates/child/parent/033_parent.tpl new file mode 100644 index 00000000..cbb08821 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/child/parent/033_parent.tpl @@ -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} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/child/parent/include/include.tpl b/tests/UnitTests/ResourceTests/Extends/templates/child/parent/include/include.tpl new file mode 100644 index 00000000..25e7b985 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/child/parent/include/include.tpl @@ -0,0 +1 @@ +include parent:{include './include/include.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Extends/templates/child/parent/include/include/include.tpl b/tests/UnitTests/ResourceTests/Extends/templates/child/parent/include/include/include.tpl new file mode 100644 index 00000000..3ed97ea1 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/child/parent/include/include/include.tpl @@ -0,0 +1 @@ +content include parent \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Extends/templates/include/include.tpl b/tests/UnitTests/ResourceTests/Extends/templates/include/include.tpl new file mode 100644 index 00000000..1d72045b --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/include/include.tpl @@ -0,0 +1 @@ +include grand:{include './include/include.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Extends/templates/include/include/include.tpl b/tests/UnitTests/ResourceTests/Extends/templates/include/include/include.tpl new file mode 100644 index 00000000..e560a2ad --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/include/include/include.tpl @@ -0,0 +1 @@ +content include grand \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php index 903751e6..050037df 100644 --- a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php @@ -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'); + } + } diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/033_grandchild.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/033_grandchild.tpl new file mode 100644 index 00000000..88d9ec73 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/033_grandchild.tpl @@ -0,0 +1,2 @@ +{extends "./child/033_child.tpl"} +{block 'grand'}{include './include/include.tpl'}{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/033_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/033_child.tpl new file mode 100644 index 00000000..6ed3943f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/033_child.tpl @@ -0,0 +1,2 @@ +{extends "./parent/033_parent.tpl"} +{block 'child'}{include './include/include.tpl'}{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include.tpl new file mode 100644 index 00000000..3360d880 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include.tpl @@ -0,0 +1 @@ +include child:{include './include/include.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include/include.tpl new file mode 100644 index 00000000..021312d2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include/include.tpl @@ -0,0 +1 @@ +content include child \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/033_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/033_parent.tpl new file mode 100644 index 00000000..cbb08821 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/033_parent.tpl @@ -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} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include.tpl new file mode 100644 index 00000000..25e7b985 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include.tpl @@ -0,0 +1 @@ +include parent:{include './include/include.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include/include.tpl new file mode 100644 index 00000000..3ed97ea1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include/include.tpl @@ -0,0 +1 @@ +content include parent \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include.tpl new file mode 100644 index 00000000..1d72045b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include.tpl @@ -0,0 +1 @@ +include grand:{include './include/include.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include/include.tpl new file mode 100644 index 00000000..e560a2ad --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include/include.tpl @@ -0,0 +1 @@ +content include grand \ No newline at end of file