From 5c416f2f0faa355011b6a4258eb91099dd4e5056 Mon Sep 17 00:00:00 2001 From: uwetews Date: Sun, 23 Aug 2015 15:04:21 +0200 Subject: [PATCH] Update for 3.1.28 --- .../Plugins/include/function.plugin1.php | 5 ++ .../Plugins/include1/function.plugin2.php | 5 ++ tests/PHPUnit_Smarty.php | 46 +----------- .../AutoEscape/AutoEscapeTest.php | 0 .../{_Core => A_Core}/Filter/FilterTest.php | 0 .../Filter/LoadFilterTest.php | 0 .../Filter/RegisterFilterTest.php | 0 .../GetterSetter/GetterSetterTest.php | 0 .../LoadPlugin/DefaultPluginHandlerTest.php | 0 .../A_Core/LoadPlugin/IncludePathTest.php | 49 ++++++++++++ .../LoadPlugin/LoadPluginTest.php | 0 .../LoadPlugin/include/function.plugin3.php | 5 ++ .../LoadPlugin/scripts/script_block_tag.php | 0 .../scripts/script_compiler_function_tag.php | 0 .../script_default_static_modifier.php | 0 .../scripts/script_function_tag.php | 0 .../LoadPlugin/scripts/script_modifier.php | 0 .../LoadPlugin/scripts/test_include_php.php | 0 .../templates/test_default_block_script.tpl | 0 .../test_default_compiler_function_script.tpl | 0 .../templates/test_default_function_local.tpl | 0 .../test_default_function_script.tpl | 0 ...st_default_function_script_notcachable.tpl | 0 .../templates/test_default_modifier.tpl | 0 .../test_default_modifier_script.tpl | 0 .../test_default_static_modifier.tpl | 0 .../templates/test_include_path1.tpl | 1 + .../templates/test_include_path2.tpl | 1 + .../templates/test_include_path3.tpl | 1 + .../MuteExpectedErrorsTest.php | 0 .../MuteExpectedErrors/templates/default.tpl | 0 .../OutputFilterTrimWhitespaceTest.php | 0 .../PHPunitplugins/function.chain1.php | 0 .../PHPunitplugins/function.chain2.php | 0 .../PHPunitplugins/function.chain3.php | 0 .../PluginTests/PluginChainedLoadTest.php | 0 .../Shared/SharedFunctionsTest.php | 0 .../PluginTests/helpers/_object_tostring.php | 0 .../templates/test_plugin_chained_load.tpl | 0 .../PluginTests/templates/whitespace.tpl | 0 .../SmartyBC/SmartyBcTest.php | 0 .../_shared/CacheResourceTestCommon.php | 4 +- .../ResourceMysqlPluginTest.php | 4 +- .../ResourceTests/Eval/EvalResourceTest.php | 4 +- .../Extends/ExtendsResourceTest.php | 8 +- .../ResourceTests/File/FileResourceTest.php | 4 +- .../ResourceTests/Php/PhpResourceTest.php | 4 +- .../Stream/StreamResourceTest.php | 4 +- .../String/StringResourceTest.php | 4 +- .../ClearCompiledTest.php | 2 +- .../BockExtend/CompileBlockExtendsTest.php | 13 ++-- .../TemplateFunction/CompileFunctionTest.php | 74 ++++++++++--------- 52 files changed, 135 insertions(+), 103 deletions(-) create mode 100644 tests/Include_Path/Plugins/include/function.plugin1.php create mode 100644 tests/Include_Path/Plugins/include1/function.plugin2.php rename tests/UnitTests/{_Core => A_Core}/AutoEscape/AutoEscapeTest.php (100%) rename tests/UnitTests/{_Core => A_Core}/Filter/FilterTest.php (100%) rename tests/UnitTests/{_Core => A_Core}/Filter/LoadFilterTest.php (100%) rename tests/UnitTests/{_Core => A_Core}/Filter/RegisterFilterTest.php (100%) rename tests/UnitTests/{_Core => A_Core}/GetterSetter/GetterSetterTest.php (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/DefaultPluginHandlerTest.php (100%) create mode 100644 tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/LoadPluginTest.php (100%) create mode 100644 tests/UnitTests/A_Core/LoadPlugin/include/function.plugin3.php rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/scripts/script_block_tag.php (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/scripts/script_compiler_function_tag.php (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/scripts/script_default_static_modifier.php (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/scripts/script_function_tag.php (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/scripts/script_modifier.php (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/scripts/test_include_php.php (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/templates/test_default_block_script.tpl (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/templates/test_default_compiler_function_script.tpl (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/templates/test_default_function_local.tpl (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/templates/test_default_function_script.tpl (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/templates/test_default_function_script_notcachable.tpl (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/templates/test_default_modifier.tpl (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/templates/test_default_modifier_script.tpl (100%) rename tests/UnitTests/{_Core => A_Core}/LoadPlugin/templates/test_default_static_modifier.tpl (100%) create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_include_path1.tpl create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_include_path2.tpl create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_include_path3.tpl rename tests/UnitTests/{_Core => A_Core}/MuteExpectedErrors/MuteExpectedErrorsTest.php (100%) rename tests/UnitTests/{_Core => A_Core}/MuteExpectedErrors/templates/default.tpl (100%) rename tests/UnitTests/{_Core => A_Core}/PluginTests/OutputFilterTrimWhitespaceTest.php (100%) rename tests/UnitTests/{_Core => A_Core}/PluginTests/PHPunitplugins/function.chain1.php (100%) rename tests/UnitTests/{_Core => A_Core}/PluginTests/PHPunitplugins/function.chain2.php (100%) rename tests/UnitTests/{_Core => A_Core}/PluginTests/PHPunitplugins/function.chain3.php (100%) rename tests/UnitTests/{_Core => A_Core}/PluginTests/PluginChainedLoadTest.php (100%) rename tests/UnitTests/{_Core => A_Core}/PluginTests/Shared/SharedFunctionsTest.php (100%) rename tests/UnitTests/{_Core => A_Core}/PluginTests/helpers/_object_tostring.php (100%) rename tests/UnitTests/{_Core => A_Core}/PluginTests/templates/test_plugin_chained_load.tpl (100%) rename tests/UnitTests/{_Core => A_Core}/PluginTests/templates/whitespace.tpl (100%) rename tests/UnitTests/{_Core => A_Core}/SmartyBC/SmartyBcTest.php (100%) diff --git a/tests/Include_Path/Plugins/include/function.plugin1.php b/tests/Include_Path/Plugins/include/function.plugin1.php new file mode 100644 index 00000000..50fc9d40 --- /dev/null +++ b/tests/Include_Path/Plugins/include/function.plugin1.php @@ -0,0 +1,5 @@ +cleanDir($dir . '/templates_c'); + $this->cleanDir($dir . '/cache'); $dir = __DIR__; } if (!is_dir($dir . '/templates_c')) { @@ -529,49 +531,6 @@ KEY `expire` (`expire`) } } - /** - * Remove Smarty object from cached resources - * - */ - public function clearResourceCache() - { - if (class_exists('Smarty_Resource', false)) { - if (isset(Smarty_Resource::$sources) && !empty(Smarty_Resource::$sources)) { - foreach (Smarty_Resource::$sources as $obj) { - if (isset($obj->smarty)) { - $obj->smarty = null; - } - } - Smarty_Resource::$sources = array(); - } - if (isset(Smarty_Resource::$compileds) && !empty(Smarty_Resource::$compileds)) { - foreach (Smarty_Resource::$compileds as $obj) { - if (isset($obj->smarty)) { - $obj->smarty = null; - } - } - Smarty_Resource::$compileds = array(); - } - if (isset(Smarty_Resource::$resources) && !empty(Smarty_Resource::$resources)) { - foreach (Smarty_Resource::$resources as $obj) { - if (isset($obj->smarty)) { - $obj->smarty = null; - } - } - Smarty_Resource::$resources = array(); - } - } - if (class_exists('Smarty_CacheResource', false)) { - if (isset(Smarty_CacheResource::$resources) && !empty(Smarty_CacheResource::$resources)) { - foreach (Smarty_CacheResource::$resources as $obj) { - if (isset($obj->smarty)) { - $obj->smarty = null; - } - } - Smarty_CacheResource::$resources = array(); - } - } - } /** * Tears down the fixture @@ -580,7 +539,6 @@ KEY `expire` (`expire`) */ protected function tearDown() { - $this->clearResourceCache(); if (isset($this->smarty->smarty)) { $this->smarty->smarty = null; } diff --git a/tests/UnitTests/_Core/AutoEscape/AutoEscapeTest.php b/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php similarity index 100% rename from tests/UnitTests/_Core/AutoEscape/AutoEscapeTest.php rename to tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php diff --git a/tests/UnitTests/_Core/Filter/FilterTest.php b/tests/UnitTests/A_Core/Filter/FilterTest.php similarity index 100% rename from tests/UnitTests/_Core/Filter/FilterTest.php rename to tests/UnitTests/A_Core/Filter/FilterTest.php diff --git a/tests/UnitTests/_Core/Filter/LoadFilterTest.php b/tests/UnitTests/A_Core/Filter/LoadFilterTest.php similarity index 100% rename from tests/UnitTests/_Core/Filter/LoadFilterTest.php rename to tests/UnitTests/A_Core/Filter/LoadFilterTest.php diff --git a/tests/UnitTests/_Core/Filter/RegisterFilterTest.php b/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php similarity index 100% rename from tests/UnitTests/_Core/Filter/RegisterFilterTest.php rename to tests/UnitTests/A_Core/Filter/RegisterFilterTest.php diff --git a/tests/UnitTests/_Core/GetterSetter/GetterSetterTest.php b/tests/UnitTests/A_Core/GetterSetter/GetterSetterTest.php similarity index 100% rename from tests/UnitTests/_Core/GetterSetter/GetterSetterTest.php rename to tests/UnitTests/A_Core/GetterSetter/GetterSetterTest.php diff --git a/tests/UnitTests/_Core/LoadPlugin/DefaultPluginHandlerTest.php b/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php similarity index 100% rename from tests/UnitTests/_Core/LoadPlugin/DefaultPluginHandlerTest.php rename to tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php diff --git a/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php b/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php new file mode 100644 index 00000000..371c073e --- /dev/null +++ b/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php @@ -0,0 +1,49 @@ +setUpSmarty(__DIR__); + $this->smarty->use_include_path = true; + $this->smarty->setPluginsDir(array('./include','./include1')); + $this->smarty->enableSecurity(); + $ds = DS; + set_include_path($this->smarty->_realpath(__DIR__ . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Plugins{$ds}", true) . PATH_SEPARATOR . get_include_path()); + } + + /** + * Tears down the fixture + * This method is called after a test is executed. + * + */ + protected function tearDown() + { + restore_include_path(); + $this->smarty->disableSecurity(); + parent::tearDown(); + } + public function testInit() + { + $this->cleanDirs(); + } + public function testInclude1() + { + $this->assertContains('plugin1', $this->smarty->fetch('test_include_path1.tpl')); + } + public function testInclude2() + { + $this->assertContains('plugin2', $this->smarty->fetch('test_include_path2.tpl')); + } + public function testInclude3() + { + $this->assertContains('plugin3', $this->smarty->fetch('test_include_path3.tpl')); + } + } diff --git a/tests/UnitTests/_Core/LoadPlugin/LoadPluginTest.php b/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php similarity index 100% rename from tests/UnitTests/_Core/LoadPlugin/LoadPluginTest.php rename to tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php diff --git a/tests/UnitTests/A_Core/LoadPlugin/include/function.plugin3.php b/tests/UnitTests/A_Core/LoadPlugin/include/function.plugin3.php new file mode 100644 index 00000000..c9c3a6ef --- /dev/null +++ b/tests/UnitTests/A_Core/LoadPlugin/include/function.plugin3.php @@ -0,0 +1,5 @@ +getVariable('test'), $text); + return str_replace('#', $tpl->_getVariable('test'), $text); } /** @@ -376,7 +376,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty */ public function testCache($lockTime, $lockTimeout, $compile_id, $cache_id, $isCached, $tmin, $tmax, $forceCompile, $forceCache, $update, $testNumber, $compileTestNumber, $renderTestNumber, $testName) { - if ($testNumber == 27) { + if ($testNumber == 13) { $i =0; } $this->smarty->caching = true; diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php index e061c5ab..44a73e90 100644 --- a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php @@ -46,7 +46,7 @@ if (defined(MysqlResourceEnable) && MysqlResourceEnable == 'true') { // $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); $this->smarty->addPluginsDir("./PHPunitplugins/"); $tpl = $this->smarty->createTemplate('mysqltest:test.tpl'); - $this->assertEquals(strtotime("2010-12-25 22:00:00"), $tpl->source->timestamp); + $this->assertEquals(strtotime("2010-12-25 22:00:00"), $tpl->source->getTimeStamp()); } /** @@ -81,7 +81,7 @@ if (defined(MysqlResourceEnable) && MysqlResourceEnable == 'true') { // $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); $this->smarty->addPluginsDir("./PHPunitplugins/"); $tpl = $this->smarty->createTemplate('mysqlstest:test.tpl'); - $this->assertEquals(strtotime("2010-12-25 22:00:00"), $tpl->source->timestamp); + $this->assertEquals(strtotime("2010-12-25 22:00:00"), $tpl->source->getTimeStamp()); } } } \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php b/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php index 68b8b99f..1d7343c3 100644 --- a/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php +++ b/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php @@ -79,7 +79,7 @@ class EvalResourceTest extends PHPUnit_Smarty public function testUsesCompiler() { $tpl = $this->smarty->createTemplate('eval:hello world'); - $this->assertFalse($tpl->source->uncompiled); + $this->assertFalse($tpl->source->handler->uncompiled); } /** @@ -88,7 +88,7 @@ class EvalResourceTest extends PHPUnit_Smarty public function testIsEvaluated() { $tpl = $this->smarty->createTemplate('eval:hello world'); - $this->assertTrue($tpl->source->recompiled); + $this->assertTrue($tpl->source->handler->recompiled); } /** diff --git a/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php b/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php index 77007871..292f0d22 100644 --- a/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php +++ b/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php @@ -52,7 +52,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty $this->assertFalse($tpl->isCached()); $result = $this->smarty->fetch($tpl); $this->assertContains('Grandchild Page Title', $result); - $this->smarty->template_objects = null; + $this->smarty->_cache['template_objects'] = null; $tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $this->assertTrue($tpl2->isCached()); $result = $this->smarty->fetch($tpl2); @@ -74,7 +74,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty $this->assertFalse($tpl->isCached()); $result = $this->smarty->fetch($tpl); $this->assertContains('Grandchild Page Title', $result); - $this->smarty->template_objects = null; + $this->smarty->_cache['template_objects'] = null; $tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $this->assertTrue($tpl2->isCached()); $result = $this->smarty->fetch($tpl2); @@ -96,7 +96,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty $this->assertFalse($tpl->isCached()); $result = $this->smarty->fetch($tpl); $this->assertContains('Grandchild Page Title', $result); - $this->smarty->template_objects = null; + $this->smarty->_cache['template_objects'] = null; $tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $this->assertTrue($tpl2->isCached()); $result = $this->smarty->fetch($tpl2); @@ -118,7 +118,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty $this->assertFalse($tpl->isCached()); $result = $this->smarty->fetch($tpl); $this->assertContains('Grandchild Page Title', $result); - $this->smarty->template_objects = null; + $this->smarty->_cache['template_objects'] = null; $tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $this->assertTrue($tpl2->isCached()); $result = $this->smarty->fetch($tpl2); diff --git a/tests/UnitTests/ResourceTests/File/FileResourceTest.php b/tests/UnitTests/ResourceTests/File/FileResourceTest.php index 84bef22d..98af2d26 100644 --- a/tests/UnitTests/ResourceTests/File/FileResourceTest.php +++ b/tests/UnitTests/ResourceTests/File/FileResourceTest.php @@ -90,13 +90,13 @@ class FileResourceTest extends PHPUnit_Smarty public function testUsesCompiler() { $tpl = $this->smarty->createTemplate('helloworld.tpl'); - $this->assertFalse($tpl->source->uncompiled); + $this->assertFalse($tpl->source->handler->uncompiled); } public function testIsEvaluated() { $tpl = $this->smarty->createTemplate('helloworld.tpl'); - $this->assertFalse($tpl->source->recompiled); + $this->assertFalse($tpl->source->handler->recompiled); } public function testGetCompiledFilepath() diff --git a/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php b/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php index 574cb469..c2fa3d60 100644 --- a/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php +++ b/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php @@ -63,7 +63,7 @@ class PhpResourceTest extends PHPUnit_Smarty public function testUsesCompiler() { $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); - $this->assertTrue($tpl->source->uncompiled); + $this->assertTrue($tpl->source->handler->uncompiled); } /** @@ -72,7 +72,7 @@ class PhpResourceTest extends PHPUnit_Smarty public function testIsEvaluated() { $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); - $this->assertFalse($tpl->source->recompiled); + $this->assertFalse($tpl->source->handler->recompiled); } /** diff --git a/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php b/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php index 3cbb58ff..43f3320e 100644 --- a/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php +++ b/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php @@ -69,7 +69,7 @@ class StreamResourceTest extends PHPUnit_Smarty public function testUsesCompiler() { $tpl = $this->smarty->createTemplate('global:mytest'); - $this->assertFalse($tpl->source->uncompiled); + $this->assertFalse($tpl->source->handler->uncompiled); } /** @@ -78,7 +78,7 @@ class StreamResourceTest extends PHPUnit_Smarty public function testIsEvaluated() { $tpl = $this->smarty->createTemplate('global:mytest'); - $this->assertTrue($tpl->source->recompiled); + $this->assertTrue($tpl->source->handler->recompiled); } /** diff --git a/tests/UnitTests/ResourceTests/String/StringResourceTest.php b/tests/UnitTests/ResourceTests/String/StringResourceTest.php index cae2f60c..386c0662 100644 --- a/tests/UnitTests/ResourceTests/String/StringResourceTest.php +++ b/tests/UnitTests/ResourceTests/String/StringResourceTest.php @@ -81,7 +81,7 @@ class StringResourceTest extends PHPUnit_Smarty public function testUsesCompiler() { $tpl = $this->smarty->createTemplate('string:hello world'); - $this->assertFalse($tpl->source->uncompiled); + $this->assertFalse($tpl->source->handler->uncompiled); } /** @@ -90,7 +90,7 @@ class StringResourceTest extends PHPUnit_Smarty public function testIsEvaluated() { $tpl = $this->smarty->createTemplate('string:hello world'); - $this->assertFalse($tpl->source->recompiled); + $this->assertFalse($tpl->source->handler->recompiled); } /** diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php index cc213a6e..52b28aa1 100644 --- a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php @@ -89,7 +89,7 @@ class ClearCompiledTest extends PHPUnit_Smarty } // TODO //Smarty::$_resource_cache = array(); - $this->smarty->template_objects = array(); + //$this->smarty->_cache['template_objects'] = array(); return $this->_files; } diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php index 61f921ed..f507c358 100644 --- a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php @@ -232,14 +232,14 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty */ public function testCompileBlockGrandChildMustCompile_021_1() { - $this->cleanDirs(); + $this->smarty->setCompileDir('./templates_c/mustcompile'); $this->smarty->caching = true; $this->smarty->cache_lifetime = 1000; $tpl = $this->smarty->createTemplate('021_grandchild.tpl'); $this->assertFalse($tpl->isCached()); $result = $this->smarty->fetch($tpl); $this->assertContains('Grandchild Page Title', $result); - $this->smarty->template_objects = null; + $this->smarty->_cache['template_objects'] = null; $tpl2 = $this->smarty->createTemplate('021_grandchild.tpl'); $this->assertTrue($tpl2->isCached()); $result = $this->smarty->fetch($tpl2); @@ -252,6 +252,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty */ public function testCompileBlockGrandChildMustCompile_021_2() { + $this->smarty->setCompileDir('./templates_c/mustcompile'); sleep(2); touch($this->smarty->getTemplateDir(0) . '021_grandchild.tpl'); clearstatcache(); @@ -261,7 +262,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty $this->assertFalse($tpl->isCached()); $result = $this->smarty->fetch($tpl); $this->assertContains('Grandchild Page Title', $result); - $this->smarty->template_objects = null; + $this->smarty->_cache['template_objects'] = null; $tpl2 = $this->smarty->createTemplate('021_grandchild.tpl'); $this->assertTrue($tpl2->isCached()); $result = $this->smarty->fetch($tpl2); @@ -274,6 +275,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty */ public function testCompileBlockGrandChildMustCompile_021_3() { + $this->smarty->setCompileDir('./templates_c/mustcompile'); sleep(2); touch($this->smarty->getTemplateDir(0) . '021_child.tpl'); clearstatcache(); @@ -283,7 +285,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty $this->assertFalse($tpl->isCached()); $result = $this->smarty->fetch($tpl); $this->assertContains('Grandchild Page Title', $result); - $this->smarty->template_objects = null; + $this->smarty->_cache['template_objects'] = null; $tpl2 = $this->smarty->createTemplate('021_grandchild.tpl'); $this->assertTrue($tpl2->isCached()); $result = $this->smarty->fetch($tpl2); @@ -296,6 +298,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty */ public function testCompileBlockGrandChildMustCompile_021_4() { + $this->smarty->setCompileDir('./templates_c/mustcompile'); sleep(2); touch($this->smarty->getTemplateDir(0) . '021_parent.tpl'); clearstatcache(); @@ -305,7 +308,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty $this->assertFalse($tpl->isCached()); $result = $this->smarty->fetch($tpl); $this->assertContains('Grandchild Page Title', $result); - $this->smarty->template_objects = null; + $this->smarty->_cache['template_objects'] = null; $tpl2 = $this->smarty->createTemplate('021_grandchild.tpl'); $this->assertTrue($tpl2->isCached()); $result = $this->smarty->fetch($tpl2); diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php index 7161f7e2..d0da7378 100644 --- a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php @@ -24,7 +24,7 @@ class CompileFunctionTest extends PHPUnit_Smarty $this->cleanDirs(); } /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProvider * test simple function call tag @@ -38,7 +38,7 @@ class CompileFunctionTest extends PHPUnit_Smarty } /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProvider * test simple function call tag cached @@ -52,7 +52,7 @@ class CompileFunctionTest extends PHPUnit_Smarty } /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProvider * test simple function call tag cached @@ -67,7 +67,7 @@ class CompileFunctionTest extends PHPUnit_Smarty /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProvider * test simple function call tag cached no cache default variable @@ -82,7 +82,7 @@ class CompileFunctionTest extends PHPUnit_Smarty } /** - * test simple function call tag ached no cache default variable 2 + * test simple function call tag cached no cache default variable 2 * * @run InSeparateProcess * @preserveGlobalState disabled @@ -97,21 +97,22 @@ class CompileFunctionTest extends PHPUnit_Smarty } /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled - * @dataProvider functionProvider + * @dataProvider functionProviderCaching * test simple function call tag plugin * */ - public function testSimpleFunctionPlugin_003() + public function testSimpleFunctionPlugin_003($caching, $text) { + $this->smarty->setCaching($caching); $this->smarty->assign('param', 1); $this->smarty->assign('default', 2, true); - $this->assertEquals("default 1", $this->smarty->fetch('test_template_function_003.tpl')); + $this->assertEquals("default 1", $this->smarty->fetch('test_template_function_003.tpl'), $text); } /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProvider * test simple function call tag plugin nocache @@ -123,12 +124,12 @@ class CompileFunctionTest extends PHPUnit_Smarty $this->smarty->setCompileId(1); $this->smarty->assign('param', 1); $this->smarty->assign('default', 2, true); - $this->assertEquals("default 1", $this->smarty->fetch('test_template_function_003.tpl')); + $this->assertEquals("default 1", $this->smarty->fetch('test_template_function_003.tpl'), $text); } /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProvider * test simple function call tag 2 @@ -141,7 +142,7 @@ class CompileFunctionTest extends PHPUnit_Smarty /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProvider * test simple function call recursive @@ -152,7 +153,7 @@ class CompileFunctionTest extends PHPUnit_Smarty } /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProviderInline * test inherited function call tag @@ -165,7 +166,7 @@ class CompileFunctionTest extends PHPUnit_Smarty } /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProviderInline * test function definition in include @@ -180,7 +181,7 @@ class CompileFunctionTest extends PHPUnit_Smarty /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProviderInline * test external function definition cached @@ -198,7 +199,7 @@ class CompileFunctionTest extends PHPUnit_Smarty } /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProviderInline * test external function definition cached 2 @@ -217,7 +218,7 @@ class CompileFunctionTest extends PHPUnit_Smarty } /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProviderInline * test external function definition nocache call @@ -235,7 +236,7 @@ class CompileFunctionTest extends PHPUnit_Smarty } /** - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProviderInline * test external function definition nocache call 2 @@ -256,7 +257,7 @@ class CompileFunctionTest extends PHPUnit_Smarty /** * test external function definition nocache call 3 * - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled * @dataProvider functionProviderInline */ @@ -273,24 +274,15 @@ class CompileFunctionTest extends PHPUnit_Smarty } /** - * test external function definition nocache call 3 + * test external defined recursion * - * @run InSeparateProcess + * @runinSeparateProcess * @preserveGlobalState disabled + * @dataProvider functionProvider */ - public function testExternalDefinedFunctionRecursion() + public function testExternalDefinedFunctionRecursion($text) { - $this->assertEquals('12345', $this->smarty->fetch('test_template_function_recursion2.tpl')); - } - /** - * test external function definition nocache call 3 - * - * @run InSeparateProcess - * @preserveGlobalState disabled - */ - public function testExternalDefinedFunctionRecursion2() - { - $this->assertEquals('12345', $this->smarty->fetch('test_template_function_recursion2.tpl')); + $this->assertEquals('12345', $this->smarty->fetch('test_template_function_recursion2.tpl'), $text); } /** @@ -306,7 +298,7 @@ class CompileFunctionTest extends PHPUnit_Smarty ); } /** - * Function data provider inline + * Function data provider */ public function functionProvider() { @@ -315,4 +307,16 @@ class CompileFunctionTest extends PHPUnit_Smarty array('call'), ); } + /** + * Function data provider + */ + public function functionProviderCaching() + { + return array( + array(false, 'normal compile'), + array(false, 'normal call'), + array(true, 'cached compile'), + array(true, 'cached call'), + ); + } }