From cd1d7c4d6ae83e0e69c27cb3b86ddc786c0eecb8 Mon Sep 17 00:00:00 2001 From: uwetews Date: Mon, 21 Dec 2015 02:13:46 +0100 Subject: [PATCH] add test where extendsall is default resource --- .../ResourceExtendsAllPluginTest.php | 125 +++++++++++++++--- .../templates/extendsall.tpl | 1 + .../templates/extendsall2.tpl | 1 + .../templates_1/data1.tpl | 4 + .../templates_1/data2.tpl | 4 + .../templates_1/data3.tpl | 4 + .../templates_1/template.tpl | 5 + .../templates_2/data1.tpl | 4 + .../templates_3/data1.tpl | 4 + .../templates_3/extendsall.tpl | 1 + .../templates_4/extendsall.tpl | 1 + 11 files changed, 136 insertions(+), 18 deletions(-) create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data1.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data2.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data3.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/template.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_2/data1.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_3/data1.tpl diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php index 7b22365e..ea3d9e49 100644 --- a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php @@ -1,13 +1,13 @@ setUpSmarty(__DIR__); - } - + } public function testInit() { $this->cleanDirs(); } + /** + * test extendsall + * @runInSeparateProcess + * @preserveGlobalState disabled + */ public function testResourcePluginExtendsall() { $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); - $this->smarty->setTemplateDir(array( - 'root' => './templates', - './templates_2', - './templates_3', - './templates_4', - )); + $this->smarty->setTemplateDir(array('root' => './templates', './templates_2', './templates_3', + './templates_4',)); - $expected = "templates\n\n templates_3\n templates\n\ntemplates_4"; + $expected = "templatestemplates_3templatestemplates_4"; + $this->assertEquals($expected, $this->smarty->fetch('extendsall:extendsall.tpl')); + } + + /** + * test extendsall + * changed tepmplate_setting + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + + public function testResourcePluginExtendsall2() + { + $this->smarty->setMergeCompiledIncludes(true); + $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); + $this->smarty->setTemplateDir(array('./templates_3', './templates_4',)); + + $expected = "templates_3templates_3templates_3templates_4"; $this->assertEquals($expected, $this->smarty->fetch('extendsall:extendsall.tpl')); } public function testResourcePluginExtendsallOne() { $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); - $this->smarty->setTemplateDir(array( - 'root' => './templates', - './templates_2', - './templates_3', - './templates_4', - )); + $this->smarty->setTemplateDir(array('root' => './templates', './templates_2', './templates_3', + './templates_4',)); - $expected = "templates\ntemplates"; + $expected = "templatestemplates"; $this->assertEquals($expected, $this->smarty->fetch('extendsall:extendsall2.tpl')); } + /** + * test extendsall special application + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testResourcePluginExtendsallSpecialApplication() + { + $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); + $this->smarty->setTemplateDir(array('./templates_2', './templates_1',)); + $this->smarty->setDefaultResourceType('extendsall'); + $this->assertEquals('

data1 from templates1

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + } + /** + * test extendsall special application + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testResourcePluginExtendsallSpecialApplication2() + { + $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); + $this->smarty->setTemplateDir(array('./templates_3','./templates_2', './templates_1',)); + $this->smarty->setDefaultResourceType('extendsall'); + $this->assertEquals('

data1 from templates3

data1 from templates1

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + } + /** + * test extendsall special application + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testResourcePluginExtendsallSpecialApplication3() + { + $this->smarty->setMergeCompiledIncludes(true); + $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); + $this->smarty->setTemplateDir(array('./templates_2', './templates_1',)); + $this->smarty->setDefaultResourceType('extendsall'); + $this->assertEquals('

data1 from templates1

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + } + /** + * test extendsall special application + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testResourcePluginExtendsallSpecialApplication4() + { + $this->smarty->setMergeCompiledIncludes(true); + $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); + $this->smarty->setTemplateDir(array('./templates_2', './templates_1',)); + $this->smarty->setDefaultResourceType('extendsall'); + $this->assertEquals('

data1 from templates1

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + } + /** + * test extendsall special application + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testResourcePluginExtendsallSpecialApplication5() + { + $this->smarty->setMergeCompiledIncludes(true); + $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); + $this->smarty->setTemplateDir(array('./templates_3','./templates_2', './templates_1',)); + $this->smarty->setDefaultResourceType('extendsall'); + $this->assertEquals('

data1 from templates3

data1 from templates1

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + } + /** + * test extendsall special application + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testResourcePluginExtendsallSpecialApplication6() + { + $this->smarty->setMergeCompiledIncludes(true); + $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); + $this->smarty->setTemplateDir(array('./templates_3','./templates_2', './templates_1',)); + $this->smarty->setDefaultResourceType('extendsall'); + $this->assertEquals('

data1 from templates3

data1 from templates1

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + } } diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall.tpl index 988c37e0..ab061b43 100644 --- a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall.tpl +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall.tpl @@ -1,2 +1,3 @@ +{strip} {block name="alpha"}templates{/block} {block name="bravo_2"}templates{/block} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall2.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall2.tpl index 988c37e0..ab061b43 100644 --- a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall2.tpl +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall2.tpl @@ -1,2 +1,3 @@ +{strip} {block name="alpha"}templates{/block} {block name="bravo_2"}templates{/block} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data1.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data1.tpl new file mode 100644 index 00000000..3771cbdc --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data1.tpl @@ -0,0 +1,4 @@ +{strip} +{block name="content-data1"} +

data1 from templates1

+{/block} diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data2.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data2.tpl new file mode 100644 index 00000000..af2235b0 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data2.tpl @@ -0,0 +1,4 @@ +{strip} +{block name="content-data2"} +

data2 from templates1

+{/block} diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data3.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data3.tpl new file mode 100644 index 00000000..3771cbdc --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/data3.tpl @@ -0,0 +1,4 @@ +{strip} +{block name="content-data1"} +

data1 from templates1

+{/block} diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/template.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/template.tpl new file mode 100644 index 00000000..c772aff5 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_1/template.tpl @@ -0,0 +1,5 @@ +{strip} +{block name="content"} +{include file="data1.tpl"} +{include file="data2.tpl"} +{/block} diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_2/data1.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_2/data1.tpl new file mode 100644 index 00000000..f210130e --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_2/data1.tpl @@ -0,0 +1,4 @@ +{strip} +{block name="content-data1" append} +

data1 from templates2

+{/block} diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_3/data1.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_3/data1.tpl new file mode 100644 index 00000000..919f1929 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_3/data1.tpl @@ -0,0 +1,4 @@ +{strip} +{block name="content-data1" prepend} +

data1 from templates3

+{/block} diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_3/extendsall.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_3/extendsall.tpl index 0b79019d..ee9e030a 100644 --- a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_3/extendsall.tpl +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_3/extendsall.tpl @@ -1,3 +1,4 @@ +{strip} {block name="alpha"}templates_3{/block} {block name="bravo"} {block name="bravo_1"}templates_3{/block} diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_4/extendsall.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_4/extendsall.tpl index 93557dca..c2d7cade 100644 --- a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_4/extendsall.tpl +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_4/extendsall.tpl @@ -1,3 +1,4 @@ +{strip} {block name="alpha"}templates_4{/block} {block name="bravo"}templates_4{/block} {block name="charlie"}templates_4{/block} \ No newline at end of file