From 585850230c22939951d84c4da535cdada76e2802 Mon Sep 17 00:00:00 2001 From: uwetews Date: Sat, 2 Jan 2016 04:56:22 +0100 Subject: [PATCH] update block plugin tests --- .../BlockPlugin/CompileBlockPluginTest.php | 74 ++++--------------- .../PHPunitplugins/block.nooutput.php | 24 ++++++ .../PHPunitplugins/block.testblock.php | 7 +- .../TagTests/BlockPlugin/cache/dummy.txt | 0 .../TagTests/BlockPlugin/templates/assign.tpl | 1 + .../BlockPlugin/templates/blockplugintest.tpl | 1 - .../BlockPlugin/templates/no_assign.tpl | 1 + .../BlockPlugin/templates/nooutput.tpl | 1 + .../BlockPlugin/templates/registered.tpl | 1 + .../TagTests/BlockPlugin/templates/repeat.tpl | 1 + .../BlockPlugin/templates/repeat_modifier.tpl | 1 + .../templates/repeat_modifier_2.tpl | 1 + 12 files changed, 50 insertions(+), 63 deletions(-) create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.nooutput.php delete mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/cache/dummy.txt create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/assign.tpl delete mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/blockplugintest.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/no_assign.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/nooutput.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier_2.tpl diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php index 726e4a0c..a0598631 100644 --- a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php @@ -19,7 +19,6 @@ class CompileBlockPluginTest extends PHPUnit_Smarty { $this->setUpSmarty(dirname(__FILE__)); $this->smarty->addPluginsDir("./PHPunitplugins/"); - $this->smarty->setForceCompile(true); $this->smarty->disableSecurity(); } @@ -34,8 +33,7 @@ class CompileBlockPluginTest extends PHPUnit_Smarty */ public function testBlockPluginNoAssign() { - $tpl = $this->smarty->createTemplate("eval:{textformat}hello world{/textformat}"); - $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + $this->assertEquals("hello world", $this->smarty->fetch('no_assign.tpl')); } /** @@ -44,51 +42,7 @@ class CompileBlockPluginTest extends PHPUnit_Smarty */ public function testBlockPluginAssign() { - $tpl = $this->smarty->createTemplate("eval:{textformat assign=foo}hello world{/textformat}{\$foo}"); - $this->assertEquals("hello world", $this->smarty->fetch($tpl)); - } - - /** - * test block plugin tag in template file - * - * @runInSeparateProcess - * @preserveGlobalState disabled - * - */ - public function testBlockPluginFromTemplateFile() - { - $tpl = $this->smarty->createTemplate('blockplugintest.tpl'); - $this->assertEquals("abc", $this->smarty->fetch($tpl)); - } - - /** - * test block plugin tag in compiled template file - * - * @runInSeparateProcess - * @preserveGlobalState disabled - * - */ - public function testBlockPluginFromCompiledTemplateFile() - { - $this->smarty->setForceCompile(false); - $tpl = $this->smarty->createTemplate('blockplugintest.tpl'); - $this->assertEquals("abc", $this->smarty->fetch($tpl)); - } - - /** - * test block plugin tag in template file - * - * @runInSeparateProcess - * @preserveGlobalState disabled - * - */ - public function testBlockPluginFromTemplateFileCache() - { - $this->smarty->setForceCompile(false); - $this->smarty->caching = 1; - $this->smarty->cache_lifetime = 10; - $tpl = $this->smarty->createTemplate('blockplugintest.tpl'); - $this->assertEquals("abc", $this->smarty->fetch($tpl)); + $this->assertEquals("hello world", $this->smarty->fetch('assign.tpl')); } /** @@ -101,8 +55,7 @@ class CompileBlockPluginTest extends PHPUnit_Smarty public function testBlockPluginRegisteredFunction() { $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'blockplugintest', 'myblockplugintest'); - $tpl = $this->smarty->createTemplate('eval:{blockplugintest}hello world{/blockplugintest}'); - $this->assertEquals('block test', $this->smarty->fetch($tpl)); + $this->assertEquals('block test', $this->smarty->fetch('registered.tpl')); } /** @@ -111,28 +64,33 @@ class CompileBlockPluginTest extends PHPUnit_Smarty */ public function testBlockPluginRepeat() { - $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); - $this->assertEquals('12345', $this->smarty->fetch('eval:{testblock}{/testblock}')); + $this->assertEquals('12345', $this->smarty->fetch('repeat.tpl')); } /** - * + * test block plugin repeat function with modifier * */ public function testBlockPluginRepeatModidier1() { - $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); - $this->assertEquals('11111', $this->smarty->fetch('eval:{testblock}{/testblock|strlen}')); + $this->assertEquals('11111', $this->smarty->fetch('repeat_modifier.tpl')); } /** - * + * test block plugin repeat function with modifier list * */ public function testBlockPluginRepeatModidier2() { - $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); - $this->assertEquals('11111', $this->smarty->fetch('eval:{testblock}{/testblock|strlen|default:""}')); + $this->assertEquals('11111', $this->smarty->fetch('repeat_modifier_2.tpl')); + } + /** + * test block plugin with no output + * + */ + public function testBlockPluginNoOutput() + { + $this->assertEquals('default', $this->smarty->fetch('nooutput.tpl')); } } diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.nooutput.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.nooutput.php new file mode 100644 index 00000000..398c9a3b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.nooutput.php @@ -0,0 +1,24 @@ +