From bfca72e71b9ea8b64be825a0c96db8c33df1677d Mon Sep 17 00:00:00 2001 From: uwetews Date: Tue, 12 Jul 2016 23:01:29 +0200 Subject: [PATCH] update compiler plugin test --- .../CompileCompilerPluginTest.php | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php b/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php index 589aa29c..d83197c0 100644 --- a/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php +++ b/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php @@ -28,11 +28,30 @@ class CompileCompilerPluginTest extends PHPUnit_Smarty /** * test compiler plugin tag in template file */ - public function testCompilerPlugin() + public function testCompilerPluginFunction() { $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'compilerplugin', 'mycompilerplugin'); - $tpl = $this->smarty->createTemplate('compilerplugintest.tpl'); - $this->assertEquals("Hello World", $this->smarty->fetch($tpl)); + $this->smarty->compile_id = 'function'; + $this->assertEquals("Hello World", $this->smarty->fetch('compilerplugintest.tpl')); + } + /** + * test compiler plugin tag in template file + */ + public function testCompilerPluginClassStatic() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'compilerplugin', array('CompilerPluginClass', 'statCompile')); + $this->smarty->compile_id = 'static'; + $this->assertEquals("Static World", $this->smarty->fetch('compilerplugintest.tpl')); + } + /** + * test compiler plugin tag in template file + */ + public function testCompilerPluginClassObject() + { + $plugin = new CompilerPluginClass; + $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'compilerplugin', array($plugin, 'compile')); + $this->smarty->compile_id = 'object'; + $this->assertEquals("Public World", $this->smarty->fetch('compilerplugintest.tpl')); } } @@ -40,3 +59,13 @@ function mycompilerplugin($params, $compiler) { return ''; } + +class CompilerPluginClass +{ + static function statCompile ($params, $compiler) { + return ''; + } + public function compile ($params, $compiler) { + return ''; + } +} \ No newline at end of file