From 17d4d43624f9cd183ae0395854f4409c410e3ce9 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Mon, 13 Apr 2020 15:30:52 +0200 Subject: [PATCH] Feature/merge smarty-phpunit into tests subfolder (#580) * Removed unneeded files and replace dummy.txt with .gitignore files * Synced unit tests with master codebase, noted TODO's, fixed phpunit scripts and travis config * fix php7.4 deprecation and remove php7.4 from travis allow_failures since php7.4 is current stable Co-authored-by: Uwe Tews Co-authored-by: Uwe Tews Co-authored-by: AnrDaemon --- .gitignore | 1 - .travis.yml | 7 +- TODO.md | 69 + phpunit.sh | 2 + phpunit.xml | 43 + tests/.gitignore | 11 + tests/Bootstrap.php | 28 + tests/Config.php | 18 + .../Plugins/include/function.plugin1.php | 5 + .../Plugins/include1/function.plugin2.php | 5 + .../Tpl/include/include_test2.tpl | 1 + .../Tpl/include/include_test4.tpl | 1 + tests/Include_Path/Tpl/templates_2/test4.tpl | 1 + tests/Include_Path/Tpl/test5.tpl | 1 + tests/PHPUnit_Smarty.php | 699 +++++++++ .../PathNormalizationTest.php | 78 + .../PluginDirNormalizationTest.php | 145 ++ .../TemlateDirNormalizationTest.php | 137 ++ .../A_0/PathNormalization/cache/.gitignore | 2 + .../PathNormalization/templates_c/.gitignore | 2 + .../ProtectedFolderVarsTest.php | 226 +++ .../A_1/ProtectedFolderVars/cache/.gitignore | 2 + .../A_1/ProtectedFolderVars/comp/.gitignore | 2 + .../UndefinedTemplateVarTest.php | 74 + .../A_2/UndefinedTemplateVar/cache/.gitignore | 2 + .../templates/001_include.tpl | 1 + .../templates/001_main.tpl | 1 + .../templates_c/.gitignore | 2 + .../A_Core/AutoEscape/AutoEscapeTest.php | 33 + .../A_Core/AutoEscape/cache/.gitignore | 2 + .../A_Core/AutoEscape/templates_c/.gitignore | 2 + .../UnitTests/A_Core/Filter/FilterClosure.php | 14 + tests/UnitTests/A_Core/Filter/FilterTest.php | 279 ++++ .../A_Core/Filter/LoadFilterTest.php | 31 + .../A_Core/Filter/RegisterFilterTest.php | 158 ++ .../UnitTests/A_Core/Filter/cache/.gitignore | 2 + .../A_Core/Filter/templates/output_001.tpl | 1 + .../A_Core/Filter/templates/output_002.tpl | 1 + .../A_Core/Filter/templates_c/.gitignore | 2 + .../A_Core/GetterSetter/GetterSetterTest.php | 75 + .../A_Core/GetterSetter/cache/.gitignore | 2 + .../GetterSetter/templates_c/.gitignore | 2 + .../LoadPlugin/DefaultPluginHandlerTest.php | 182 +++ .../A_Core/LoadPlugin/IncludePathTest.php | 51 + .../A_Core/LoadPlugin/LoadPluginTest.php | 54 + .../A_Core/LoadPlugin/cache/.gitignore | 2 + .../LoadPlugin/include/function.plugin3.php | 5 + .../LoadPlugin/scripts/script_block_tag.php | 7 + .../scripts/script_compiler_function_tag.php | 5 + .../script_default_static_modifier.php | 10 + .../scripts/script_function_tag.php | 5 + .../LoadPlugin/scripts/script_modifier.php | 5 + .../LoadPlugin/scripts/test_include_php.php | 2 + .../templates/test_default_block_script.tpl | 1 + .../test_default_compiler_function_script.tpl | 1 + .../test_default_compiler_object.tpl | 1 + .../templates/test_default_function_local.tpl | 1 + .../test_default_function_script.tpl | 1 + ...st_default_function_script_notcachable.tpl | 1 + .../templates/test_default_modifier.tpl | 1 + .../test_default_modifier_script.tpl | 1 + .../test_default_static_modifier.tpl | 1 + .../templates/test_include_path1.tpl | 1 + .../templates/test_include_path2.tpl | 1 + .../templates/test_include_path3.tpl | 1 + .../A_Core/LoadPlugin/templates_c/.gitignore | 2 + .../MuteExpectedErrorsTest.php | 123 ++ .../MuteExpectedErrors/cache/.gitignore | 2 + .../MuteExpectedErrors/templates/default.tpl | 1 + .../MuteExpectedErrors/templates_c/.gitignore | 2 + .../PHPunitplugins/function.chain1.php | 7 + .../PHPunitplugins/function.chain2.php | 7 + .../PHPunitplugins/function.chain3.php | 5 + .../PluginTests/PluginChainedLoadTest.php | 33 + .../Shared/SharedFunctionsTest.php | 29 + .../PluginTests/Shared/cache/.gitignore | 2 + .../PluginTests/Shared/templates_c/.gitignore | 2 + .../A_Core/PluginTests/cache/.gitignore | 2 + .../PluginTests/helpers/_object_tostring.php | 26 + .../templates/test_plugin_chained_load.tpl | 1 + .../A_Core/PluginTests/templates_c/.gitignore | 2 + .../A_Core/SmartyBC/SmartyBcTest.php | 37 + .../A_Core/SmartyBC/cache/.gitignore | 2 + .../A_Core/SmartyBC/templates_c/.gitignore | 2 + .../ModifiedSince/HttpModifiedSinceTest.php | 148 ++ .../ModifiedSince/cache/.gitignore | 2 + .../ModifiedSince/templates/helloworld.tpl | 1 + .../ModifiedSince/templates_c/.gitignore | 2 + .../Apc/CacheResourceCustomApcTest.php | 36 + .../File/CacheResourceFileTest.php | 383 +++++ .../CacheResourceTests/File/cache/.gitignore | 2 + .../File/templates_c/.gitignore | 2 + .../CacheResourceCustomMemcacheTest.php | 97 ++ .../Memcache/templates_c/.gitignore | 2 + .../Mysql/CacheResourceCustomMysqlTest.php | 43 + .../CacheResourceTests/Mysql/cache/.gitignore | 2 + .../Mysql/templates_c/.gitignore | 2 + .../PDO/CacheResourceCustomPDOTest.php | 47 + .../CacheResourceCustomPDOGzipTest.php | 45 + .../CacheResourceCustomRegisteredTest.php | 44 + .../Registered/templates_c/.gitignore | 2 + .../_shared/CacheResourceTestCommon.php | 569 +++++++ .../PHPunitplugins/cacheresource.apctest.php | 38 + .../PHPunitplugins/cacheresource.filetest.php | 18 + .../cacheresource.memcachetest.php | 38 + .../cacheresource.mysqltest.php | 31 + .../cacheresource.pdo_gziptest.php | 19 + .../PHPunitplugins/cacheresource.pdotest.php | 20 + .../PHPunitplugins/resource.filetest.php | 22 + .../_shared/templates/a/include.tpl | 1 + .../_shared/templates/b/include.tpl | 1 + .../_shared/templates/cacheresource.tpl | 1 + .../_shared/templates/helloworld.tpl | 1 + .../_shared/templates/helloworld2.tpl | 1 + .../_shared/templates/templatedir.tpl | 1 + .../CompileCompilerPluginTest.php | 71 + .../Compiler/CompilerPlugin/cache/.gitignore | 2 + .../templates/compilerplugintest.tpl | 1 + .../CompilerPlugin/templates_c/.gitignore | 2 + .../Compiler/Delimiter/AutoLiteralTest.php | 90 ++ .../Compiler/Delimiter/DelimiterTest.php | 102 ++ .../Compiler/Delimiter/UserLiteralTest.php | 72 + .../Compiler/Delimiter/cache/.gitignore | 2 + .../Delimiter/templates/autoliteral.tpl | 1 + .../Delimiter/templates/autoliteralblock.tpl | 1 + .../templates/autoliteraldoublequote.tpl | 1 + .../templates/autoliteraldoublequote2.tpl | 1 + .../Delimiter/templates/userliteral.tpl | 1 + .../Delimiter/templates/userliteral1.tpl | 1 + .../Delimiter/templates/userliteral2.tpl | 1 + .../templates/userliteraldoublequote.tpl | 1 + .../Compiler/Delimiter/templates_c/.gitignore | 2 + .../DefaultConfigHandlerTest.php | 179 +++ .../defaultHandler/configs/test.conf | 49 + .../defaultHandler/templates/foo.tpl | 1 + .../defaultHandler/templates/number.tpl | 1 + .../defaultHandler/templates_c/.gitignore | 2 + .../ConfigFileTests/file/ConfigVarTest.php | 409 +++++ .../file/PHPunitplugins/resource.db4.php | 27 + .../ConfigFileTests/file/configs/test.conf | 49 + .../ConfigFileTests/file/templates/foo.tpl | 1 + .../ConfigFileTests/file/templates/hidden.tpl | 1 + .../ConfigFileTests/file/templates/number.tpl | 1 + .../ConfigFileTests/file/templates/sec.tpl | 1 + .../file/templates/sec1sec2.tpl | 1 + .../ConfigFileTests/file/templates/text.tpl | 1 + .../file/templates_c/.gitignore | 2 + .../Ambiguous/CustomResourceAmbiguousTest.php | 121 ++ .../PHPunitplugins/resource.ambiguous.php | 58 + .../Custom/Ambiguous/cache/.gitignore | 2 + .../Custom/Ambiguous/resource.tpl | 0 .../templates/ambiguous/case1/foobar.tpl | 1 + .../templates/ambiguous/case2/foobar.tpl | 1 + .../Custom/Ambiguous/templates_c/.gitignore | 2 + .../ResourceExtendsAllPluginTest.php | 165 ++ .../DemoPluginExtendsAll/cache/.gitignore | 2 + .../templates/extendsall.tpl | 3 + .../templates/extendsall2.tpl | 3 + .../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_2/helloworld.php | 1 + .../templates_3/data1.tpl | 4 + .../templates_3/extendsall.tpl | 6 + .../templates_4/extendsall.tpl | 4 + .../templates_c/.gitignore | 2 + .../PHPunitplugins/resource.mysqlstest.php | 18 + .../PHPunitplugins/resource.mysqltest.php | 19 + .../ResourceMysqlPluginTest.php | 151 ++ .../Custom/DemoPluginMysql/cache/.gitignore | 2 + .../DemoPluginMysql/templates_c/.gitignore | 2 + .../DefaultTemplateHandlerTest.php | 113 ++ .../DefaultHandler/cache/.gitignore | 2 + .../DefaultHandler/templates/helloworld.tpl | 1 + .../DefaultHandler/templates_c/.gitignore | 2 + .../ResourceTests/Eval/EvalResourceTest.php | 188 +++ .../ResourceTests/Eval/cache/.gitignore | 2 + .../ResourceTests/Eval/templates_c/.gitignore | 2 + .../Extends/ExtendsResourceTest.php | 326 ++++ .../ResourceTests/Extends/cache/.gitignore | 2 + .../Extends/templates/003_child_prepend.tpl | 1 + .../Extends/templates/003_parent.tpl | 2 + .../Extends/templates/004_child_append.tpl | 1 + .../Extends/templates/004_parent.tpl | 2 + .../Extends/templates/021_child.tpl | 1 + .../Extends/templates/021_grandchild.tpl | 1 + .../Extends/templates/021_parent.tpl | 1 + .../Extends/templates/022_child.tpl | 4 + .../Extends/templates/033_grandchild.tpl | 1 + .../Extends/templates/034_child.tpl | 3 + .../Extends/templates/034_grandchild.tpl | 3 + .../Extends/templates/034_parent.tpl | 4 + .../Extends/templates/040_child.tpl | 1 + .../Extends/templates/040_parent.tpl | 2 + .../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 + .../Extends/templates_c/.gitignore | 2 + .../ResourceTests/File/FileResourceTest.php | 602 +++++++ .../ResourceTests/File/cache/.gitignore | 2 + .../File/templates/001_smarty_current_dir.tpl | 1 + .../File/templates/001_smarty_template.tpl | 1 + .../ResourceTests/File/templates/dirname.tpl | 1 + .../File/templates/helloworld.tpl | 1 + .../ResourceTests/File/templates/relative.tpl | 1 + .../File/templates/relative_notexist.tpl | 1 + .../File/templates/relative_sub.tpl | 1 + .../File/templates/relativity/foo.tpl | 1 + .../File/templates/relativity/relativity.tpl | 1 + .../relativity/theory/einstein/einstein.tpl | 1 + .../relativity/theory/einstein/foo.tpl | 1 + .../File/templates/relativity/theory/foo.tpl | 1 + .../templates/relativity/theory/theory.tpl | 1 + .../File/templates/sub/relative.tpl | 1 + .../ResourceTests/File/templates_2/hello.tpl | 1 + .../ResourceTests/File/templates_c/.gitignore | 2 + .../FileIncludePath/FileIncludePathTest.php | 67 + .../FileIncludePath/cache/.gitignore | 2 + .../FileIncludePath/include_test3.tpl | 1 + .../FileIncludePath/templates/dirname.tpl | 1 + .../FileIncludePath/templates/test1.tpl | 1 + .../FileIncludePath/templates/test2.tpl | 1 + .../FileIncludePath/templates/test3.tpl | 1 + .../FileIncludePath/templates_2/dirname.tpl | 1 + .../templates_2/include_test1.tpl | 1 + .../FileIncludePath/templates_3/dirname.tpl | 1 + .../FileIncludePath/templates_4/dirname.tpl | 1 + .../FileIncludePath/templates_c/.gitignore | 2 + .../FileIndexed/FileResourceIndexedTest.php | 115 ++ .../FileIndexed/cache/.gitignore | 2 + .../FileIndexed/templates/dirname.tpl | 1 + .../FileIndexed/templates_2/dirname.tpl | 1 + .../FileIndexed/templates_2/dirname1.tpl | 1 + .../FileIndexed/templates_2/dirname_x.tpl | 1 + .../FileIndexed/templates_3/dirname.tpl | 1 + .../FileIndexed/templates_3/dirname10.tpl | 1 + .../FileIndexed/templates_4/dirname.tpl | 1 + .../FileIndexed/templates_4/dirname_foo.tpl | 1 + .../FileIndexed/templates_4/dirname_x.tpl | 1 + .../FileIndexed/templates_c/.gitignore | 2 + .../ResourceTests/Php/PhpResourceTest.php | 300 ++++ .../ResourceTests/Php/cache/.gitignore | 2 + .../Php/templates/includephp.tpl | 1 + .../Php/templates/phphelloworld.php | 1 + .../Php/templates_2/helloworld.php | 1 + .../ResourceTests/Php/templates_c/.gitignore | 2 + .../Registered/RegisteredResourceTest.php | 162 ++ .../ResourceTests/Registered/cache/.gitignore | 2 + .../Registered/templates_c/.gitignore | 2 + .../PHPunitplugins/resource.db.php | 37 + .../PHPunitplugins/resource.db2.php | 27 + .../PHPunitplugins/resource.db3.php | 32 + .../PHPunitplugins/resource.db4.php | 31 + .../ResourcePlugins/ResourcePluginTest.php | 80 + .../ResourcePlugins/cache/.gitignore | 2 + .../ResourcePlugins/templates/extendsall.tpl | 2 + .../ResourcePlugins/templates/extendsall2.tpl | 2 + .../templates_2/ambiguous/case1/foobar.tpl | 1 + .../ResourcePlugins/templates_2/dirname.tpl | 1 + .../ResourcePlugins/templates_2/hello.tpl | 1 + .../templates_2/helloworld.php | 1 + .../ResourcePlugins/templates_3/dirname.tpl | 1 + .../templates_3/extendsall.tpl | 5 + .../ResourcePlugins/templates_4/dirname.tpl | 1 + .../templates_4/extendsall.tpl | 3 + .../ResourcePlugins/templates_c/.gitignore | 2 + .../Stream/StreamResourceTest.php | 279 ++++ .../ResourceTests/Stream/cache/.gitignore | 2 + .../Stream/templates_c/.gitignore | 2 + .../String/StringResourceTest.php | 198 +++ .../ResourceTests/String/cache/.gitignore | 2 + .../String/templates_c/.gitignore | 2 + .../UnitTests/SecurityTests/FunctionTest.php | 44 + .../UnitTests/SecurityTests/SecurityTest.php | 471 ++++++ .../UnitTests/SecurityTests/cache/.gitignore | 2 + .../SecurityTests/templates/helloworld.tpl | 1 + .../SecurityTests/templates_2/hello.tpl | 1 + .../SecurityTests/templates_3/dirname.tpl | 1 + .../SecurityTests/templates_c/.gitignore | 2 + .../SmartyMethodsTests/Append/AppendTest.php | 86 + .../Append/cache/.gitignore | 2 + .../Append/templates_c/.gitignore | 2 + .../AppendByRef/AppendByRefBCTest.php | 48 + .../AppendByRef/AppendByRefTest.php | 64 + .../AppendByRef/cache/.gitignore | 2 + .../AppendByRef/templates_c/.gitignore | 2 + .../SmartyMethodsTests/Assign/AssignTest.php | 45 + .../Assign/cache/.gitignore | 2 + .../Assign/templates_c/.gitignore | 2 + .../AssignByRef/AssignByRefBCTest.php | 51 + .../AssignByRef/AssignByRefTest.php | 33 + .../AssignByRef/cache/.gitignore | 2 + .../AssignByRef/templates_c/.gitignore | 2 + .../AssignGlobal/AssignGlobalTest.php | 70 + .../AssignGlobal/cache/.gitignore | 2 + .../AssignGlobal/templates_c/.gitignore | 2 + .../ClearAllAssign/ClearAllAssignBCTest.php | 40 + .../ClearAllAssign/ClearAllAssignTest.php | 73 + .../ClearAllAssign/cache/.gitignore | 2 + .../ClearAllAssign/templates_c/.gitignore | 2 + .../ClearAssign/ClearAssignBCTest.php | 47 + .../ClearAssign/ClearAssignTest.php | 53 + .../ClearAssign/cache/.gitignore | 2 + .../ClearAssign/templates_c/.gitignore | 2 + .../ClearCompiledBCTest.php | 29 + .../ClearCompiledTest.php | 454 ++++++ .../ClearCompiledTemplate/cache/.gitignore | 2 + .../templates/ambiguous/case1/foobar.tpl | 1 + .../templates/helloworld.tpl | 1 + .../templates/helloworld2.tpl | 1 + .../templates_2/ambiguous/case1/foobar.tpl | 1 + .../templates_2/dirname.tpl | 1 + .../templates_2/hello.tpl | 1 + .../templates_2/helloworld.php | 1 + .../templates_c/.gitignore | 2 + .../GetTemplateVars/GetTemplateVarsBCTest.php | 54 + .../GetTemplateVars/GetTemplateVarsTest.php | 112 ++ .../GetTemplateVars/cache/.gitignore | 2 + .../GetTemplateVars/templates_c/.gitignore | 2 + .../RegisterBlock/RegisterBlockTest.php | 312 ++++ .../RegisterBlock/cache/.gitignore | 2 + .../templates/test_register_block.tpl | 1 + .../RegisterBlock/templates_c/.gitignore | 2 + .../RegisterCompilerFunctionBCTest.php | 127 ++ .../RegisterCompilerFunctionTest.php | 124 ++ .../RegisterCompiler/cache/.gitignore | 2 + .../RegisterCompiler/templates_c/.gitignore | 2 + .../RegisterFunctionBCTest.php | 173 +++ .../RegisterFunction/RegisterFunctionTest.php | 169 ++ .../RegisterFunction/cache/.gitignore | 2 + .../templates/test_register_function.tpl | 1 + .../RegisterFunction/templates_c/.gitignore | 2 + .../RegisterModifier/RegisterModifierTest.php | 109 ++ .../RegisterModifier/cache/.gitignore | 2 + .../RegisterModifier/templates_c/.gitignore | 2 + .../CompileRegisteredObjectFunctionTest.php | 106 ++ .../RegisterObject/cache/.gitignore | 2 + .../RegisterObject/templates_c/.gitignore | 2 + .../TemplateExist/TemplateExistsTest.php | 43 + .../TemplateExist/cache/.gitignore | 2 + .../TemplateExist/templates/helloworld.tpl | 1 + .../TemplateExist/templates_c/.gitignore | 2 + .../TemplateSource/Comments/CommentsTest.php | 79 + .../TemplateSource/Comments/cache/.gitignore | 2 + .../Comments/templates/longcomment.tpl | 225 +++ .../Comments/templates_c/.gitignore | 2 + .../TemplateSource/Spacing/SpacingTest.php | 77 + .../TemplateSource/Spacing/cache/.gitignore | 2 + .../Spacing/templates_c/.gitignore | 2 + .../Spacing/templates_tmp/.gitignore | 2 + .../StaticClass/StaticClassAccessTest.php | 136 ++ .../StaticClass/cache/.gitignore | 2 + .../StaticClass/templates_c/.gitignore | 2 + .../TagTests/Append/CompileAppendTest.php | 149 ++ .../TagTests/Append/cache/.gitignore | 2 + .../TagTests/Append/templates_c/.gitignore | 2 + .../TagTests/Append/templates_tmp/.gitignore | 2 + .../TagTests/Assign/CompileAssignTest.php | 168 ++ .../TagTests/Assign/cache/.gitignore | 2 + .../Assign/templates/test_scope_assignbar.tpl | 1 + .../templates/test_scope_assignnocache.tpl | 1 + .../TagTests/Assign/templates_c/.gitignore | 2 + .../TagTests/Assign/templates_tmp/.gitignore | 2 + .../BlockPlugin/CompileBlockPluginTest.php | 531 +++++++ .../BlockPlugin/PHPunitplugins/block.noop.php | 24 + .../PHPunitplugins/block.nooutput.php | 24 + .../PHPunitplugins/block.testblock.php | 33 + .../PHPunitplugins/block.testparameter.php | 25 + .../PHPunitplugins/block.teststack.php | 25 + .../TagTests/BlockPlugin/cache/.gitignore | 2 + .../BlockPlugin/scripts/other_block_tag.php | 7 + .../BlockPlugin/scripts/script_block_tag.php | 7 + .../TagTests/BlockPlugin/templates/assign.tpl | 1 + .../BlockPlugin/templates/caching.tpl | 1 + .../BlockPlugin/templates/default1.tpl | 1 + .../BlockPlugin/templates/default2.tpl | 1 + .../TagTests/BlockPlugin/templates/nested.tpl | 1 + .../BlockPlugin/templates/no_assign.tpl | 1 + .../BlockPlugin/templates/nooutput.tpl | 1 + .../BlockPlugin/templates/registered.tpl | 1 + .../templates/registered_method.tpl | 1 + .../templates/registered_object.tpl | 1 + .../templates/registered_static.tpl | 1 + .../TagTests/BlockPlugin/templates/repeat.tpl | 1 + .../BlockPlugin/templates/repeat_modifier.tpl | 1 + .../templates/repeat_modifier_2.tpl | 1 + .../BlockPlugin/templates/tag_stack.tpl | 1 + .../BlockPlugin/templates/unknown.tpl | 1 + .../BlockPlugin/templates_c/.gitignore | 2 + .../BlockPlugin/templates_tmp/.gitignore | 2 + .../BockExtend/CompileBlockExtendsTest.php | 1382 +++++++++++++++++ .../TagTests/BockExtend/cache/.gitignore | 2 + .../BockExtend/templates/001_parent.tpl | 1 + .../BockExtend/templates/002_child.tpl | 2 + .../BockExtend/templates/002_parent.tpl | 2 + .../BockExtend/templates/003_child.tpl | 2 + .../BockExtend/templates/003_grand.tpl | 2 + .../BockExtend/templates/003_parent.tpl | 3 + .../BockExtend/templates/004_child.tpl | 2 + .../BockExtend/templates/004_grand.tpl | 2 + .../BockExtend/templates/004_grand2.tpl | 2 + .../BockExtend/templates/004_parent.tpl | 2 + .../BockExtend/templates/005_child.tpl | 2 + .../BockExtend/templates/005_parent.tpl | 2 + .../BockExtend/templates/006_child.tpl | 2 + .../BockExtend/templates/006_parent.tpl | 2 + .../BockExtend/templates/007_child.tpl | 2 + .../BockExtend/templates/007_grand.tpl | 2 + .../BockExtend/templates/007_parent.tpl | 2 + .../BockExtend/templates/008_child.tpl | 2 + .../BockExtend/templates/008_parent.tpl | 2 + .../BockExtend/templates/009_parent.tpl | 2 + .../BockExtend/templates/010_child.tpl | 2 + .../BockExtend/templates/010_parent.tpl | 2 + .../BockExtend/templates/011_child.tpl | 12 + .../BockExtend/templates/011_grand.tpl | 5 + .../BockExtend/templates/011_include.tpl | 1 + .../BockExtend/templates/011_parent.tpl | 2 + .../BockExtend/templates/012_child.tpl | 2 + .../BockExtend/templates/012_grand.tpl | 2 + .../BockExtend/templates/012_grandgrand.tpl | 2 + .../BockExtend/templates/012_parent.tpl | 2 + .../BockExtend/templates/018_child.tpl | 9 + .../BockExtend/templates/018_grand.tpl | 6 + .../BockExtend/templates/018_grandgrand.tpl | 6 + .../BockExtend/templates/018_parent.tpl | 2 + .../BockExtend/templates/020_include_1.tpl | 5 + .../BockExtend/templates/020_include_2.tpl | 5 + .../BockExtend/templates/020_include_3.tpl | 5 + .../templates/020_include_parent.tpl | 5 + .../BockExtend/templates/020_include_root.tpl | 5 + .../templates/020_include_subtemplate.tpl | 1 + .../BockExtend/templates/021_child.tpl | 2 + .../BockExtend/templates/021_grand.tpl | 2 + .../BockExtend/templates/021_parent.tpl | 1 + .../BockExtend/templates/022_child.tpl | 4 + .../BockExtend/templates/022_parent.tpl | 1 + .../BockExtend/templates/023_child.tpl | 8 + .../BockExtend/templates/023_parent.tpl | 9 + .../BockExtend/templates/024_parent.tpl | 1 + .../BockExtend/templates/025_parent.tpl | 1 + .../BockExtend/templates/026_child.tpl | 2 + .../BockExtend/templates/026_parent.tpl | 1 + .../BockExtend/templates/027_parent.tpl | 1 + .../BockExtend/templates/028_child.tpl | 4 + .../BockExtend/templates/028_parent.tpl | 2 + .../templates/028_parent_include1.tpl | 1 + .../templates/028_parent_include2.tpl | 1 + .../BockExtend/templates/029_child.tpl | 4 + .../BockExtend/templates/029_parent.tpl | 1 + .../BockExtend/templates/029_parent2.tpl | 1 + .../BockExtend/templates/030_child.tpl | 23 + .../BockExtend/templates/030_child_nested.tpl | 6 + .../BockExtend/templates/030_grandchild.tpl | 14 + .../templates/030_grandchild_nested.tpl | 2 + .../BockExtend/templates/030_include.tpl | 1 + .../BockExtend/templates/030_include_2.tpl | 6 + .../BockExtend/templates/030_parent.tpl | 2 + .../BockExtend/templates/031_post_filter.tpl | 1 + .../BockExtend/templates/032_child.tpl | 3 + .../templates/032_included_child.tpl | 3 + .../templates/032_included_parent.tpl | 2 + .../BockExtend/templates/032_parent.tpl | 2 + .../BockExtend/templates/033_grandchild.tpl | 2 + .../BockExtend/templates/034_1child.tpl | 2 + .../BockExtend/templates/034_2child.tpl | 2 + .../BockExtend/templates/034_3child.tpl | 2 + .../BockExtend/templates/034_4child.tpl | 2 + .../BockExtend/templates/034_parent.tpl | 2 + .../BockExtend/templates/035_1parent.tpl | 2 + .../BockExtend/templates/035_2parent.tpl | 2 + .../BockExtend/templates/035_3parent.tpl | 2 + .../BockExtend/templates/035_4parent.tpl | 2 + .../BockExtend/templates/035_child.tpl | 2 + .../BockExtend/templates/036_1_parent.tpl | 1 + .../BockExtend/templates/036_2_parent.tpl | 1 + .../BockExtend/templates/036_3_parent.tpl | 1 + .../BockExtend/templates/036_parent.tpl | 1 + .../BockExtend/templates/037_parent.tpl | 1 + .../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/helloworld.tpl | 1 + .../BockExtend/templates/include/include.tpl | 1 + .../templates/include/include/include.tpl | 1 + .../templates/sub/030_child_nested_rel.tpl | 6 + .../sub/030_grandchild_nested_rel.tpl | 2 + .../BockExtend/templates_c/.gitignore | 2 + .../templates_c/mustcompile/.gitignore | 2 + .../BockExtend/templates_tmp/.gitignore | 2 + .../TagTests/Capture/CompileCaptureTest.php | 149 ++ .../TagTests/Capture/cache/.gitignore | 2 + .../Capture/templates/009_capture.tpl | 3 + .../Capture/templates/009_capture_include.tpl | 2 + .../Capture/templates/010_capture.tpl | 4 + .../templates/test_capture_nocache.tpl | 2 + .../TagTests/Capture/templates_c/.gitignore | 2 + .../TagTests/Capture/templates_tmp/.gitignore | 2 + .../CompilerPlugin/CompilerPluginTest.php | 36 + .../PHPunitplugins/compiler.test.php | 28 + .../PHPunitplugins/compiler.testclose.php | 13 + .../TagTests/CompilerPlugin/cache/.gitignore | 2 + .../CompilerPlugin/templates_c/.gitignore | 2 + .../ConfigLoad/CompileConfigLoadTest.php | 172 ++ .../TagTests/ConfigLoad/cache/.gitignore | 2 + .../TagTests/ConfigLoad/configs/data.conf | 1 + .../TagTests/ConfigLoad/configs/smarty.conf | 1 + .../TagTests/ConfigLoad/configs/template.conf | 1 + .../TagTests/ConfigLoad/configs/test.conf | 53 + .../TagTests/ConfigLoad/configs/test2.conf | 5 + .../ConfigLoad/configs/test_error.conf | 15 + .../ConfigLoad/templates/001_section2.tpl | 1 + .../ConfigLoad/templates/002_section2.tpl | 1 + .../ConfigLoad/templates/003_include.tpl | 1 + .../ConfigLoad/templates/003_section2.tpl | 1 + .../ConfigLoad/templates/004_allsection.tpl | 1 + .../ConfigLoad/templates/005_overwrite.tpl | 1 + .../ConfigLoad/templates/0061_overwrite.tpl | 1 + .../ConfigLoad/templates/006_overwrite.tpl | 1 + .../ConfigLoad/templates/007_overwrite.tpl | 1 + .../ConfigLoad/templates/008_booleanize.tpl | 1 + .../ConfigLoad/templates/009_error.tpl | 1 + .../ConfigLoad/templates_c/.gitignore | 2 + .../Delimiter/CompileDelimiterTest.php | 55 + .../TagTests/Delimiter/cache/.gitignore | 2 + .../TagTests/Delimiter/templates_c/.gitignore | 2 + .../TagTests/Eval/CompileEvalTest.php | 48 + .../TagTests/Eval/cache/.gitignore | 2 + .../TagTests/Eval/templates_c/.gitignore | 2 + .../TagTests/For/CompileForTest.php | 200 +++ .../TagTests/For/cache/.gitignore | 2 + .../TagTests/For/templates_c/.gitignore | 2 + .../TagTests/For/templates_tmp/.gitignore | 2 + .../TagTests/Foreach/CompileForeachTest.php | 389 +++++ .../TagTests/Foreach/cache/.gitignore | 2 + .../Foreach/templates/024_foreach.tpl | 1 + .../Foreach/templates/025_foreach.tpl | 1 + .../Foreach/templates/026_foreach.tpl | 1 + .../Foreach/templates/027_foreach.tpl | 9 + .../Foreach/templates/028_foreach.tpl | 9 + .../Foreach/templates/029_foreach.tpl | 5 + .../Foreach/templates/030_foreach.tpl | 9 + .../Foreach/templates/031_foreach.tpl | 9 + .../Foreach/templates/032_foreach.tpl | 5 + .../Foreach/templates/033_foreach.tpl | 9 + .../Foreach/templates/034_foreach.tpl | 9 + .../Foreach/templates/035_foreach.tpl | 9 + .../Foreach/templates/036_foreach.tpl | 1 + .../Foreach/templates/037_foreach.tpl | 1 + .../TagTests/Foreach/templates_c/.gitignore | 2 + .../TagTests/Foreach/templates_tmp/.gitignore | 2 + .../CompileFunctionPluginTest.php | 62 + .../TagTests/FunctionPlugin/cache/.gitignore | 2 + .../templates/functionplugintest.tpl | 1 + .../templates/functionplugintestnocache.tpl | 1 + .../FunctionPlugin/templates_c/.gitignore | 2 + .../TagTests/If/CompileIfTest.php | 261 ++++ .../TagTests/If/cache/.gitignore | 2 + .../TagTests/If/templates_c/.gitignore | 2 + .../TagTests/If/templates_tmp/.gitignore | 2 + .../TagTests/Include/CompileIncludeTest.php | 327 ++++ .../TagTests/Include/cache/.gitignore | 2 + .../TagTests/Include/templates/helloworld.tpl | 1 + .../Include/templates/include_spacing1.tpl | 1 + .../Include/templates/include_spacing2.tpl | 1 + .../Include/templates/include_spacing3.tpl | 1 + .../Include/templates/test_include_001.tpl | 1 + .../Include/templates/test_include_001V2.tpl | 1 + .../Include/templates/test_include_001V3.tpl | 1 + .../Include/templates/test_include_001_2.tpl | 1 + .../templates/test_include_001_2V3.tpl | 1 + .../Include/templates/test_include_001_3.tpl | 1 + .../templates/test_include_assign1.tpl | 1 + .../templates/test_include_assign2.tpl | 1 + .../templates/test_include_pass_vars.tpl | 1 + .../templates/test_include_pass_vars2.tpl | 1 + .../templates/test_include_pass_vars2_sub.tpl | 1 + .../templates/test_include_standard.tpl | 1 + .../test_include_standard_nocache_var.tpl | 3 + .../templates/test_recursive_includes.tpl | 2 + .../templates/test_recursive_includes2.tpl | 2 + .../test_recursive_includes_pass.tpl | 1 + .../TagTests/Include/templates/test_scope.tpl | 1 + .../Include/templates/test_scope_assign.tpl | 1 + .../templates/test_scope_pluginassign.tpl | 1 + .../TagTests/Include/templates_c/.gitignore | 2 + .../TagTests/Include/templates_tmp/.gitignore | 2 + .../IncludePhp/CompileIncludePhpTest.php | 74 + .../TagTests/IncludePhp/cache/.gitignore | 2 + .../IncludePhp/scripts/test_include_php.php | 2 + .../IncludePhp/templates/include_php.tpl | 1 + .../templates/include_php_trusted.tpl | 1 + .../IncludePhp/templates_c/.gitignore | 2 + .../TagTests/Insert/CompileInsertTest.php | 268 ++++ .../insert.insertplugintest.php | 7 + .../Insert/PHPunitplugins/insert.test2.php | 6 + .../TagTests/Insert/cache/.gitignore | 2 + .../TagTests/Insert/templates/inner.tpl | 1 + .../Insert/templates/insertplugintest.tpl | 1 + .../Insert/templates/insertplugintest2.tpl | 2 + .../TagTests/Insert/templates_c/.gitignore | 2 + .../TagTests/Insert/templates_tmp/.gitignore | 2 + .../TagTests/Literal/LiteralTest.php | 67 + .../TagTests/Literal/cache/.gitignore | 2 + .../TagTests/Literal/templates_c/.gitignore | 2 + .../MakeNocache/CompileMakeNocacheTest.php | 309 ++++ .../TagTests/MakeNocache/cache/.gitignore | 2 + .../MakeNocache/templates/001_test_foo.tpl | 1 + .../templates/001_test_foo_assign.tpl | 1 + .../templates/001_test_foo_foreach.tpl | 3 + .../MakeNocache/templates/001_test_foo_if.tpl | 1 + .../templates/002_test_backslash.tpl | 1 + .../MakeNocache/templates/003_test_spaces.tpl | 1 + .../MakeNocache/templates_c/.gitignore | 2 + .../TagTests/Nocache/CompileNocacheTest.php | 75 + .../TagTests/Nocache/cache/.gitignore | 2 + .../Nocache/templates/test_nocache_tag.tpl | 2 + .../templates/test_nocache_tag_include.tpl | 1 + .../TagTests/Nocache/templates_c/.gitignore | 2 + .../TagTests/Php/CompilePhpTest.php | 198 +++ .../Php/PHPunitplugins/function.phptest.php | 5 + .../TagTests/Php/cache/.gitignore | 2 + .../TagTests/Php/templates/asp.tpl | 4 + .../TagTests/Php/templates/php.tpl | 5 + .../TagTests/Php/templates/php2.tpl | 4 + .../Php/templates/php_block_comment.tpl | 16 + .../Php/templates/php_line_comment.tpl | 12 + .../TagTests/Php/templates/phptag.tpl | 5 + .../Php/templates/phptag_block_comment.tpl | 16 + .../Php/templates/phptag_line_comment.tpl | 12 + .../TagTests/Php/templates/phptag_literal.tpl | 5 + .../TagTests/Php/templates/phptag_nocache.tpl | 2 + .../TagTests/Php/templates/script.tpl | 1 + .../TagTests/Php/templates_c/.gitignore | 2 + .../PluginBlock/PluginBlockTextformatTest.php | 136 ++ .../TagTests/PluginBlock/cache/.gitignore | 2 + .../PluginBlock/templates_c/.gitignore | 2 + .../PluginFunctionFetchTest.php | 85 + .../PluginFunctionHtmlCheckboxesTest.php | 415 +++++ .../PluginFunctionHtmlImageTest.php | 27 + .../PluginFunctionHtmlOptionsTest.php | 502 ++++++ .../PluginFunctionHtmlRadiosTest.php | 410 +++++ .../PluginFunctionHtmlSelectDateTest.php | 604 +++++++ .../PluginFunctionHtmlSelectTimeTest.php | 1151 ++++++++++++++ .../PluginFunctionMailtoTest.php | 166 ++ .../TagTests/PluginFunction/cache/.gitignore | 2 + .../helpers/_object_tostring.php | 26 + .../PluginFunction/templates_c/.gitignore | 2 + .../PluginModifierCapitalizeTest.php | 153 ++ .../PluginModifierCharsetTest.php | 98 ++ .../PluginModifierCountCharactersTest.php | 90 ++ .../PluginModifierCountSentencesTest.php | 63 + .../PluginModifierCountWordsTest.php | 70 + .../PluginModifierEscapeTest.php | 210 +++ .../PluginModifierLowerTest.php | 53 + .../PluginModifierRegexReplaceTest.php | 45 + .../PluginModifierSpacifyTest.php | 36 + .../PluginModifierStripTest.php | 44 + .../PluginModifierTruncateTest.php | 134 ++ .../PluginModifierUnescapeTest.php | 68 + .../PluginModifierUpperTest.php | 54 + .../PluginModifierWordwrapTest.php | 163 ++ .../TagTests/PluginModifier/cache/.gitignore | 2 + .../PluginModifier/templates_c/.gitignore | 2 + .../TagTests/Section/CompileSectionTest.php | 151 ++ .../TagTests/Section/cache/.gitignore | 2 + .../Section/templates/001_section.tpl | 1 + .../Section/templates/002_section.tpl | 1 + .../Section/templates/003_section.tpl | 1 + .../Section/templates/004_section.tpl | 1 + .../Section/templates/006_section.tpl | 1 + .../Section/templates/007_section.tpl | 1 + .../TagTests/Section/templates_c/.gitignore | 2 + .../TagTests/Section/templates_tmp/.gitignore | 2 + .../SetFilter/CompileSetfilterTest.php | 57 + .../TagTests/SetFilter/cache/.gitignore | 2 + .../TagTests/SetFilter/templates_c/.gitignore | 2 + .../TagTests/Strip/CompileStripTest.php | 83 + .../TagTests/Strip/templates_c/.gitignore | 2 + .../TagTests/Strip/templates_tmp/.gitignore | 2 + .../TemplateFunction/CompileFunctionTest.php | 435 ++++++ .../TemplateFunction/cache/.gitignore | 2 + .../templates/CachingTests/nocache_lib.tpl | 6 + .../templates/CachingTests/test0.tpl | 4 + .../templates/CachingTests/test1.tpl | 7 + .../templates/CachingTests/test2.tpl | 3 + .../templates/CachingTests/test3.tpl | 4 + .../templates/CachingTests/test4.tpl | 3 + .../templates/CachingTests/test5.tpl | 4 + .../templates/CachingTests/test6.tpl | 8 + .../templates/CachingTests/test7.tpl | 2 + .../templates/simple_function_lib.tpl | 1 + .../templates/template_function_lib.tpl | 1 + .../templates/test_define_function_tag.tpl | 1 + .../templates/test_inherit_function_tag.tpl | 1 + .../templates/test_inherit_function_tag6.tpl | 1 + .../templates/test_template_function.tpl | 1 + .../templates/test_template_function_001.tpl | 1 + .../templates/test_template_function_002.tpl | 1 + .../templates/test_template_function_003.tpl | 1 + .../test_template_function_assign_001.tpl | 1 + .../templates/test_template_function_call.tpl | 1 + .../test_template_function_nocache_call.tpl | 1 + .../test_template_function_recursion1.tpl | 20 + .../test_template_function_recursion2.tpl | 10 + .../templates/test_template_function_tag2.tpl | 1 + .../templates/test_template_function_tag4.tpl | 1 + .../templates/test_template_function_tag5.tpl | 1 + .../templates/test_template_function_tag6.tpl | 1 + .../TemplateFunction/templates_c/.gitignore | 2 + .../TemplateFunction/templates_tmp/.gitignore | 2 + .../TagTests/While/CompileWhileTest.php | 154 ++ .../TagTests/While/cache/.gitignore | 2 + .../TagTests/While/templates_c/.gitignore | 2 + .../TagTests/While/templates_tmp/.gitignore | 2 + .../TagTests/_Attributes/AttributeTest.php | 79 + .../TagTests/_Attributes/cache/.gitignore | 2 + .../_Attributes/templates_c/.gitignore | 2 + .../TagTests/_Error/CompileErrorTest.php | 67 + .../TagTests/_Error/cache/.gitignore | 2 + .../TagTests/_Error/templates_c/.gitignore | 2 + .../TagTests/_Print/PrintTest.php | 108 ++ .../TagTests/_Print/cache/.gitignore | 2 + .../TagTests/_Print/templates_c/.gitignore | 2 + .../TagTests/_Print/templates_tmp/.gitignore | 2 + .../TagTests/break/CompileBreakTest.php | 45 + .../TagTests/break/cache/.gitignore | 2 + .../break/templates/break_foreach.tpl | 7 + .../TagTests/break/templates_c/.gitignore | 2 + .../ValueTests/Array/ArrayTest.php | 75 + .../ValueTests/Array/cache/.gitignore | 2 + .../ValueTests/Array/templates_c/.gitignore | 2 + .../ValueTests/Array/templates_tmp/.gitignore | 2 + .../ValueTests/BoolenNull/BooleanNullTest.php | 51 + .../ValueTests/BoolenNull/cache/.gitignore | 2 + .../BoolenNull/templates/.gitignore | 2 + .../BoolenNull/templates_c/.gitignore | 2 + .../ConstantTests/ConstantsTest.php | 89 ++ .../ValueTests/ConstantTests/cache/.gitignore | 2 + .../ConstantTests/templates_c/.gitignore | 2 + .../DoubleQuoted/DoubleQuotedStringTest.php | 105 ++ .../ValueTests/DoubleQuoted/cache/.gitignore | 2 + .../templates/001_closedBlock.tpl | 1 + .../templates/001_unclosedBlock.tpl | 1 + .../DoubleQuoted/templates_c/.gitignore | 2 + .../DoubleQuoted/templates_tmp/.gitignore | 2 + .../ValueTests/Math/MathTest.php | 110 ++ .../ValueTests/Math/cache/.gitignore | 2 + .../ValueTests/Math/templates_c/.gitignore | 2 + .../ValueTests/Modifier/ModifierTest.php | 135 ++ .../ValueTests/Modifier/cache/.gitignore | 2 + .../templates/testModifier_Default.tpl | 1 + .../testModifier_RegisteredMethod.tpl | 1 + .../testModifier_RegisteredStatic.tpl | 1 + .../Modifier/templates_c/.gitignore | 2 + .../Modifier/templates_tmp/.gitignore | 2 + .../ValueTests/Objects/ObjectVariableTest.php | 106 ++ .../ValueTests/Objects/cache/.gitignore | 2 + .../Objects/templates/hello_world_test.tpl | 1 + .../ValueTests/Objects/templates_c/.gitignore | 2 + .../PHPfunctions/PhpFunctionTest.php | 186 +++ .../ValueTests/PHPfunctions/cache/.gitignore | 2 + .../PHPfunctions/templates_c/.gitignore | 2 + .../SingleQouted/SingleQuotedStringTest.php | 81 + .../ValueTests/SingleQouted/cache/.gitignore | 2 + .../SingleQouted/templates_c/.gitignore | 2 + .../Constant/SmartyConstantTest.php | 45 + .../Constant/cache/.gitignore | 2 + .../Constant/templates/constant.tpl | 1 + .../Constant/templates/constant_variable.tpl | 1 + .../Constant/templates_c/.gitignore | 2 + .../SmartySpecialVars/Cookie/CookieTest.php | 84 + .../SmartySpecialVars/Cookie/cache/.gitignore | 2 + .../Cookie/templates/cookie.tpl | 1 + .../Cookie/templates/cookie_modifier.tpl | 1 + .../Cookie/templates/cookie_variable.tpl | 1 + .../Cookie/templates_c/.gitignore | 2 + .../Delimiter/SmartyDelimiterTest.php | 34 + .../Delimiter/cache/.gitignore | 2 + .../Delimiter/templates/delimiter.tpl | 1 + .../Delimiter/templates_c/.gitignore | 2 + .../Error/SmartyErrorTest.php | 36 + .../SmartySpecialVars/Error/cache/.gitignore | 2 + .../Error/templates/error.tpl | 1 + .../Error/templates_c/.gitignore | 2 + .../SmartySpecialVars/Now/SmartyNowTest.php | 50 + .../SmartySpecialVars/Now/cache/.gitignore | 2 + .../SmartySpecialVars/Now/templates/now.tpl | 1 + .../Now/templates/now_nocache.tpl | 1 + .../Now/templates_c/.gitignore | 2 + .../SmartySpecialVars/Post/PostTest.php | 84 + .../SmartySpecialVars/Post/cache/.gitignore | 2 + .../SmartySpecialVars/Post/templates/post.tpl | 1 + .../Post/templates/post_modifier.tpl | 1 + .../Post/templates/post_variable.tpl | 1 + .../Post/templates_c/.gitignore | 2 + .../SmartyTemplateObjectTest.php | 34 + .../TemplateObject/cache/.gitignore | 2 + .../templates/template_object.tpl | 1 + .../TemplateObject/templates_c/.gitignore | 2 + .../Version/SmartyVersionTest.php | 34 + .../Version/cache/.gitignore | 2 + .../Version/templates/version.tpl | 1 + .../Version/templates_c/.gitignore | 2 + .../Variables/Stream/StreamVariableTest.php | 137 ++ .../Variables/Stream/cache/.gitignore | 2 + .../Variables/Stream/templates_c/.gitignore | 2 + .../VariableVariable/VariableVariableTest.php | 63 + .../VariableVariable/cache/.gitignore | 2 + .../VariableVariable/templates_c/.gitignore | 2 + .../TemplateSource/X_Scopes/ScopeTest.php | 299 ++++ .../TemplateSource/X_Scopes/cache/.gitignore | 2 + .../TemplateSource/X_Scopes/configs/data.conf | 1 + .../X_Scopes/configs/smarty.conf | 1 + .../X_Scopes/configs/template.conf | 1 + .../templates/test_function_scope.tpl | 35 + .../templates/test_function_scope_include.tpl | 2 + .../X_Scopes/templates/test_scope.tpl | 1 + .../X_Scopes/templates/test_scope_assign.tpl | 1 + .../templates/test_scope_assign_noscope.tpl | 1 + .../templates/test_scope_assignbar.tpl | 1 + .../templates/test_scope_assignnocache.tpl | 1 + .../templates/test_scope_pluginassign.tpl | 1 + .../X_Scopes/templates_c/.gitignore | 2 + .../X_Scopes/templates_tmp/.gitignore | 2 + .../UnitTests/TemplateSource/Xml/XmlTest.php | 137 ++ .../TemplateSource/Xml/cache/.gitignore | 2 + .../TemplateSource/Xml/templates/xml.tpl | 1 + .../TemplateSource/Xml/templates/xml_main.tpl | 1 + .../TemplateSource/Xml/templates/xmlvar.tpl | 1 + .../TemplateSource/Xml/templates_c/.gitignore | 2 + .../_Issues/327/ModifierIssue327Test.php | 33 + .../_Issues/327/cache/.gitignore | 2 + .../_Issues/327/templates_c/.gitignore | 2 + .../_Issues/419/ExtendsIssue419Test.php | 35 + .../_Issues/419/cache/.gitignore | 2 + .../_Issues/419/templates/001_child.tpl | 1 + .../_Issues/419/templates/001_parent.tpl | 1 + .../_Issues/419/templates_c/.gitignore | 2 + .../_Issues/422/NestedLoopIssue422Test.php | 35 + .../_Issues/422/cache/.gitignore | 2 + .../_Issues/422/templates/422_test.tpl | 8 + .../_Issues/422/templates_c/.gitignore | 2 + ...ctionPropertiesShortSyntaxIssue428Test.php | 42 + .../_Issues/428/cache/.gitignore | 2 + .../_Issues/428/templates/001_section.tpl | 1 + .../_Issues/428/templates/002_section.tpl | 1 + .../_Issues/428/templates_c/.gitignore | 2 + .../_Issues/topic26878/NewlineSpacing.php | 69 + .../_Issues/topic26878/cache/.gitignore | 2 + .../_Issues/topic26878/templates_c/.gitignore | 2 + .../topic26878/templates_tmp/.gitignore | 2 + .../PHPunitplugins/block.dummyblock.php | 23 + .../compiler.getparamsshort.php | 56 + .../function.checkconfigvar.php | 45 + .../PHPunitplugins/function.checkvar.php | 56 + .../PHPunitplugins/function.getparams.php | 20 + .../PHPunitplugins/function.getvar.php | 24 + .../PHPunitplugins/function.pluginassign.php | 21 + .../UnitTests/__shared/templates/run_code.tpl | 1 + .../__shared/templates/run_code_caching.tpl | 1 + .../__shared/templates/scope_include.tpl | 1 + .../__shared/templates/scope_tag.tpl | 1 + tests/cache/.gitignore | 2 + tests/templates_c/.gitignore | 2 + 875 files changed, 26924 insertions(+), 6 deletions(-) create mode 100644 TODO.md create mode 100755 phpunit.sh create mode 100644 phpunit.xml create mode 100644 tests/.gitignore create mode 100644 tests/Bootstrap.php create mode 100644 tests/Config.php create mode 100644 tests/Include_Path/Plugins/include/function.plugin1.php create mode 100644 tests/Include_Path/Plugins/include1/function.plugin2.php create mode 100644 tests/Include_Path/Tpl/include/include_test2.tpl create mode 100644 tests/Include_Path/Tpl/include/include_test4.tpl create mode 100644 tests/Include_Path/Tpl/templates_2/test4.tpl create mode 100644 tests/Include_Path/Tpl/test5.tpl create mode 100644 tests/PHPUnit_Smarty.php create mode 100644 tests/UnitTests/A_0/PathNormalization/PathNormalizationTest.php create mode 100644 tests/UnitTests/A_0/PathNormalization/PluginDirNormalizationTest.php create mode 100644 tests/UnitTests/A_0/PathNormalization/TemlateDirNormalizationTest.php create mode 100644 tests/UnitTests/A_0/PathNormalization/cache/.gitignore create mode 100644 tests/UnitTests/A_0/PathNormalization/templates_c/.gitignore create mode 100644 tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php create mode 100644 tests/UnitTests/A_1/ProtectedFolderVars/cache/.gitignore create mode 100644 tests/UnitTests/A_1/ProtectedFolderVars/comp/.gitignore create mode 100644 tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php create mode 100644 tests/UnitTests/A_2/UndefinedTemplateVar/cache/.gitignore create mode 100644 tests/UnitTests/A_2/UndefinedTemplateVar/templates/001_include.tpl create mode 100644 tests/UnitTests/A_2/UndefinedTemplateVar/templates/001_main.tpl create mode 100644 tests/UnitTests/A_2/UndefinedTemplateVar/templates_c/.gitignore create mode 100644 tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php create mode 100644 tests/UnitTests/A_Core/AutoEscape/cache/.gitignore create mode 100644 tests/UnitTests/A_Core/AutoEscape/templates_c/.gitignore create mode 100644 tests/UnitTests/A_Core/Filter/FilterClosure.php create mode 100644 tests/UnitTests/A_Core/Filter/FilterTest.php create mode 100644 tests/UnitTests/A_Core/Filter/LoadFilterTest.php create mode 100644 tests/UnitTests/A_Core/Filter/RegisterFilterTest.php create mode 100644 tests/UnitTests/A_Core/Filter/cache/.gitignore create mode 100644 tests/UnitTests/A_Core/Filter/templates/output_001.tpl create mode 100644 tests/UnitTests/A_Core/Filter/templates/output_002.tpl create mode 100644 tests/UnitTests/A_Core/Filter/templates_c/.gitignore create mode 100644 tests/UnitTests/A_Core/GetterSetter/GetterSetterTest.php create mode 100644 tests/UnitTests/A_Core/GetterSetter/cache/.gitignore create mode 100644 tests/UnitTests/A_Core/GetterSetter/templates_c/.gitignore create mode 100644 tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php create mode 100644 tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php create mode 100644 tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php create mode 100644 tests/UnitTests/A_Core/LoadPlugin/cache/.gitignore create mode 100644 tests/UnitTests/A_Core/LoadPlugin/include/function.plugin3.php create mode 100644 tests/UnitTests/A_Core/LoadPlugin/scripts/script_block_tag.php create mode 100644 tests/UnitTests/A_Core/LoadPlugin/scripts/script_compiler_function_tag.php create mode 100644 tests/UnitTests/A_Core/LoadPlugin/scripts/script_default_static_modifier.php create mode 100644 tests/UnitTests/A_Core/LoadPlugin/scripts/script_function_tag.php create mode 100644 tests/UnitTests/A_Core/LoadPlugin/scripts/script_modifier.php create mode 100644 tests/UnitTests/A_Core/LoadPlugin/scripts/test_include_php.php create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_default_block_script.tpl create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_default_compiler_function_script.tpl create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_default_compiler_object.tpl create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_default_function_local.tpl create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_default_function_script.tpl create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_default_function_script_notcachable.tpl create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_default_modifier.tpl create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_default_modifier_script.tpl create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates/test_default_static_modifier.tpl 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 create mode 100644 tests/UnitTests/A_Core/LoadPlugin/templates_c/.gitignore create mode 100644 tests/UnitTests/A_Core/MuteExpectedErrors/MuteExpectedErrorsTest.php create mode 100644 tests/UnitTests/A_Core/MuteExpectedErrors/cache/.gitignore create mode 100644 tests/UnitTests/A_Core/MuteExpectedErrors/templates/default.tpl create mode 100644 tests/UnitTests/A_Core/MuteExpectedErrors/templates_c/.gitignore create mode 100644 tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain1.php create mode 100644 tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain2.php create mode 100644 tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain3.php create mode 100644 tests/UnitTests/A_Core/PluginTests/PluginChainedLoadTest.php create mode 100644 tests/UnitTests/A_Core/PluginTests/Shared/SharedFunctionsTest.php create mode 100644 tests/UnitTests/A_Core/PluginTests/Shared/cache/.gitignore create mode 100644 tests/UnitTests/A_Core/PluginTests/Shared/templates_c/.gitignore create mode 100644 tests/UnitTests/A_Core/PluginTests/cache/.gitignore create mode 100644 tests/UnitTests/A_Core/PluginTests/helpers/_object_tostring.php create mode 100644 tests/UnitTests/A_Core/PluginTests/templates/test_plugin_chained_load.tpl create mode 100644 tests/UnitTests/A_Core/PluginTests/templates_c/.gitignore create mode 100644 tests/UnitTests/A_Core/SmartyBC/SmartyBcTest.php create mode 100644 tests/UnitTests/A_Core/SmartyBC/cache/.gitignore create mode 100644 tests/UnitTests/A_Core/SmartyBC/templates_c/.gitignore create mode 100644 tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php create mode 100644 tests/UnitTests/CacheModify/ModifiedSince/cache/.gitignore create mode 100644 tests/UnitTests/CacheModify/ModifiedSince/templates/helloworld.tpl create mode 100644 tests/UnitTests/CacheModify/ModifiedSince/templates_c/.gitignore create mode 100644 tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php create mode 100644 tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php create mode 100644 tests/UnitTests/CacheResourceTests/File/cache/.gitignore create mode 100644 tests/UnitTests/CacheResourceTests/File/templates_c/.gitignore create mode 100644 tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php create mode 100644 tests/UnitTests/CacheResourceTests/Memcache/templates_c/.gitignore create mode 100644 tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php create mode 100644 tests/UnitTests/CacheResourceTests/Mysql/cache/.gitignore create mode 100644 tests/UnitTests/CacheResourceTests/Mysql/templates_c/.gitignore create mode 100644 tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php create mode 100644 tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php create mode 100644 tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php create mode 100644 tests/UnitTests/CacheResourceTests/Registered/templates_c/.gitignore create mode 100644 tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php create mode 100644 tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php create mode 100644 tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php create mode 100644 tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.memcachetest.php create mode 100644 tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.mysqltest.php create mode 100644 tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdo_gziptest.php create mode 100644 tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdotest.php create mode 100644 tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php create mode 100644 tests/UnitTests/CacheResourceTests/_shared/templates/a/include.tpl create mode 100644 tests/UnitTests/CacheResourceTests/_shared/templates/b/include.tpl create mode 100644 tests/UnitTests/CacheResourceTests/_shared/templates/cacheresource.tpl create mode 100644 tests/UnitTests/CacheResourceTests/_shared/templates/helloworld.tpl create mode 100644 tests/UnitTests/CacheResourceTests/_shared/templates/helloworld2.tpl create mode 100644 tests/UnitTests/CacheResourceTests/_shared/templates/templatedir.tpl create mode 100644 tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php create mode 100644 tests/UnitTests/Compiler/CompilerPlugin/cache/.gitignore create mode 100644 tests/UnitTests/Compiler/CompilerPlugin/templates/compilerplugintest.tpl create mode 100644 tests/UnitTests/Compiler/CompilerPlugin/templates_c/.gitignore create mode 100644 tests/UnitTests/Compiler/Delimiter/AutoLiteralTest.php create mode 100644 tests/UnitTests/Compiler/Delimiter/DelimiterTest.php create mode 100644 tests/UnitTests/Compiler/Delimiter/UserLiteralTest.php create mode 100644 tests/UnitTests/Compiler/Delimiter/cache/.gitignore create mode 100644 tests/UnitTests/Compiler/Delimiter/templates/autoliteral.tpl create mode 100644 tests/UnitTests/Compiler/Delimiter/templates/autoliteralblock.tpl create mode 100644 tests/UnitTests/Compiler/Delimiter/templates/autoliteraldoublequote.tpl create mode 100644 tests/UnitTests/Compiler/Delimiter/templates/autoliteraldoublequote2.tpl create mode 100644 tests/UnitTests/Compiler/Delimiter/templates/userliteral.tpl create mode 100644 tests/UnitTests/Compiler/Delimiter/templates/userliteral1.tpl create mode 100644 tests/UnitTests/Compiler/Delimiter/templates/userliteral2.tpl create mode 100644 tests/UnitTests/Compiler/Delimiter/templates/userliteraldoublequote.tpl create mode 100644 tests/UnitTests/Compiler/Delimiter/templates_c/.gitignore create mode 100644 tests/UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php create mode 100644 tests/UnitTests/ConfigFileTests/defaultHandler/configs/test.conf create mode 100644 tests/UnitTests/ConfigFileTests/defaultHandler/templates/foo.tpl create mode 100644 tests/UnitTests/ConfigFileTests/defaultHandler/templates/number.tpl create mode 100644 tests/UnitTests/ConfigFileTests/defaultHandler/templates_c/.gitignore create mode 100644 tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php create mode 100644 tests/UnitTests/ConfigFileTests/file/PHPunitplugins/resource.db4.php create mode 100644 tests/UnitTests/ConfigFileTests/file/configs/test.conf create mode 100644 tests/UnitTests/ConfigFileTests/file/templates/foo.tpl create mode 100644 tests/UnitTests/ConfigFileTests/file/templates/hidden.tpl create mode 100644 tests/UnitTests/ConfigFileTests/file/templates/number.tpl create mode 100644 tests/UnitTests/ConfigFileTests/file/templates/sec.tpl create mode 100644 tests/UnitTests/ConfigFileTests/file/templates/sec1sec2.tpl create mode 100644 tests/UnitTests/ConfigFileTests/file/templates/text.tpl create mode 100644 tests/UnitTests/ConfigFileTests/file/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php create mode 100644 tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php create mode 100644 tests/UnitTests/ResourceTests/Custom/Ambiguous/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Custom/Ambiguous/resource.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/Ambiguous/templates/ambiguous/case1/foobar.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/Ambiguous/templates/ambiguous/case2/foobar.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/Ambiguous/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall2.tpl 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_2/helloworld.php create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_3/data1.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_3/extendsall.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_4/extendsall.tpl create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/PHPunitplugins/resource.mysqlstest.php create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/PHPunitplugins/resource.mysqltest.php create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/DefaultHandler/DefaultTemplateHandlerTest.php create mode 100644 tests/UnitTests/ResourceTests/DefaultHandler/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/DefaultHandler/templates/helloworld.tpl create mode 100644 tests/UnitTests/ResourceTests/DefaultHandler/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php create mode 100644 tests/UnitTests/ResourceTests/Eval/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Eval/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php create mode 100644 tests/UnitTests/ResourceTests/Extends/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/003_child_prepend.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/003_parent.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/004_child_append.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/004_parent.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/021_child.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/021_grandchild.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/021_parent.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/022_child.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/033_grandchild.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/034_child.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/034_grandchild.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/034_parent.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/040_child.tpl create mode 100644 tests/UnitTests/ResourceTests/Extends/templates/040_parent.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/ResourceTests/Extends/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/File/FileResourceTest.php create mode 100644 tests/UnitTests/ResourceTests/File/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/File/templates/001_smarty_current_dir.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/001_smarty_template.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/helloworld.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/relative.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/relative_notexist.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/relative_sub.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/relativity/foo.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/relativity/relativity.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/relativity/theory/einstein/einstein.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/relativity/theory/einstein/foo.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/relativity/theory/foo.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/relativity/theory/theory.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates/sub/relative.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates_2/hello.tpl create mode 100644 tests/UnitTests/ResourceTests/File/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/include_test3.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/templates/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/templates/test1.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/templates/test2.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/templates/test3.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/templates_2/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/templates_2/include_test1.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/templates_3/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/templates_4/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIncludePath/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/FileResourceIndexedTest.php create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/templates/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname1.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname_x.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/templates_3/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/templates_3/dirname10.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname_foo.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname_x.tpl create mode 100644 tests/UnitTests/ResourceTests/FileIndexed/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Php/PhpResourceTest.php create mode 100644 tests/UnitTests/ResourceTests/Php/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Php/templates/includephp.tpl create mode 100644 tests/UnitTests/ResourceTests/Php/templates/phphelloworld.php create mode 100644 tests/UnitTests/ResourceTests/Php/templates_2/helloworld.php create mode 100644 tests/UnitTests/ResourceTests/Php/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Registered/RegisteredResourceTest.php create mode 100644 tests/UnitTests/ResourceTests/Registered/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Registered/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db.php create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db2.php create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db3.php create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db4.php create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/ResourcePluginTest.php create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/templates/extendsall.tpl create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/templates/extendsall2.tpl create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/ambiguous/case1/foobar.tpl create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/hello.tpl create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/helloworld.php create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/templates_3/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/templates_3/extendsall.tpl create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/templates_4/dirname.tpl create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/templates_4/extendsall.tpl create mode 100644 tests/UnitTests/ResourceTests/ResourcePlugins/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php create mode 100644 tests/UnitTests/ResourceTests/Stream/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/Stream/templates_c/.gitignore create mode 100644 tests/UnitTests/ResourceTests/String/StringResourceTest.php create mode 100644 tests/UnitTests/ResourceTests/String/cache/.gitignore create mode 100644 tests/UnitTests/ResourceTests/String/templates_c/.gitignore create mode 100644 tests/UnitTests/SecurityTests/FunctionTest.php create mode 100644 tests/UnitTests/SecurityTests/SecurityTest.php create mode 100644 tests/UnitTests/SecurityTests/cache/.gitignore create mode 100644 tests/UnitTests/SecurityTests/templates/helloworld.tpl create mode 100644 tests/UnitTests/SecurityTests/templates_2/hello.tpl create mode 100644 tests/UnitTests/SecurityTests/templates_3/dirname.tpl create mode 100644 tests/UnitTests/SecurityTests/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/Append/AppendTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/Append/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/Append/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefBCTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/AppendByRef/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/AppendByRef/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/Assign/AssignTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/Assign/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/Assign/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefBCTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/AssignByRef/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/AssignByRef/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/AssignGlobal/AssignGlobalTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/AssignGlobal/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/AssignGlobal/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignBCTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearAllAssign/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearAllAssign/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignBCTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearAssign/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearAssign/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledBCTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/ambiguous/case1/foobar.tpl create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/helloworld.tpl create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/helloworld2.tpl create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/ambiguous/case1/foobar.tpl create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/dirname.tpl create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/hello.tpl create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/helloworld.php create mode 100644 tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsBCTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/GetTemplateVars/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/GetTemplateVars/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterBlock/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterBlock/templates/test_register_block.tpl create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterBlock/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionBCTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterCompiler/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterCompiler/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionBCTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterFunction/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterFunction/templates/test_register_function.tpl create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterFunction/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterModifier/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterModifier/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterObject/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/RegisterObject/templates_c/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/TemplateExist/TemplateExistsTest.php create mode 100644 tests/UnitTests/SmartyMethodsTests/TemplateExist/cache/.gitignore create mode 100644 tests/UnitTests/SmartyMethodsTests/TemplateExist/templates/helloworld.tpl create mode 100644 tests/UnitTests/SmartyMethodsTests/TemplateExist/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/Comments/CommentsTest.php create mode 100644 tests/UnitTests/TemplateSource/Comments/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/Comments/templates/longcomment.tpl create mode 100644 tests/UnitTests/TemplateSource/Comments/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/Spacing/SpacingTest.php create mode 100644 tests/UnitTests/TemplateSource/Spacing/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/Spacing/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/Spacing/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/StaticClass/StaticClassAccessTest.php create mode 100644 tests/UnitTests/TemplateSource/StaticClass/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/StaticClass/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Append/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Append/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Append/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Assign/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignbar.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignnocache.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Assign/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Assign/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.noop.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.nooutput.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.testblock.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.testparameter.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.teststack.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/scripts/other_block_tag.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/scripts/script_block_tag.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/assign.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/caching.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/default1.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/default2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/nested.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/registered_method.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_object.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_static.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 create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/tag_stack.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/unknown.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/001_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_grand.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_grand.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/009_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_grand.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_include.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grand.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grandgrand.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grand.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grandgrand.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_1.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_3.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_root.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_subtemplate.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_grand.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/024_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/025_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/027_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include1.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child_nested.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild_nested.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include_2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/031_post_filter.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/033_grandchild.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_1child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_2child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_3child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_4child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_1parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_2parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_3parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_4parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_1_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_2_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_3_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/037_parent.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/helloworld.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 create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_child_nested_rel.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_grandchild_nested_rel.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/mustcompile/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Capture/CompileCaptureTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Capture/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture_include.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Capture/templates/010_capture.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Capture/templates/test_capture_nocache.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Capture/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Capture/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/CompilerPluginTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.testclose.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/data.conf create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/smarty.conf create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/template.conf create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test.conf create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test2.conf create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test_error.conf create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/001_section2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/002_section2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_include.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_section2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/004_allsection.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/005_overwrite.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/0061_overwrite.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/006_overwrite.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/007_overwrite.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/008_booleanize.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/009_error.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Delimiter/CompileDelimiterTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Delimiter/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Delimiter/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Eval/CompileEvalTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Eval/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Eval/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/For/CompileForTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/For/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/For/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/For/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/024_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/025_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/026_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/027_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/028_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/029_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/030_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/031_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/032_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/033_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/034_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/035_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/036_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/037_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintest.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintestnocache.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/If/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/If/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/If/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/helloworld.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing1.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing3.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V3.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2V3.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_3.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign1.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2_sub.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard_nocache_var.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes_pass.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_assign.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_pluginassign.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Include/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/IncludePhp/CompileIncludePhpTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/IncludePhp/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/IncludePhp/scripts/test_include_php.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates/include_php.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates/include_php_trusted.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.insertplugintest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.test2.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/templates/inner.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Literal/LiteralTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Literal/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Literal/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/MakeNocache/CompileMakeNocacheTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/MakeNocache/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_assign.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_if.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/002_test_backslash.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/003_test_spaces.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Nocache/CompileNocacheTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Nocache/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag_include.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Nocache/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/CompilePhpTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/PHPunitplugins/function.phptest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates/asp.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates/php.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates/php2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates/php_block_comment.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates/php_line_comment.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_block_comment.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_line_comment.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_literal.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_nocache.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates/script.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Php/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginBlock/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginBlock/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlImageTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectTimeTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginFunction/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginFunction/helpers/_object_tostring.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginFunction/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierSpacifyTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Section/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Section/templates/001_section.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Section/templates/002_section.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Section/templates/003_section.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Section/templates/004_section.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Section/templates/006_section.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Section/templates/007_section.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Section/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Section/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/SetFilter/CompileSetfilterTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/SetFilter/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/SetFilter/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/Strip/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/Strip/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/nocache_lib.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test0.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test1.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test3.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test4.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test5.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test6.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test7.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/simple_function_lib.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/template_function_lib.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_define_function_tag.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag6.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_001.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_002.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_003.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_assign_001.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_call.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_nocache_call.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion1.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag4.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag5.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag6.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/While/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/While/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/While/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/_Attributes/AttributeTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/_Attributes/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/_Attributes/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/_Error/CompileErrorTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/_Error/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/_Error/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/_Print/PrintTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/_Print/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/_Print/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/_Print/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/break/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/TagTests/break/templates/break_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/break/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Array/ArrayTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Array/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Array/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Array/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/BoolenNull/BooleanNullTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/BoolenNull/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/ConstantTests/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/ConstantTests/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/DoubleQuotedStringTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_closedBlock.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_unclosedBlock.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Math/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Math/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Modifier/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_Default.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredMethod.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredStatic.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Objects/ObjectVariableTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Objects/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Objects/templates/hello_world_test.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Objects/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SingleQouted/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SingleQouted/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/SmartyConstantTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant_variable.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_modifier.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_variable.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/SmartyDelimiterTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates/delimiter.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates/error.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now_nocache.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/PostTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_modifier.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_variable.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/SmartyTemplateObjectTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates/template_object.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates/version.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/VariableVariableTest.php create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/configs/data.conf create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/configs/smarty.conf create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/configs/template.conf create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope.tpl create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope_include.tpl create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope.tpl create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign.tpl create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign_noscope.tpl create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignbar.tpl create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignnocache.tpl create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_pluginassign.tpl create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/X_Scopes/templates_tmp/.gitignore create mode 100644 tests/UnitTests/TemplateSource/Xml/XmlTest.php create mode 100644 tests/UnitTests/TemplateSource/Xml/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/Xml/templates/xml.tpl create mode 100644 tests/UnitTests/TemplateSource/Xml/templates/xml_main.tpl create mode 100644 tests/UnitTests/TemplateSource/Xml/templates/xmlvar.tpl create mode 100644 tests/UnitTests/TemplateSource/Xml/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php create mode 100644 tests/UnitTests/TemplateSource/_Issues/327/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/327/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php create mode 100644 tests/UnitTests/TemplateSource/_Issues/419/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/419/templates/001_child.tpl create mode 100644 tests/UnitTests/TemplateSource/_Issues/419/templates/001_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/_Issues/419/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php create mode 100644 tests/UnitTests/TemplateSource/_Issues/422/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/422/templates/422_test.tpl create mode 100644 tests/UnitTests/TemplateSource/_Issues/422/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php create mode 100644 tests/UnitTests/TemplateSource/_Issues/428/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/428/templates/001_section.tpl create mode 100644 tests/UnitTests/TemplateSource/_Issues/428/templates/002_section.tpl create mode 100644 tests/UnitTests/TemplateSource/_Issues/428/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php create mode 100644 tests/UnitTests/TemplateSource/_Issues/topic26878/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/topic26878/templates_c/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/topic26878/templates_tmp/.gitignore create mode 100644 tests/UnitTests/__shared/PHPunitplugins/block.dummyblock.php create mode 100644 tests/UnitTests/__shared/PHPunitplugins/compiler.getparamsshort.php create mode 100644 tests/UnitTests/__shared/PHPunitplugins/function.checkconfigvar.php create mode 100644 tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php create mode 100644 tests/UnitTests/__shared/PHPunitplugins/function.getparams.php create mode 100644 tests/UnitTests/__shared/PHPunitplugins/function.getvar.php create mode 100644 tests/UnitTests/__shared/PHPunitplugins/function.pluginassign.php create mode 100644 tests/UnitTests/__shared/templates/run_code.tpl create mode 100644 tests/UnitTests/__shared/templates/run_code_caching.tpl create mode 100644 tests/UnitTests/__shared/templates/scope_include.tpl create mode 100644 tests/UnitTests/__shared/templates/scope_tag.tpl create mode 100644 tests/cache/.gitignore create mode 100644 tests/templates_c/.gitignore diff --git a/.gitignore b/.gitignore index 0cbbf4d2..00d98c5b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,3 @@ utilies/*.php phpunit* vendor/* composer.lock -templates_c/* diff --git a/.travis.yml b/.travis.yml index 44fb4eb1..38b75919 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,11 +11,10 @@ matrix: - php: 7.1 - php: 7.2 - php: 7.3 - - php: 7.4snapshot + - php: 7.4 - php: nightly fast_finish: true allow_failures: - - php: 7.4snapshot - php: nightly services: @@ -30,8 +29,6 @@ before_install: install: - travis_retry composer install - - git clone --depth=50 --branch=master git://github.com/smarty-php/smarty-phpunit.git script: - - cd smarty-phpunit - - ../vendor/bin/phpunit ./ + - ./phpunit.sh diff --git a/TODO.md b/TODO.md new file mode 100644 index 00000000..95896157 --- /dev/null +++ b/TODO.md @@ -0,0 +1,69 @@ +# Todo + +## Add unit test for strip issue in correct branch +tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php +``` +@@ -76,6 +76,7 @@ class CompileStripTest extends PHPUnit_Smarty + array("{'Var'}\n ", 'Var ', '', $i ++), + array("\n ", ' ', '', $i ++), + array("\n\n ", '', '', $i ++), ++ array("\n\n {* a comment *}\n ", '', '', $i ++), + + ); + } +``` + +## Add unit test for isset issue in correct branch +tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php +```php + /** + * test PHP isset() on (non-)variables + * @dataProvider dataTestIsset3 + * @param string $strTemplate template to test + * @param string $result expected result + */ + public function testIsset3($strTemplate, $result) + { + $this->smarty->disableSecurity(); + + $this->smarty->assign('varobject', new TestIsset()); + $this->smarty->assign('vararray', $vararray = [ + 'keythatexists' => false, + 'keywitharray' => [1 => 1], + 'keywithobject' => new TestIsset()] + ); + + $this->smarty->assign('key', 'A'); + $this->smarty->assign('_varsimpleA', 1); + $this->smarty->assign('varsimpleB', 0); + $this->smarty->assign('varsimpleC', null); + + $this->assertEquals($result, $this->smarty->fetch('string:' . $strTemplate)); + } + + /** + * Data provider for testIsset3 + */ + public function dataTestIsset3() + { + return array( + array('{if isset($varobject->arr)}true{else}false{/if}', 'true'), + array('{if isset($vararray["keywitharray"])}true{else}false{/if}', 'true'), + array('{if isset($vararray["keythatexists"])}true{else}false{/if}', 'true'), + array('{if isset($vararray["nonexistingkey"])}true{else}false{/if}', 'false'), + array('{if isset($_GET["sscr6hr6cz34j6"])}true{else}false{/if}', 'false'), + array('{if isset(count([\'hi\']))}true{else}false{/if}', 'true'), + array('{if isset($vararray[\'keywitharray\'][intval(\'1\')])}true{else}false{/if}', 'true'), + array('{if isset($vararray[\'keywithobject\']->arr[\'isSet\'])}true{else}false{/if}', 'true'), + array('{if isset($vararray[\'keywithobject\']->arr[\'isNull\'])}true{else}false{/if}', 'false'), + array('{if isset($varobject->arr[\'isSet\'])}true{else}false{/if}', 'true'), + array('{if isset($varobject->arr[\'isNull\'])}true{else}false{/if}', 'false'), + array('{if isset($_varsimpleA)}true{else}false{/if}', 'true'), + array('{if isset($varsimpleB)}true{else}false{/if}', 'true'), + array('{if isset($varsimpleC)}true{else}false{/if}', 'false'), + array('{if isset($_varsimpleA && varsimpleB)}true{else}false{/if}', 'true'), + array('{if isset($_varsimpleA && varsimpleC)}true{else}false{/if}', 'true'), + array('{if isset($_varsimple{$key})}true{else}false{/if}', 'true'), + ); + } +``` \ No newline at end of file diff --git a/phpunit.sh b/phpunit.sh new file mode 100755 index 00000000..65935ab5 --- /dev/null +++ b/phpunit.sh @@ -0,0 +1,2 @@ +#! /bin/bash +vendor/phpunit/phpunit/phpunit tests/UnitTests diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 00000000..e372eb80 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,43 @@ + + + + + + tests/UnitTests + + + + tests + tests/cache + tests/templates_c + + + libs + libs/plugins + libs/sysplugins + demo/plugins + + + + + + + diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 00000000..83774db7 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,11 @@ +.idea + +# Unit test / coverage reports +.coverage +.tox + +#Smarty +testdox.html +TestResults.tap +TestResults.txt + diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php new file mode 100644 index 00000000..b3e05a8c --- /dev/null +++ b/tests/Bootstrap.php @@ -0,0 +1,28 @@ + array('config', 'pdo', 'init', + 'testNumver', 'pluginsdir'),); + + /** + * This method is called before the first test of this test class is run. + * + */ + public static function setUpBeforeClass() + { + error_reporting(E_ALL & ~E_STRICT); + self::$init = true; + self::$pluginsdir =self::getSmartyPluginsDir(); + } + + /** + * This method is called after the last test of this test class is run. + * + */ + public static function tearDownAfterClass() + { + //self::$pdo = null; + self::$testNumber = 0; + } + + /** + * Constructs a test case with the given name. + * + * @param string $name + * @param array $data + * @param string $dataName + */ + public function __construct($name = null, array $data = array(), $dataName = '') + { + date_default_timezone_set('Europe/Berlin'); + if (!defined('individualFolders')) { + define('individualFolders', true); + } + parent::__construct($name, $data, $dataName); + $this->backupStaticAttributesBlacklist[ get_class($this) ] = array('init', 'config', 'pdo', 'testNumber'); + } + + /** + * Setup Smarty instance called for each test + * + * @param null $dir working directory + */ + public function setUpSmarty($dir = null) + { + static $s_dir; + // set up current working directory + chdir($dir); + self::$cwd = getcwd(); + // create missing folders for test + if (self::$init) { + if (!is_dir($dir . '/templates')) { + mkdir($dir . '/templates'); + } + if (!is_dir($dir . '/configs')) { + mkdir($dir . '/configs'); + } + if (individualFolders != 'true') { + if (!isset($s_dir[ $dir ])) { + $this->cleanDir($dir . '/templates_c'); + $this->cleanDir($dir . '/cache'); + if (is_dir($dir . '/templates_tmp')) { + $this->cleanDir($dir . '/templates_tmp'); + } + $s_dir[ $dir ] = true; + } + $dir = dirname(__FILE__); + } + if (!is_dir($dir . '/templates_c')) { + mkdir($dir . '/templates_c'); + } + chmod($dir . '/templates_c', 0775); + if (!is_dir($dir . '/cache')) { + mkdir($dir . '/cache'); + chmod($dir . '/cache', 0775); + } + self::$init = false; + } + clearstatcache(); + // instance Smarty class + if ($this->loadSmarty) { + $this->smarty = new Smarty; + if (individualFolders != 'true') { + $this->smarty->setCompileDir(dirname(__FILE__) . '/templates_c'); + $this->smarty->setCacheDir(dirname(__FILE__) . '/cache'); + } + } + // instance SmartyBC class + if ($this->loadSmartyBC) { + $this->smartyBC = new SmartyBC; + if (individualFolders != 'true') { + $this->smartyBC->setCompileDir(dirname(__FILE__) . '/templates_c'); + $this->smartyBC->setCacheDir(dirname(__FILE__) . '/cache'); + } + } + $smarty = $this->getSmartyObj(); + } + + /** + * Create Mysql PDO object + * + */ + final public function getConnection() + { + if (PHPUnit_Smarty::$pdo == null) { + try { + PHPUnit_Smarty::$pdo = new PDO(DB_DSN, DB_USER, DB_PASSWD); + } + catch (PDOException $e) { + throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); + } + $timezone = date_default_timezone_get(); + $j = PHPUnit_Smarty::$pdo->exec("SET time_zone = '{$timezone}';"); + + + } + } + + /** + * Create table for Mysql resource + * + */ + public function initMysqlResource() + { + $this->getConnection(); + PHPUnit_Smarty::$pdo->exec("DROP TABLE `templates`"); + PHPUnit_Smarty::$pdo->exec("CREATE TABLE IF NOT EXISTS `templates` ( + `name` varchar(100) NOT NULL, + `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `source` text, +PRIMARY KEY (`name`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8"); + + } + + /** + * Create table for Mysql cache resource + * + */ + public function initMysqlCache() + { + $this->getConnection(); + PHPUnit_Smarty::$pdo->exec("DROP TABLE `output_cache`"); + PHPUnit_Smarty::$pdo->exec("CREATE TABLE IF NOT EXISTS `output_cache` ( + `name` varchar(256) NOT NULL, + `id` char(40) NOT NULL, + `cache_id` varchar(250) DEFAULT NULL, + `compile_id` varchar(250) DEFAULT NULL, +`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `content` mediumblob NOT NULL, +PRIMARY KEY (`id`), +KEY `cache_id` (`cache_id`), +KEY `compile_id` (`compile_id`), +KEY `modified` (`modified`), +KEY `name` (`name`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8"); +// PHPUnit_Smarty::$pdo->exec("CREATE TABLE IF NOT EXISTS `output_cache` ( +//`id` char(40) NOT NULL, +//`name` varchar(250) NOT NULL, +//`cache_id` varchar(250) DEFAULT NULL, +//`compile_id` varchar(250) DEFAULT NULL, +//`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, +//`expire` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', +//`content` mediumblob NOT NULL, +///PRIMARY KEY (`id`), +//KEY `name` (`name`), +//KEY `cache_id` (`cache_id`), +//KEY `compile_id` (`compile_id`), +//KEY `modified` (`modified`), +//KEY `expire` (`expire`) +//) ENGINE=InnoDB DEFAULT CHARSET=utf8"); + + } + + /** + * Delete files in templates_c and cache folders + * + */ + public function cleanDirs() + { + $this->cleanCompileDir(); + $this->cleanCacheDir(); + if (is_dir(self::$cwd . '/templates_tmp')) { + $this->cleanDir(self::$cwd . '/templates_tmp'); + } + $this->assertTrue(true); + } + + /** + * Make temporary template file + * + */ + public function makeTemplateFile($name, $code) + { + if (!is_dir(self::$cwd . '/templates_tmp')) { + mkdir(self::$cwd . '/templates_tmp'); + chmod(self::$cwd . '/templates_tmp', 0775); + } + $fileName = self::$cwd . '/templates_tmp/' . "{$name}"; + file_put_contents($fileName, $code); + } + + /** + * Delete files in templates_c folder + * + */ + public function cleanCompileDir() + { + $smarty = $this->getSmartyObj(); + if (isset($smarty)) { + $dir = $smarty->getCompileDir(); + $this->cleanDir($dir); + } + } + + /** + * Delete files in cache folder + * + */ + public function cleanCacheDir() + { + $smarty = $this->getSmartyObj(); + if (isset($smarty)) { + $dir = $smarty->getCacheDir(); + $this->cleanDir($dir); + } + } + + /** + * Delete files and sub folders + * + * @param string $dir + */ + public function cleanDir($dir) + { + $di = new RecursiveDirectoryIterator($dir); + $ri = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST); + foreach ($ri as $file) { + if (substr(basename($file->getPathname()), 0, 1) === '.' || substr((string)$file,-4) === '.txt') { + continue; + } + // directory ? + if ($file->isDir()) { + if (!$ri->isDot()) { + // delete folder if empty + @rmdir($file->getPathname()); + } + } else { + unlink($file->getPathname()); + } + } + } + + /** + * Get PDO object + * + * @return null|PDO + */ + final public function getPDO() + { + return PHPUnit_Smarty::$pdo; + } + + /** + * Remove "\r" and replace "\t" with spaces + * + * @param string $in + * + * @return mixed + */ + public function normalizeString($in) + { + if (is_string($in)) { + return str_replace(array("\r", "\t"), array('', ' '), $in); + } else { + return $in; + } + } + + /** + * Remove all spaces + * + * @param string $in + * + * @return mixed + */ + public function strip($in) + { + if (is_string($in)) { + return preg_replace('/\s/', '', $in); + } else { + return $in; + } + } + + /** + * Return source path + * + * @param Smarty_Internal_TemplateBase $tpl template object + * @param null|string $name optional template name + * @param null|string $type optional template type + * @param null|string $dir optional template folder + * + * @return string + * @throws \Exception + */ + public function buildSourcePath($tpl, $name = null, $type = null, $dir = null) + { + $name = isset($name) ? $name : $tpl->source->name; + $type = isset($type) ? $type : $tpl->source->type; + $dir = isset($dir) ? $dir : $this->smarty->getTemplateDir(0); + switch ($type) { + case 'file': + case 'filetest': + case 'php': + return $this->normalizePath($dir . $name); + case 'mysqltest': + case 'mysql': + return sha1($type . ':' . $name); + case 'string': + $this->smarty->getTemplateDir(); + return sha1($name . $this->smarty->_joined_template_dir); + default: + throw new Exception("Unhandled source resource type '{$type}'"); + } + } + + /** + * Build template uid + * + * @param Smarty_Internal_TemplateBase $tpl template object + * @param null|string $value + * @param null|string $name optional template name + * @param null|string $type optional template type + * + * @return string + * @throws \Exception + */ + public function buildUid($tpl, $value = null, $name = null, $type = null) + { + $type = isset($type) ? $type : $tpl->source->type; + $name = isset($name) ? $name : $tpl->source->name; + switch ($type) { + case 'php': + case 'file': + case 'filetest': + if ($tpl instanceof Smarty) { + return sha1($this->normalizePath($this->smarty->getTemplateDir(0) . $name) . + $this->smarty->_joined_template_dir); + } + return sha1($tpl->source->filepath . $this->smarty->_joined_template_dir); + case 'mysqltest': + case 'mysql': + return sha1($type . ':' . $name); + case 'string': + $this->smarty->getTemplateDir(); + return sha1($name . $this->smarty->_joined_template_dir); + default: + throw new Exception("Unhandled source resource type '{$type}'"); + } + } + + /** + * Normalize path + * - remove /./ and /../ + * - make it absolute + * + * @param string $path file path + * + * @return string + */ + public function normalizePath($path, $ds =null ,$absolute = true) + { + $ds = isset($ds) ? $ds : DIRECTORY_SEPARATOR; + $nds = $ds == '/' ? '\\' : '/'; + $getcwd = getcwd(); + // normalize $ds + $path = str_replace($nds, $ds, $path); + preg_match('#^([a-zA-Z][:])?([.]{1,2}[\/\\\]+)?([\\\])?([.]{0,2}[\/\\\]+)?([[:print:]]*)#', $path, $match); + if ($match[1] === '') { + if ($match[ 2 ] !== '' || $match[ 2 ] . $match[ 3 ] . $match[ 4 ] === '') { + $path = $getcwd . $ds . $path; + } else if (Smarty::$_IS_WINDOWS && $match[ 3 ] !== '') { + $path = substr($getcwd, 0, 2) . $path; + } + } + $path = preg_replace('#[\\\/]+([.][\\\/]+)*#', $ds, $path); + while (strrpos($path, '.' . $ds) !== false) { + $path = + preg_replace('#([\\\/]([^\\\/]+[\\\/]){2}([.][.][\\\/]){2})|([\\\/][^\\\/]+[\\\/][.][.][\\\/])#', $ds, + $path); + } + $cwd = preg_replace('#[\\\/]#', $ds, $getcwd); + $path = str_ireplace($cwd,$getcwd, $path); + if (!$absolute) { + $path = preg_replace('#'.$getcwd.'#', '', $path); + } + return $path; + } + + /** + * Return base name + * + * @param \Smarty_Internal_Template|\Smarty_Internal_TemplateBase $tpl template object + * @param null|string $name optional template name + * @param null|string $type optional template type + * + * @return null|string + */ + public function getBasename(Smarty_Internal_Template $tpl, $name = null, $type = null) + { + $name = isset($name) ? $name : $tpl->source->name; + $type = isset($type) ? $type : $tpl->source->type; + switch ($type) { + case 'file': + case 'filetest': + if (($_pos = strpos($name, ']')) !== false) { + $name = substr($name, $_pos + 1); + } + return basename($name); + case 'mysqltest': + case 'mysql': + return $name; + case 'string': + return ''; + default: + return null; + } + } + + /** + * Return compiled file path + * + * @param \Smarty_Internal_Template|\Smarty_Internal_TemplateBase $tpl template object + * @param bool $sub use sub directory flag + * @param bool $caching caching flag + * @param null|string $compile_id optional compile id + * @param null|string $name optional template name + * @param null|string $type optional template type + * @param null|string $dir optional template folder + * + * @return string + * @throws \Exception + */ + public function buildCompiledPath(Smarty_Internal_Template $tpl, $sub = true, $caching = false, $compile_id = null, + $name = null, $type = null, $dir = null) + { + $sep = DIRECTORY_SEPARATOR; + $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; + $sp = $this->buildSourcePath($tpl, $name, $type, $dir); + $uid = $this->buildUid($tpl, $sp, $name, $type); + $_flag = ''; + if (isset($tpl->source) && $tpl->source->isConfig) { + $_flag = '_' . ((int) $tpl->smarty->config_read_hidden + (int) $tpl->smarty->config_booleanize * 2 + + (int) $tpl->smarty->config_overwrite * 4); + } else { + $_flag = '_' . ((int) $tpl->smarty->merge_compiled_includes + (int) $tpl->smarty->escape_html * 2); + } + $_filepath = $uid . $_flag; + // if use_sub_dirs, break file into directories + if ($sub) { + $_filepath = + substr($_filepath, 0, 2) . $sep . substr($_filepath, 2, 2) . $sep . substr($_filepath, 4, 2) . $sep . + $_filepath; + } + $_compile_dir_sep = $sub ? $sep : '^'; + if (isset($_compile_id)) { + $_filepath = $_compile_id . $_compile_dir_sep . $_filepath; + } + // caching token + if ($caching) { + $_cache = '.cache'; + } else { + $_cache = ''; + } + $_compile_dir = $tpl->smarty->getCompileDir(); + // set basename if not specified + $_basename = $this->getBasename($tpl, $name, $type); + if ($_basename === null) { + $_basename = basename(preg_replace('![^\w\/]+!', '_', $name)); + } + // separate (optional) basename by dot + if ($_basename) { + $_basename = '.' . $_basename; + } + + return $_compile_dir . $_filepath . '.' . $type . $_basename . $_cache . '.php'; + } + + /** + * Return cache file path + * + * @param Smarty_Internal_TemplateBase $tpl template object + * @param bool $sub use sub directory flag + * @param null|string $cache_id optional cache id + * @param null|string $compile_id optional compile id + * @param null|string $name optional template name + * @param null|string $type optional template type + * @param null|string $dir optional template folder + * @param null|string $cacheType optional cache resource type + * + * @return string + * @throws \Exception + */ + public function buildCachedPath($tpl, $sub = true, $cache_id = null, $compile_id = null, $name = null, $type = null, + $dir = null, $cacheType = null) + { + $cacheType = isset($cacheType) ? $cacheType : $tpl->smarty->caching_type; + switch ($cacheType) { + case 'file': + case 'filetest': + $sep = DIRECTORY_SEPARATOR; + $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; + $_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null; + $sp = $this->buildSourcePath($tpl, $name, $type, $dir); + $uid = $this->buildUid($tpl, $sp, $name, $type); + $_filepath = sha1($uid . $this->smarty->_joined_template_dir); + // if use_sub_dirs, break file into directories + if ($sub) { + $_filepath = + substr($_filepath, 0, 2) . $sep . substr($_filepath, 2, 2) . $sep . substr($_filepath, 4, 2) . + $sep . $_filepath; + } + $_compile_dir_sep = $sub ? $sep : '^'; + if (isset($_cache_id)) { + $_cache_id = str_replace('|', $_compile_dir_sep, $_cache_id) . $_compile_dir_sep; + } else { + $_cache_id = ''; + } + if (isset($_compile_id)) { + $_compile_id = $_compile_id . $_compile_dir_sep; + } else { + $_compile_id = ''; + } + $smarty = isset($tpl->smarty) ? $tpl->smarty : $tpl; + $_cache_dir = $smarty->getCacheDir(); + return $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($sp) . '.php'; + case 'mysql': + case 'mysqltest': + case 'pdo': + case 'foobar': + $sp = $this->buildSourcePath($tpl, $name, $type, $dir); + $uid = $this->buildUid($tpl, $sp, $name, $type); + $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; + $_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null; + return sha1($uid . $_cache_id . $_compile_id); + case 'memcachetest': + case 'acp': + $sp = $this->buildSourcePath($tpl, $name, $type, $dir); + $uid = $this->buildUid($tpl, $sp, $name, $type); + $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; + $_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null; + return sha1($uid) . '#' . preg_replace('#[^\w\|]+#S', '_', $tpl->template_resource) . '#' . $_cache_id . + '#' . $_compile_id; + + default: + throw new Exception("Unhandled cache resource type '{$cacheType}'"); + } + } + + /** + * prefilter to insert test number + * + * @param string $source + * @param \Smarty_Internal_Template $tpl + * + * @return string + */ + public function prefilterTest($source, Smarty_Internal_Template $tpl) + { + return str_replace('#test#', "test:{\$test nocache} compiled:{$tpl->getTemplateVars('test')} rendered:{\$test}", + $source); + } + + /** + * Gat Smarty object + * @return null|\Smarty|\SmartyBC + */ + public function getSmartyObj(){ + return isset($this->smarty) ? $this->smarty : (isset($this->smartyBC) ? $this->smartyBC : null); + } + + public static function getSmartyPluginsDir(){ + if (is_dir(dirname(__FILE__) . '/../smarty/libs/plugins')) { + return dirname(__FILE__) . '/../smarty/libs/plugins'; + } else if(is_dir(dirname(__FILE__) . '/../libs/plugins')) { + return dirname(__FILE__) . '/../libs/plugins'; + } + } + /** + * Tears down the fixture + * This method is called after a test is executed. + * + */ + protected function tearDown() + { + if (class_exists('Smarty_Internal_TemplateCompilerBase') && + isset(Smarty_Internal_TemplateCompilerBase::$_tag_objects) + ) { + Smarty_Internal_TemplateCompilerBase::$_tag_objects = array(); + } + if (isset($this->smarty->smarty)) { + $this->smarty->smarty = null; + } + if (isset($this->smarty)) { + $this->smarty = null; + } + if (isset($this->smartyBC->smarty)) { + $this->smartyBC->smarty = null; + } + if (isset($this->smartyBC)) { + $this->smartyBC = null; + } + } +} diff --git a/tests/UnitTests/A_0/PathNormalization/PathNormalizationTest.php b/tests/UnitTests/A_0/PathNormalization/PathNormalizationTest.php new file mode 100644 index 00000000..ce4cdd91 --- /dev/null +++ b/tests/UnitTests/A_0/PathNormalization/PathNormalizationTest.php @@ -0,0 +1,78 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testNormalizeToAbsolute() { + $d = $this->smarty->_realpath('./foo/a.foo', true); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'a.foo', $d); + } + /**public function testNormalizeAbsolute() { + if (DIRECTORY_SEPARATOR == '/') { + $d = $this->smarty->_realpath('\\foo\\a.foo', true); + $this->assertEquals('/foo/a.foo', $d); + } else { + $d = $this->smarty->_realpath('/foo/a.foo', true); + $this->assertEquals(substr(getcwd(), 0, 2) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'a.foo', $d); + $d = $this->smarty->_realpath(substr(getcwd(), 0, 2) . '/foo/a.foo', true); + $this->assertEquals(substr(getcwd(), 0, 2) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'a.foo', $d); + } + } + * */ + public function testNormalizeToAbsoluteNoStart() { + $d = $this->smarty->_realpath('foo/a.foo', true); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'a.foo', $d); + } + public function testNormalizeToAbsoluteNoStart2() { + $d = $this->smarty->_realpath('a.foo', true); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'a.foo', $d); + } + public function testNormalizeToAbsolutePathLeadingDot() { + $d = $this->smarty->_realpath('.foo/a.foo', true); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . '.foo' . DIRECTORY_SEPARATOR . 'a.foo', $d); + } + public function testNormalizeToAbsolutePathTrailingDot() { + $d = $this->smarty->_realpath('./foo./a.foo', true); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo.' . DIRECTORY_SEPARATOR . 'a.foo', $d); + } + public function testNormalizeToAbsolutePathBubbleUp() { + $ds = '\\' . DIRECTORY_SEPARATOR; + $prefix = preg_replace("#[{$ds}][^{$ds}]+$#", '', getcwd()); + $d = $this->smarty->_realpath('./../a.foo', true); + $this->assertEquals($prefix . DIRECTORY_SEPARATOR . 'a.foo', $d); + } + public function testNormalizeToAbsolutePathBubbleUp2() { + $ds = '\\' . DIRECTORY_SEPARATOR; + $prefix = preg_replace("#[{$ds}][^{$ds}]+$#", '', getcwd()); + $d = $this->smarty->_realpath('././../././a.foo', true); + $this->assertEquals($prefix . DIRECTORY_SEPARATOR . 'a.foo', $d); + } + public function testNormalizeToAbsolutePathBubbleUp3() { + $ds = '\\' . DIRECTORY_SEPARATOR; + $prefix = preg_replace("#[{$ds}][^{$ds}]+[{$ds}][^{$ds}]+$#", '', getcwd()); + $d = $this->smarty->_realpath('././.././.././a.foo', true); + $this->assertEquals($prefix . DIRECTORY_SEPARATOR . 'a.foo', $d); + } + public function testNormalizeToAbsoluteKomplex() { + $d = $this->smarty->_realpath('./foo/\\./bar/jo/wie/so/../..///.././././../aa/bb/cc/../../go/a.foo', true); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'aa'. DIRECTORY_SEPARATOR . 'go' . DIRECTORY_SEPARATOR .'a.foo', $d); + } + +} diff --git a/tests/UnitTests/A_0/PathNormalization/PluginDirNormalizationTest.php b/tests/UnitTests/A_0/PathNormalization/PluginDirNormalizationTest.php new file mode 100644 index 00000000..737ff4eb --- /dev/null +++ b/tests/UnitTests/A_0/PathNormalization/PluginDirNormalizationTest.php @@ -0,0 +1,145 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testGetPluginsDefaultDir() + { + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(SMARTY_PLUGINS_DIR, $result[ 0 ]); + } + public function testGetPluginsDefaultDir2() + { + $this->smarty->addPluginsDir('./foo/'); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(2, count($result)); + $this->assertEquals(SMARTY_PLUGINS_DIR, $result[ 0 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 1 ]); + } + + public function testSetPluginsDir1() + { + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setPluginsDir('foo'); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetPluginsDir2() + { + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setPluginsDir('foo/'); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetPluginsDir3() + { + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setPluginsDir('foo/.'); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetPluginsDir4() + { + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setPluginsDir('foo/./'); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetPluginsDir5() + { + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setPluginsDir('.foo'); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . '.foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetPluginsDir6() + { + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setPluginsDir('..foo'); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . '..foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetPluginsDir7() + { + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setPluginsDir('../foo'); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(substr(getcwd(), 0, - strlen(basename(getcwd()))) . 'foo' . DIRECTORY_SEPARATOR, + $result[ 0 ]); + } + + public function testSetPluginsDir8() + { + $this->smarty->setPluginsDir(array('foo', 'bah')); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(2, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'bah' . DIRECTORY_SEPARATOR, $result[ 1 ]); + } + + public function testSetPluginsDir9() + { + $this->smarty->setPluginsDir(array('foo', 'bah')); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(2, count($result)); + $this->smarty->addPluginsDir('blar'); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(3, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'bah' . DIRECTORY_SEPARATOR, $result[ 1 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'blar' . DIRECTORY_SEPARATOR, $result[ 2 ]); + } + + public function testSetPluginsDir10() + { + $this->smarty->setPluginsDir(array('foo', 'bah')); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(2, count($result)); + $this->smarty->addPluginsDir(array('blar', 'smarty')); + $result = $this->smarty->getPluginsDir(); + $this->assertEquals(4, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'bah' . DIRECTORY_SEPARATOR, $result[ 1 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'blar' . DIRECTORY_SEPARATOR, $result[ 2 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR, $result[ 3 ]); + } + +} diff --git a/tests/UnitTests/A_0/PathNormalization/TemlateDirNormalizationTest.php b/tests/UnitTests/A_0/PathNormalization/TemlateDirNormalizationTest.php new file mode 100644 index 00000000..3ee101b1 --- /dev/null +++ b/tests/UnitTests/A_0/PathNormalization/TemlateDirNormalizationTest.php @@ -0,0 +1,137 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testGetTemplateDir() + { + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetTemplateDir1() + { + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setTemplateDir('foo'); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetTemplateDir2() + { + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setTemplateDir('foo/'); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetTemplateDir3() + { + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setTemplateDir('foo/.'); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetTemplateDir4() + { + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setTemplateDir('foo/./'); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetTemplateDir5() + { + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setTemplateDir('.foo'); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . '.foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetTemplateDir6() + { + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setTemplateDir('..foo'); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . '..foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + } + + public function testSetTemplateDir7() + { + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->smarty->setTemplateDir('../foo'); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(1, count($result)); + $this->assertEquals(substr(getcwd(), 0, - strlen(basename(getcwd()))) . 'foo' . DIRECTORY_SEPARATOR, + $result[ 0 ]); + } + + public function testSetTemplateDir8() + { + $this->smarty->setTemplateDir(array('foo', 'bah')); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(2, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'bah' . DIRECTORY_SEPARATOR, $result[ 1 ]); + } + + public function testSetTemplateDir9() + { + $this->smarty->setTemplateDir(array('foo', 'bah')); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(2, count($result)); + $this->smarty->addTemplateDir('blar'); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(3, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'bah' . DIRECTORY_SEPARATOR, $result[ 1 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'blar' . DIRECTORY_SEPARATOR, $result[ 2 ]); + } + + public function testSetTemplateDir10() + { + $this->smarty->setTemplateDir(array('foo', 'bah')); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(2, count($result)); + $this->smarty->addTemplateDir(array('blar', 'smarty')); + $result = $this->smarty->getTemplateDir(); + $this->assertEquals(4, count($result)); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $result[ 0 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'bah' . DIRECTORY_SEPARATOR, $result[ 1 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'blar' . DIRECTORY_SEPARATOR, $result[ 2 ]); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR, $result[ 3 ]); + } + +} diff --git a/tests/UnitTests/A_0/PathNormalization/cache/.gitignore b/tests/UnitTests/A_0/PathNormalization/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_0/PathNormalization/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_0/PathNormalization/templates_c/.gitignore b/tests/UnitTests/A_0/PathNormalization/templates_c/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_0/PathNormalization/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php b/tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php new file mode 100644 index 00000000..a51757ae --- /dev/null +++ b/tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php @@ -0,0 +1,226 @@ +setUpSmarty(dirname(__FILE__)); + } + + /* + * template_dir + */ + + public function testTemplateDirDirectRelative() + { + $s = new Smarty(); + $s->template_dir = './foo'; + $d = $s->getTemplateDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + } + + public function testTemplateDirDirectRelativeArray() + { + $s = new Smarty(); + $s->template_dir = array('./foo', './bar/'); + $d = $s->template_dir; + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + } + + public function testTemplateDirDirectRelativeArrayAdd() + { + $s = new Smarty(); + $s->template_dir = './foo'; + $s->addTemplateDir('./bar/'); + $d = $s->getTemplateDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + } + + public function testTemplateDirDirectRelativeExtends() + { + $s = new FolderT(); + $d = $s->getTemplateDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + } + + public function testTemplateDirDirectRelativeExtends2() + { + $s = new FolderT(); + $s->template_dir = './bar'; + $d = $s->getTemplateDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); + } + + /* + * config_dir + */ + + public function testConfigDirDirectRelative() + { + $s = new Smarty(); + $s->config_dir = './foo'; + $d = $s->getConfigDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + } + + public function testConfigDirDirectRelativeArray() + { + $s = new Smarty(); + $s->config_dir = array('./foo', './bar/'); + $d = $s->config_dir; + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + } + + public function testConfigDirDirectRelativeArrayAdd() + { + $s = new Smarty(); + $s->config_dir = './foo'; + $s->addConfigDir('./bar/'); + $d = $s->getConfigDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + } + + public function testConfigDirDirectRelativeExtends() + { + $s = new FolderT(); + $d = $s->getConfigDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR, $d[ 0 ]); + } + + public function testConfigDirDirectRelativeExtends2() + { + $s = new FolderT(); + $s->config_dir = './bar'; + $d = $s->getConfigDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); + } + + /* + * plugins_dir + */ + + public function testPluginDirDirectRelative() + { + $s = new Smarty(); + $s->plugins_dir = './foo'; + $d = $s->getPluginsDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + } + + public function testPluginDirDirectRelativeArray() + { + $s = new Smarty(); + $s->plugins_dir = array('./foo', './bar/'); + $d = $s->plugins_dir; + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + } + + public function testPluginDirDirectRelativeArrayAdd() + { + $s = new Smarty(); + $s->plugins_dir = './foo'; + $s->addPluginsDir('./bar/'); + $d = $s->getPluginsDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + } + + public function testPluginDirDirectRelativeExtends() + { + $s = new FolderT(); + $d = $s->getPluginsDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plug' . DIRECTORY_SEPARATOR, $d[ 0 ]); + } + + public function testPluginDirDirectRelativeExtends2() + { + $s = new FolderT(); + $s->plugins_dir = './bar'; + $d = $s->getPluginsDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); + } + /* + * compile_dir + */ + + public function testCompileDirDirectRelative() + { + $s = new Smarty(); + $s->compile_dir = './foo'; + $d = $s->getCompileDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d); + } + + public function testCompileDirDirectRelativeExtends() + { + $s = new FolderT(); + $d = $s->getCompileDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'comp' . DIRECTORY_SEPARATOR, $d); + } + + public function testCompileDirDirectRelativeExtends2() + { + $s = new FolderT(); + $s->compile_dir = './bar'; + $d = $s->getCompileDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d); + } + /* + * cache_dir + */ + + public function testCacheDirDirectRelative() + { + $s = new Smarty(); + $s->cache_dir = './foo'; + $d = $s->getCacheDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d); + } + + public function testCacheDirDirectRelativeExtends() + { + $s = new FolderT(); + $d = $s->getCacheDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, $d); + } + + public function testCacheDirDirectRelativeExtends2() + { + $s = new FolderT(); + $s->cache_dir = './bar'; + $d = $s->getCacheDir(); + $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d); + } +} + +class FolderT extends Smarty +{ + protected $template_dir = './foo'; + + protected $compile_dir = './comp/'; + + protected $plugins_dir = './plug/'; + + protected $cache_dir = './cache/'; + + protected $config_dir = array('./conf/'); + +} diff --git a/tests/UnitTests/A_1/ProtectedFolderVars/cache/.gitignore b/tests/UnitTests/A_1/ProtectedFolderVars/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_1/ProtectedFolderVars/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_1/ProtectedFolderVars/comp/.gitignore b/tests/UnitTests/A_1/ProtectedFolderVars/comp/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_1/ProtectedFolderVars/comp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php b/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php new file mode 100644 index 00000000..8a564cbc --- /dev/null +++ b/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php @@ -0,0 +1,74 @@ +setUpSmarty(dirname(__FILE__)); + error_reporting(E_ALL | E_STRICT); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * Test E_NOTICE suppression template fetched by Smarty object + */ + public function testE_NoticeDisabled() + { + $e1 = error_reporting(); + $this->smarty->setErrorReporting(E_ALL & ~E_NOTICE); + $this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl')); + $e2 = error_reporting(); + $this->assertEquals($e1, $e2); + } + + /** + * Test E_NOTICE suppression template fetched by template object + */ + public function testE_NoticeDisabledTplObject_1() + { + $e1 = error_reporting(); + $this->smarty->setErrorReporting(E_ALL & ~E_NOTICE); + $tpl = $this->smarty->createTemplate('001_main.tpl'); + $this->assertEquals('undefined = ', $tpl->fetch()); + $e2 = error_reporting(); + $this->assertEquals($e1, $e2); + } + + public function testE_NoticeDisabledTplObject_2() + { + $e1 = error_reporting(); + $this->smarty->setErrorReporting(E_ALL & ~E_NOTICE); + $tpl = $this->smarty->createTemplate('001_main.tpl'); + $this->assertEquals('undefined = ', $this->smarty->fetch($tpl)); + $e2 = error_reporting(); + $this->assertEquals($e1, $e2); + } + + /** + * Throw E_NOTICE message + * + * @expectedException PHPUnit_Framework_Error_Notice + * @expectedExceptionMessage Undefined index: foo + */ + public function testE_Notice() + { + $e1 = error_reporting(); + $this->assertEquals('undefined = ', $this->smarty->fetch('001_main.tpl')); + $e2 = error_reporting(); + $this->assertEquals($e1, $e2); + } +} diff --git a/tests/UnitTests/A_2/UndefinedTemplateVar/cache/.gitignore b/tests/UnitTests/A_2/UndefinedTemplateVar/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_2/UndefinedTemplateVar/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_2/UndefinedTemplateVar/templates/001_include.tpl b/tests/UnitTests/A_2/UndefinedTemplateVar/templates/001_include.tpl new file mode 100644 index 00000000..df554272 --- /dev/null +++ b/tests/UnitTests/A_2/UndefinedTemplateVar/templates/001_include.tpl @@ -0,0 +1 @@ +undefined = {$foo} \ No newline at end of file diff --git a/tests/UnitTests/A_2/UndefinedTemplateVar/templates/001_main.tpl b/tests/UnitTests/A_2/UndefinedTemplateVar/templates/001_main.tpl new file mode 100644 index 00000000..534e9ff7 --- /dev/null +++ b/tests/UnitTests/A_2/UndefinedTemplateVar/templates/001_main.tpl @@ -0,0 +1 @@ +{include '001_include.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/A_2/UndefinedTemplateVar/templates_c/.gitignore b/tests/UnitTests/A_2/UndefinedTemplateVar/templates_c/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_2/UndefinedTemplateVar/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php b/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php new file mode 100644 index 00000000..733c7226 --- /dev/null +++ b/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php @@ -0,0 +1,33 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->setEscapeHtml(true); + } + + /** + * test 'escapeHtml' property + */ + public function testAutoEscape() + { + $tpl = $this->smarty->createTemplate('eval:{$foo}'); + $tpl->assign('foo', ''); + $this->assertEquals("<a@b.c>", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/A_Core/AutoEscape/cache/.gitignore b/tests/UnitTests/A_Core/AutoEscape/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/AutoEscape/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/AutoEscape/templates_c/.gitignore b/tests/UnitTests/A_Core/AutoEscape/templates_c/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/AutoEscape/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/Filter/FilterClosure.php b/tests/UnitTests/A_Core/Filter/FilterClosure.php new file mode 100644 index 00000000..2b642640 --- /dev/null +++ b/tests/UnitTests/A_Core/Filter/FilterClosure.php @@ -0,0 +1,14 @@ +smarty->registerFilter(Smarty::FILTER_PRE, function ($input) { + return '{$foo}' . $input; + }); + $tpl = $this->smarty->createTemplate('eval:{" hello world"}'); + $tpl->assign('foo', 'buh'); + $this->assertEquals("buh hello world", $this->smarty->fetch($tpl)); + diff --git a/tests/UnitTests/A_Core/Filter/FilterTest.php b/tests/UnitTests/A_Core/Filter/FilterTest.php new file mode 100644 index 00000000..e3847be1 --- /dev/null +++ b/tests/UnitTests/A_Core/Filter/FilterTest.php @@ -0,0 +1,279 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test autoload output filter + */ + public function testAutoloadOutputFilter() + { + $this->smarty->autoload_filters[ 'output' ] = 'trimwhitespace'; + $tpl = $this->smarty->createTemplate('eval:{"
hello world"}'); + $this->assertEquals("
hello world", $this->smarty->fetch($tpl)); + } + + /** + * test autoload variable filter + */ + public function testAutoloadVariableFilter() + { + $this->smarty->autoload_filters[ 'variable' ] = 'htmlspecialchars'; + $tpl = $this->smarty->createTemplate('eval:{""}'); + $this->assertEquals("<test>", $this->smarty->fetch($tpl)); + } + + /** + * test loaded filter + */ + public function testLoadedOutputFilter() + { + $this->smarty->loadFilter(Smarty::FILTER_OUTPUT, 'trimwhitespace'); + $tpl = $this->smarty->createTemplate('string:{"
hello world"}'); + $this->assertEquals("
hello world", $this->smarty->fetch($tpl)); + } + + public function testLoadedOutputFilterWrapper() + { + $this->smartyBC->load_filter(Smarty::FILTER_OUTPUT, 'trimwhitespace'); + $tpl = $this->smartyBC->createTemplate('eval:{"
hello world"}'); + $this->assertEquals("
hello world", $this->smartyBC->fetch($tpl)); + } + + /** + * test registered output filter + */ + public function testRegisteredOutputFilter() + { + $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter'); + $tpl = $this->smarty->createTemplate('eval:{"hello world"}'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + /** + * test registered output filter not cached + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testRegisteredOutputFilter_001() + { + $this->smarty->assign('foo', 1); + $this->smarty->assign('bar', 2); + $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->assertEquals('1 filter 2', $this->smarty->fetch('output_001.tpl')); + } + + /** + * test registered output filter not cached 2" + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testRegisteredOutputFilter_001_2() + { + $this->smarty->assign('foo', 3); + $this->smarty->assign('bar', 4); + $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->assertEquals('3 filter 4', $this->smarty->fetch('output_001.tpl')); + } + + /** + * test registered output filter cached 1" + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testRegisteredOutputFilter_001_3() + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', 5); + $this->smarty->assign('bar', 6); + $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->assertEquals('5 filter 6', $this->smarty->fetch('output_001.tpl')); + } + + /** + * test registered output filter cached 1" + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testRegisteredOutputFilter_001_4() + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', 7); + $this->smarty->assign('bar', 8); + $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->assertEquals('5 filter 6', $this->smarty->fetch('output_001.tpl')); + } + + /** + * test registered output filter cached nocache" + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testRegisteredOutputFilter_002_1() + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', 10); + $this->smarty->assign('bar', 11); + $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->assertEquals('10 filter 11', $this->smarty->fetch('output_002.tpl')); + } + + /** + * test registered output filter cached nocache" + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testRegisteredOutputFilter_002_2() + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', 12); + $this->smarty->assign('bar', 13); + $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->assertEquals('12 filter 13', $this->smarty->fetch('output_002.tpl')); + } + + public function testRegisteredOutputFilterWrapper() + { + $this->smartyBC->register_outputfilter('myoutputfilter'); + $tpl = $this->smartyBC->createTemplate('eval:{"hello world"}'); + $this->assertEquals("hello world", $this->smartyBC->fetch($tpl)); + } + + /** + * test registered pre filter + */ + public function testRegisteredPreFilter() + { + function myprefilter($input) + { + return '{$foo}' . $input; + } + + $this->smarty->registerFilter(Smarty::FILTER_PRE, 'myprefilter'); + $tpl = $this->smarty->createTemplate('eval:{" hello world"}'); + $tpl->assign('foo', 'bar'); + $this->assertEquals("bar hello world", $this->smarty->fetch($tpl)); + } + + /** + * test registered pre filter closure + * @requires PHP 5.3 + */ + + public function testRegisteredPreFilterClosure() + { + if (version_compare(PHP_VERSION,'5.3','<')) + { + $this->markTestSkipped('does not run for PHP 5.2'); + } else { + include 'FilterClosure.php'; + } + } + + /** + * test registered pre filter class + */ + public function testRegisteredPreFilterClass() + { + $this->smarty->registerFilter(Smarty::FILTER_PRE, array('myprefilterclass', 'myprefilter')); + $tpl = $this->smarty->createTemplate('eval:{" hello world"}'); + $tpl->assign('foo', 'bar'); + $this->assertEquals("bar hello world", $this->smarty->fetch($tpl)); + } + + /** + * test registered post filter + */ + public function testRegisteredPostFilter() + { + function mypostfilter($input) + { + return '{$foo}' . $input; + } + + $this->smarty->registerFilter(Smarty::FILTER_POST, 'mypostfilter'); + $tpl = $this->smarty->createTemplate('eval:{" hello world"}'); + $tpl->assign('foo', 'bar'); + $this->assertEquals('{$foo} hello world', $this->smarty->fetch($tpl)); + } + + /** + * test variable filter + */ + public function testLoadedVariableFilter() + { + $this->smarty->loadFilter("variable", "htmlspecialchars"); + $tpl = $this->smarty->createTemplate('eval:{$foo}'); + $tpl->assign('foo', ''); + $this->assertEquals('<?php ?>', $this->smarty->fetch($tpl)); + } + + /** + * test registered post filter + */ + public function testRegisteredVariableFilter2() + { + $var = new VarFilter(); + + $this->smarty->registerFilter(Smarty::FILTER_VARIABLE, array($var, 'variablefilter')); + $tpl = $this->smarty->createTemplate('string:{$foo}'); + $tpl->assign('foo', 'bar'); + $this->assertEquals('var{$foo}bar', $this->smarty->fetch($tpl)); + } +} + +Class VarFilter +{ + function variablefilter($input, $smarty) + { + return 'var{$foo}' . $input; + } +} + +function myoutputfilter($input) +{ + return str_replace(' ', ' ', $input); +} + +function myoutputfilter2($input, $tpl) +{ + return $input . ' filter ' . $tpl->tpl_vars[ 'bar' ]; +} + +class myprefilterclass +{ + static function myprefilter($input) + { + return '{$foo}' . $input; + } +} diff --git a/tests/UnitTests/A_Core/Filter/LoadFilterTest.php b/tests/UnitTests/A_Core/Filter/LoadFilterTest.php new file mode 100644 index 00000000..f99719ab --- /dev/null +++ b/tests/UnitTests/A_Core/Filter/LoadFilterTest.php @@ -0,0 +1,31 @@ +setUpSmarty(dirname(__FILE__)); + } + + /** + * test loadFilter method + */ + public function testLoadFilter() + { + $this->smarty->loadFilter('output', 'trimwhitespace'); + $this->assertTrue(is_callable($this->smarty->registered_filters['output']['smarty_outputfilter_trimwhitespace'])); + } +} diff --git a/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php b/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php new file mode 100644 index 00000000..9bd0f0e3 --- /dev/null +++ b/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php @@ -0,0 +1,158 @@ +setUpSmarty(dirname(__FILE__)); + } + + /** + * test register->preFilter method for function + */ + public function testRegisterPrefilterFunction() + { + $this->smarty->registerFilter(Smarty::FILTER_PRE, 'myfilter'); + $this->assertTrue(is_callable($this->smarty->registered_filters['pre']['myfilter'])); + } + + /** + * test register->preFilter method for class method + */ + public function testRegisterPrefiltermethod() + { + $this->smarty->registerFilter(Smarty::FILTER_PRE, array('myfilterclass', 'execute')); + $this->assertTrue(is_callable($this->smarty->registered_filters['pre']['myfilterclass_execute'])); + } + + /** + * test register->preFilter method for class object + */ + public function testRegisterPrefilterObject() + { + $this->smarty->registerFilter(Smarty::FILTER_PRE, array(new myfilterclass, 'execute')); + $this->assertTrue(is_callable($this->smarty->registered_filters['pre']['myfilterclass_execute'])); + } + + /** + * test unregister->preFilter method for function + */ + public function testUnegisterPrefilterFunction() + { + $this->smarty->registerFilter(Smarty::FILTER_PRE, 'myfilter'); + $this->smarty->unregisterFilter(Smarty::FILTER_PRE, 'myfilter'); + $this->assertFalse(isset($this->smarty->registered_filters['pre']['myfilter'])); + } + + /** + * test unregister->preFilter method for class method + */ + public function testUnregisterPrefiltermethod() + { + $this->smarty->registerFilter(Smarty::FILTER_PRE, array('myfilterclass', 'execute')); + $this->smarty->unregisterFilter(Smarty::FILTER_PRE, array('myfilterclass', 'execute')); + $this->assertFalse(isset($this->smarty->registered_filters['pre']['myfilterclass_execute'])); + } + + /** + * test register->postFilter method for function + */ + public function testRegisterPostfilterFunction() + { + $this->smarty->registerFilter(Smarty::FILTER_POST, 'myfilter'); + $this->assertTrue(is_callable($this->smarty->registered_filters['post']['myfilter'])); + } + + /** + * test register->postFilter method for class method + */ + public function testRegisterPostfiltermethod() + { + $this->smarty->registerFilter(Smarty::FILTER_POST, array('myfilterclass', 'execute')); + $this->assertTrue(is_callable($this->smarty->registered_filters['post']['myfilterclass_execute'])); + } + + /** + * test unregister->postFilter method for function + */ + public function testUnegisterPostfilterFunction() + { + $this->smarty->registerFilter(Smarty::FILTER_POST, 'myfilter'); + $this->smarty->unregisterFilter(Smarty::FILTER_POST, 'myfilter'); + $this->assertFalse(isset($this->smarty->registered_filters['post']['myfilter'])); + } + + /** + * test unregister->postFilter method for class method + */ + public function testUnregisterPostfiltermethod() + { + $this->smarty->registerFilter(Smarty::FILTER_POST, array('myfilterclass', 'execute')); + $this->smarty->unregisterFilter(Smarty::FILTER_POST, array('myfilterclass', 'execute')); + $this->assertFalse(isset($this->smarty->registered_filters['post']['myfilterclass_execute'])); + } + + /** + * test register->outputFilter method for function + */ + public function testRegisterOutputfilterFunction() + { + $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myfilter'); + $this->assertTrue(is_callable($this->smarty->registered_filters['output']['myfilter'])); + } + + /** + * test register->outputFilter method for class method + */ + public function testRegisterOutputfiltermethod() + { + $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, array('myfilterclass', 'execute')); + $this->assertTrue(is_callable($this->smarty->registered_filters['output']['myfilterclass_execute'])); + } + + /** + * test unregister->outputFilter method for function + */ + public function testUnegisterOutputfilterFunction() + { + $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myfilter'); + $this->smarty->unregisterFilter(Smarty::FILTER_OUTPUT, 'myfilter'); + $this->assertFalse(isset($this->smarty->registered_filters['output']['myfilter'])); + } + + /** + * test unregister->outputFilter method for class method + */ + public function testUnregisterOutputfiltermethod() + { + $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, array('myfilterclass', 'execute')); + $this->smarty->unregisterFilter(Smarty::FILTER_OUTPUT, array('myfilterclass', 'execute')); + $this->assertFalse(isset($this->smarty->registered_filters['output']['myfilterclass_execute'])); + } +} + +function myfilter($input) +{ + return $input; +} + +class myfilterclass +{ + static function execute($input) + { + return $input; + } +} diff --git a/tests/UnitTests/A_Core/Filter/cache/.gitignore b/tests/UnitTests/A_Core/Filter/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/Filter/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/Filter/templates/output_001.tpl b/tests/UnitTests/A_Core/Filter/templates/output_001.tpl new file mode 100644 index 00000000..b9490d3b --- /dev/null +++ b/tests/UnitTests/A_Core/Filter/templates/output_001.tpl @@ -0,0 +1 @@ +{$foo} \ No newline at end of file diff --git a/tests/UnitTests/A_Core/Filter/templates/output_002.tpl b/tests/UnitTests/A_Core/Filter/templates/output_002.tpl new file mode 100644 index 00000000..fc4caa73 --- /dev/null +++ b/tests/UnitTests/A_Core/Filter/templates/output_002.tpl @@ -0,0 +1 @@ +{$foo nocache} \ No newline at end of file diff --git a/tests/UnitTests/A_Core/Filter/templates_c/.gitignore b/tests/UnitTests/A_Core/Filter/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/A_Core/Filter/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/A_Core/GetterSetter/GetterSetterTest.php b/tests/UnitTests/A_Core/GetterSetter/GetterSetterTest.php new file mode 100644 index 00000000..e2d46fcf --- /dev/null +++ b/tests/UnitTests/A_Core/GetterSetter/GetterSetterTest.php @@ -0,0 +1,75 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test setter on Smarty object + */ + public function testSmartySetter() + { + $this->smarty->setLeftDelimiter('<{'); + $this->smarty->setRightDelimiter('}>'); + $this->assertEquals('<{', $this->smarty->left_delimiter); + $this->assertEquals('}>', $this->smarty->right_delimiter); + } + + /** + * test getter on Smarty object + */ + public function testSmartyGetter() + { + $this->smarty->setLeftDelimiter('<{'); + $this->smarty->setRightDelimiter('}>'); + $this->assertEquals('<{', $this->smarty->getLeftDelimiter()); + $this->assertEquals('}>', $this->smarty->getRightDelimiter()); + } + + /** + * test setter on Template object + */ + public function testTemplateSetter() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $tpl->setLeftDelimiter('<{'); + $tpl->setRightDelimiter('}>'); + $this->assertEquals('<{', $tpl->smarty->left_delimiter); + $this->assertEquals('}>', $tpl->smarty->right_delimiter); + $this->assertEquals('{', $this->smarty->left_delimiter); + $this->assertEquals('}', $this->smarty->right_delimiter); + } + + /** + * test getter on Template object + */ + public function testTemplateGetter() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $tpl->setLeftDelimiter('<{'); + $tpl->setRightDelimiter('}>'); + $this->assertEquals('<{', $tpl->getLeftDelimiter()); + $this->assertEquals('}>', $tpl->getRightDelimiter()); + } +} diff --git a/tests/UnitTests/A_Core/GetterSetter/cache/.gitignore b/tests/UnitTests/A_Core/GetterSetter/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/GetterSetter/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/GetterSetter/templates_c/.gitignore b/tests/UnitTests/A_Core/GetterSetter/templates_c/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/GetterSetter/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php b/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php new file mode 100644 index 00000000..aa1764f3 --- /dev/null +++ b/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php @@ -0,0 +1,182 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->setForceCompile(true); + $this->smarty->disableSecurity(); + $this->smarty->registerDefaultPluginHandler('my_plugin_handler'); + } + + + public function testInit() + { + $this->cleanDirs(); + } + public function testDefaultFunctionScript() + { + $this->assertEquals("scriptfunction foo bar", $this->smarty->fetch('test_default_function_script.tpl')); + } + + public function testDefaultFunctionScriptNotCachable1() + { + $this->smarty->assign('foo', 'foo'); + $this->smarty->caching = 1; + $this->assertEquals("scriptfunction foo", $this->smarty->fetch('test_default_function_script_notcachable.tpl')); + } + + public function testDefaultFunctionScriptNotCachable2() + { + $this->smarty->assign('foo', 'bar'); + $this->smarty->caching = 1; + $this->assertEquals("scriptfunction bar", $this->smarty->fetch('test_default_function_script_notcachable.tpl')); + } + + public function testDefaultFunctionLocal() + { + $this->assertEquals("localfunction foo bar", $this->smarty->fetch('test_default_function_local.tpl')); + } + + public function testDefaultCompilerFunctionScript() + { + $this->assertEquals("echo 'scriptcompilerfunction '.'foo bar';", $this->smarty->fetch('test_default_compiler_function_script.tpl')); + } + public function testDefaultCompilerObject() + { + $this->assertEquals('Public World', $this->smarty->fetch('test_default_compiler_object.tpl')); + } + + public function testDefaultBlockScript() + { + $this->assertEquals("scriptblock foo bar", $this->smarty->fetch('test_default_block_script.tpl')); + } + + public function testDefaultModifierScript() + { + $this->smarty->assign('foo', 'bar'); + $this->assertEquals("scriptmodifier default bar", $this->smarty->fetch('test_default_modifier_script.tpl')); + } + + public function testDefaultModifier() + { + $this->smarty->assign('foo', 'bar'); + $this->assertEquals("localmodifier bar", $this->smarty->fetch('test_default_modifier.tpl')); + } + + public function testDefaultModifierStaticClassMethodCaching1() + { + $this->smarty->assign('foo', 'bar'); + $this->smarty->caching = 1; + $this->assertEquals("staticmodifier bar", $this->smarty->fetch('test_default_static_modifier.tpl')); + } + + public function testDefaultModifierStaticClassMethodCaching2() + { + $this->smarty->assign('foo', 'bar'); + $this->smarty->caching = 1; + $this->assertEquals("staticmodifier bar", $this->smarty->fetch('test_default_static_modifier.tpl')); + } +} + +function my_plugin_handler($tag, $type, $template, &$callback, &$script, &$cachable) +{ + switch ($type) { + case Smarty::PLUGIN_FUNCTION: + switch ($tag) { + case 'scriptfunction': + $script = './scripts/script_function_tag.php'; + $callback = 'default_script_function_tag'; + + return true; + case 'scriptfunctionnotcachable': + $script = './scripts/script_function_tag.php'; + $callback = 'default_script_function_tag'; + $cachable = false; + + return true; + case 'localfunction': + $callback = 'default_local_function_tag'; + + return true; + default: + return false; + } + case Smarty::PLUGIN_COMPILER: + switch ($tag) { + case 'scriptcompilerfunction': + $script = './scripts/script_compiler_function_tag.php'; + $callback = 'default_script_compiler_function_tag'; + return true; + case 'compilerobject': + $callback = array(new CompilerDefaultPluginClass, 'compile'); + return true; + default: + return false; + } + case Smarty::PLUGIN_BLOCK: + switch ($tag) { + case 'scriptblock': + $script = './scripts/script_block_tag.php'; + $callback = 'default_script_block_tag'; + + return true; + default: + return false; + } + case Smarty::PLUGIN_MODIFIER: + switch ($tag) { + case 'scriptmodifier': + $script = './scripts/script_modifier.php'; + $callback = 'default_script_modifier'; + + return true; + case 'mydefaultmodifier': + $callback = 'default_local_modifier'; + + return true; + case 'mydefaultstaticmodifier': + $script = './scripts/script_default_static_modifier.php'; + $callback = array('DefModifier', 'default_static_modifier'); + + return true; + default: + return false; + } + default: + return false; + } +} + +function default_local_function_tag($params, $template) +{ + return 'localfunction ' . $params['value']; +} + +function default_local_modifier($input) +{ + return 'localmodifier ' . $input; +} +class CompilerDefaultPluginClass +{ + static function statCompile ($params, $compiler) { + return ''; + } + public function compile ($params, $compiler) { + return ''; + } +} \ No newline at end of file diff --git a/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php b/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php new file mode 100644 index 00000000..2a3b46b7 --- /dev/null +++ b/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php @@ -0,0 +1,51 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->use_include_path = true; + $this->smarty->setPluginsDir(array('./include','./include1')); + $this->smarty->enableSecurity(); + $ds = DIRECTORY_SEPARATOR; + set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$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() + { + ini_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/A_Core/LoadPlugin/LoadPluginTest.php b/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php new file mode 100644 index 00000000..0b9a918a --- /dev/null +++ b/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php @@ -0,0 +1,54 @@ +setUpSmarty(dirname(__FILE__)); + } + + /** + * loadPlugin test unkown plugin + */ + public function testLoadPluginErrorReturn() + { + $this->assertFalse($this->smarty->loadPlugin('Smarty_Not_Known')); + } + + /** + * loadPlugin test Smarty_Internal_Debug exists + */ + public function testLoadPluginSmartyInternalDebug() + { + $this->assertTrue($this->smarty->loadPlugin('Smarty_Internal_Debug') == true); + } + + /** + * loadPlugin test $template_class exists + */ + public function testLoadPluginSmartyTemplateClass() + { + $this->assertTrue($this->smarty->loadPlugin($this->smarty->template_class) == true); + } + + /** + * loadPlugin test loaging from plugins_dir + */ + public function testLoadPluginSmartyPluginCounter() + { + $this->assertTrue($this->smarty->loadPlugin('Smarty_Function_Counter') == true); + } +} diff --git a/tests/UnitTests/A_Core/LoadPlugin/cache/.gitignore b/tests/UnitTests/A_Core/LoadPlugin/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/LoadPlugin/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file 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 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + public function error_handler($errno, $errstr, $errfile, $errline, $errcontext) + { + $this->_errors[] = $errfile . ' line ' . $errline; + } + + public function testMuted() + { + set_error_handler(array($this, 'error_handler')); + Smarty::muteExpectedErrors(); + + $this->smarty->clearCache('default.tpl'); + $this->smarty->clearCompiledTemplate('default.tpl'); + $this->smarty->fetch('default.tpl'); + + $this->assertEquals($this->_errors, array()); + + @filemtime('ckxladanwijicajscaslyxck'); + $error = array(__FILE__ . ' line ' . (__LINE__ - 1)); + $this->assertEquals($this->_errors, $error); + + Smarty::unmuteExpectedErrors(); + restore_error_handler(); + } + + /** + * + * @rrunInSeparateProcess + * + */ + public function testUnmuted() + { + set_error_handler(array($this, 'error_handler')); + + $this->smarty->clearCache('default.tpl'); + $this->smarty->clearCompiledTemplate('default.tpl'); + $this->smarty->fetch('default.tpl'); + + $this->assertEquals(Smarty::$_IS_WINDOWS ? 2 : 2, count($this->_errors)); + + @filemtime('ckxladanwijicajscaslyxck'); + $this->assertEquals(Smarty::$_IS_WINDOWS ? 3 : 3, count($this->_errors)); + + restore_error_handler(); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testMutedCaching() + { + set_error_handler(array($this, 'error_handler')); + Smarty::muteExpectedErrors(); + + $this->smarty->caching = true; + $this->smarty->clearCache('default.tpl'); + $this->smarty->clearCompiledTemplate('default.tpl'); + $this->smarty->fetch('default.tpl'); + + $this->assertEquals($this->_errors, array()); + + @filemtime('ckxladanwijicajscaslyxck'); + $error = array(__FILE__ . ' line ' . (__LINE__ - 1)); + $this->assertEquals($error, $this->_errors); + + Smarty::unmuteExpectedErrors(); + restore_error_handler(); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testUnmutedCaching() + { + set_error_handler(array($this, 'error_handler')); + + $this->smarty->caching = true; + $this->smarty->clearCache('default.tpl'); + $this->smarty->clearCompiledTemplate('default.tpl'); + $this->smarty->fetch('default.tpl'); + + $this->assertEquals(Smarty::$_IS_WINDOWS ? 2 : 2, count($this->_errors)); + + @filemtime('ckxladanwijicajscaslyxck'); + $error = array(__FILE__ . ' line ' . (__LINE__ - 1)); + $this->assertEquals(Smarty::$_IS_WINDOWS ? 3 : 3, count($this->_errors)); + + restore_error_handler(); + } +} diff --git a/tests/UnitTests/A_Core/MuteExpectedErrors/cache/.gitignore b/tests/UnitTests/A_Core/MuteExpectedErrors/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/MuteExpectedErrors/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/MuteExpectedErrors/templates/default.tpl b/tests/UnitTests/A_Core/MuteExpectedErrors/templates/default.tpl new file mode 100644 index 00000000..585945d3 --- /dev/null +++ b/tests/UnitTests/A_Core/MuteExpectedErrors/templates/default.tpl @@ -0,0 +1 @@ +{$foo|default:""} /* should compile something with @silence error suppression */ \ No newline at end of file diff --git a/tests/UnitTests/A_Core/MuteExpectedErrors/templates_c/.gitignore b/tests/UnitTests/A_Core/MuteExpectedErrors/templates_c/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/MuteExpectedErrors/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain1.php b/tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain1.php new file mode 100644 index 00000000..64b6f05d --- /dev/null +++ b/tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain1.php @@ -0,0 +1,7 @@ +smarty->loadPlugin('smarty_function_chain2'); + + return smarty_function_chain2($params, $tpl); +} diff --git a/tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain2.php b/tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain2.php new file mode 100644 index 00000000..480ba0e0 --- /dev/null +++ b/tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain2.php @@ -0,0 +1,7 @@ +smarty->loadPlugin('smarty_function_chain3'); + + return smarty_function_chain3($params, $tpl); +} diff --git a/tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain3.php b/tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain3.php new file mode 100644 index 00000000..6c0f9920 --- /dev/null +++ b/tests/UnitTests/A_Core/PluginTests/PHPunitplugins/function.chain3.php @@ -0,0 +1,5 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testPluginChainedLoad() + { + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->assertContains('from chain3', $this->smarty->fetch('test_plugin_chained_load.tpl')); + } +} diff --git a/tests/UnitTests/A_Core/PluginTests/Shared/SharedFunctionsTest.php b/tests/UnitTests/A_Core/PluginTests/Shared/SharedFunctionsTest.php new file mode 100644 index 00000000..2ecafd32 --- /dev/null +++ b/tests/UnitTests/A_Core/PluginTests/Shared/SharedFunctionsTest.php @@ -0,0 +1,29 @@ +setUpSmarty(dirname(__FILE__)); + } + + /** + * test smarty_function_escape_special_chars() + */ + public function testEscapeSpecialChars() + { + require_once SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'; + + $this->assertEquals('hello<world ©', smarty_function_escape_special_chars('helloassertEquals('ö€', smarty_function_escape_special_chars('ö€')); + } +} diff --git a/tests/UnitTests/A_Core/PluginTests/Shared/cache/.gitignore b/tests/UnitTests/A_Core/PluginTests/Shared/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/PluginTests/Shared/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/PluginTests/Shared/templates_c/.gitignore b/tests/UnitTests/A_Core/PluginTests/Shared/templates_c/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/PluginTests/Shared/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/PluginTests/cache/.gitignore b/tests/UnitTests/A_Core/PluginTests/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/PluginTests/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/PluginTests/helpers/_object_tostring.php b/tests/UnitTests/A_Core/PluginTests/helpers/_object_tostring.php new file mode 100644 index 00000000..4cb55e7f --- /dev/null +++ b/tests/UnitTests/A_Core/PluginTests/helpers/_object_tostring.php @@ -0,0 +1,26 @@ +string = (string) $string; + } + + public function __toString() + { + return $this->string; + } +} + +class _object_noString +{ + protected $string = null; + + public function __construct($string) + { + $this->string = (string) $string; + } +} diff --git a/tests/UnitTests/A_Core/PluginTests/templates/test_plugin_chained_load.tpl b/tests/UnitTests/A_Core/PluginTests/templates/test_plugin_chained_load.tpl new file mode 100644 index 00000000..3badb70f --- /dev/null +++ b/tests/UnitTests/A_Core/PluginTests/templates/test_plugin_chained_load.tpl @@ -0,0 +1 @@ +{chain1} \ No newline at end of file diff --git a/tests/UnitTests/A_Core/PluginTests/templates_c/.gitignore b/tests/UnitTests/A_Core/PluginTests/templates_c/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/PluginTests/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/SmartyBC/SmartyBcTest.php b/tests/UnitTests/A_Core/SmartyBC/SmartyBcTest.php new file mode 100644 index 00000000..988d1a4a --- /dev/null +++ b/tests/UnitTests/A_Core/SmartyBC/SmartyBcTest.php @@ -0,0 +1,37 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {php} tag + */ + public function testSmartyPhpTag() + { + $this->assertEquals('hello world', $this->smartyBC->fetch('string:{php} echo "hello world"; {/php}')); + } +} diff --git a/tests/UnitTests/A_Core/SmartyBC/cache/.gitignore b/tests/UnitTests/A_Core/SmartyBC/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/SmartyBC/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/A_Core/SmartyBC/templates_c/.gitignore b/tests/UnitTests/A_Core/SmartyBC/templates_c/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/UnitTests/A_Core/SmartyBC/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php b/tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php new file mode 100644 index 00000000..d59577c5 --- /dev/null +++ b/tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php @@ -0,0 +1,148 @@ +markTestSkipped('modified since tests are disabled'); + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * + */ + public function testDisabled() + { + $_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'] = true; + $_SERVER['SMARTY_PHPUNIT_HEADERS'] = array(); + + $this->smarty->setCacheModifiedCheck(false); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 20; + ob_start(); + $this->smarty->display('helloworld.tpl'); + $output = ob_get_contents(); + ob_end_clean(); + $this->assertEquals('hello world', $output); + $this->assertEquals('', join("\r\n", $_SERVER['SMARTY_PHPUNIT_HEADERS'])); + + unset($_SERVER['HTTP_IF_MODIFIED_SINCE']); + unset($_SERVER['SMARTY_PHPUNIT_HEADERS']); + unset($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']); + } + + /** + * + */ + public function testEnabledUncached() + { + $_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'] = true; + $_SERVER['SMARTY_PHPUNIT_HEADERS'] = array(); + + $this->smarty->setCacheModifiedCheck(true); + $this->smarty->caching = false; + $this->smarty->cache_lifetime = 20; + ob_start(); + $this->smarty->display('helloworld.tpl'); + $output = ob_get_contents(); + ob_end_clean(); + $this->assertEquals('hello world', $output); + $this->assertEquals('', join("\r\n", $_SERVER['SMARTY_PHPUNIT_HEADERS'])); + + unset($_SERVER['HTTP_IF_MODIFIED_SINCE']); + unset($_SERVER['SMARTY_PHPUNIT_HEADERS']); + unset($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']); + } + + /** + * + */ + public function testEnabledCached() + { + $_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'] = true; + $_SERVER['SMARTY_PHPUNIT_HEADERS'] = array(); + + $this->smarty->setCacheModifiedCheck(true); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 20; + + ob_start(); + $l1 = ob_get_level(); + $this->smarty->display('helloworld.tpl'); + $l2 = ob_get_level(); + $output = ob_get_contents(); + ob_end_clean(); + $this->assertEquals('hello world', $output); + $t1 = time(); + $t2 = strtotime(substr( $_SERVER['SMARTY_PHPUNIT_HEADERS'][0],15)); + $this->assertTrue(($t2-$t1) <= 1); + } + + /** + * + */ + public function testEnabledCached2() + { + + $_SERVER['SMARTY_PHPUNIT_HEADERS'] = array(); + $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', time() - 3600) . ' GMT'; + $this->smarty->setCacheModifiedCheck(true); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 20; + ob_start(); + $l3 = ob_get_level(); + $this->smarty->display('helloworld.tpl'); + $l4 = ob_get_level(); + $output = ob_get_contents(); + ob_end_clean(); + $this->assertEquals('hello world', $output); + $t1 = time(); + $t2 = strtotime(substr( $_SERVER['SMARTY_PHPUNIT_HEADERS'][0],15)); + $this->assertTrue(($t2-$t1) <= 1); + } + + /** + * + */ + public function testEnabledCached3() + { + + $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; + $_SERVER['SMARTY_PHPUNIT_HEADERS'] = array(); + $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', time() + 10) . ' GMT'; + $this->smarty->setCacheModifiedCheck(true); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 20; + ob_start(); + $l5 = ob_get_level(); + $this->smarty->display('helloworld.tpl'); + $l6 = ob_get_level(); + $output = ob_get_contents(); + ob_end_clean(); + $this->assertEquals('', $output); + $this->assertEquals('304 Not Modified', join("\r\n", $_SERVER['SMARTY_PHPUNIT_HEADERS'])); + + unset($_SERVER['HTTP_IF_MODIFIED_SINCE']); + unset($_SERVER['SMARTY_PHPUNIT_HEADERS']); + unset($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']); + } +} diff --git a/tests/UnitTests/CacheModify/ModifiedSince/cache/.gitignore b/tests/UnitTests/CacheModify/ModifiedSince/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/CacheModify/ModifiedSince/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/CacheModify/ModifiedSince/templates/helloworld.tpl b/tests/UnitTests/CacheModify/ModifiedSince/templates/helloworld.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/CacheModify/ModifiedSince/templates/helloworld.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/CacheModify/ModifiedSince/templates_c/.gitignore b/tests/UnitTests/CacheModify/ModifiedSince/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/CacheModify/ModifiedSince/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php b/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php new file mode 100644 index 00000000..3032a91e --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php @@ -0,0 +1,36 @@ +markTestSkipped('Apc tests are disabled'); + } else { + if (!function_exists('apc_cache_info') || ini_get('apc.enable_cli')) { + $this->markTestSkipped('APC cache not available'); + } + } + $this->setUpSmarty(dirname(__FILE__)); + parent::setUp(); + $this->smarty->setCachingType('apc'); + $this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/'); + } + } +} + diff --git a/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php b/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php new file mode 100644 index 00000000..dda616a8 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php @@ -0,0 +1,383 @@ +setUpSmarty(dirname(__FILE__)); + parent::setUp(); + $this->smarty->setCachingType('filetest'); + } + + + public function testInit() + + { + $this->cleanDirs(); + } + + /** + * test getCachedFilepath with configuration['useSubDirs'] enabled + */ + public function testGetCachedFilepathSubDirs() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(true); + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertEquals($this->buildCachedPath($tpl, true, null, null, 'helloworld.tpl', $type = 'file', $this->smarty->getTemplateDir(0), 'file') + , $tpl->cached->filepath); + } + + /** + * test getCachedFilepath with cache_id + */ + public function testGetCachedFilepathCacheId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(true); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar'); + $this->assertEquals($this->buildCachedPath($tpl, true, 'foo|bar', null, 'helloworld.tpl', $type = 'file', $this->smarty->getTemplateDir(0), 'file') + , $tpl->cached->filepath); + } + + /** + * test getCachedFilepath with compile_id + */ + public function testGetCachedFilepathCompileId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(true); + $tpl = $this->smarty->createTemplate('helloworld.tpl', null, 'blar'); + $this->assertEquals($this->buildCachedPath($tpl, true, null, 'blar', 'helloworld.tpl', $type = 'file', $this->smarty->getTemplateDir(0), 'file') + , $tpl->cached->filepath); + } + + /** + * test getCachedFilepath with cache_id and compile_id + */ + public function testGetCachedFilepathCacheIdCompileId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(true); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->assertEquals($this->buildCachedPath($tpl, true, 'foo|bar', 'blar', 'helloworld.tpl', $type = 'file', $this->smarty->getTemplateDir(0), 'file') + , $tpl->cached->filepath); + } + + /** + * test cache->clear_all with cache_id and compile_id + */ + public function testClearCacheAllCacheIdCompileId() + { + $this->cleanCacheDir(); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(true); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertEquals(1, $this->smarty->clearAllCache()); + } + + /** + * test cache->clear with cache_id and compile_id + */ + public function testClearCacheCacheIdCompileId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->cleanCacheDir(); + $this->smarty->setUseSubDirs(false); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar2', 'blar'); + $this->writeCachedContent($tpl2); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl3); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + $this->assertEquals(2, $this->smarty->clearCache(null, 'foo|bar')); + $this->assertFalse(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertFalse(file_exists($tpl3->cached->filepath)); + } + + public function testClearCacheCacheIdCompileId2() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(false); + $this->cleanCacheDir(); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar2', 'blar'); + $this->writeCachedContent($tpl2); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl3); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + $this->assertEquals(2, $this->smarty->clearCache('helloworld.tpl')); + $this->assertFalse(file_exists($tpl->cached->filepath)); + $this->assertFalse(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + } + + public function testClearCacheCacheIdCompileId2Sub() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(true); + $this->cleanCacheDir(); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar2', 'blar'); + $this->writeCachedContent($tpl2); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl3); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + $this->assertEquals(2, $this->smarty->clearCache('helloworld.tpl')); + $this->assertFalse(file_exists($tpl->cached->filepath)); + $this->assertFalse(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + } + + public function testClearCacheCacheIdCompileId3() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->cleanCacheDir(); + $this->smarty->setUseSubDirs(false); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $this->writeCachedContent($tpl2); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl3); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + $this->assertEquals(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2')); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertFalse(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + } + + public function testClearCacheCacheIdCompileId3Sub() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->cleanCacheDir(); + $this->smarty->setUseSubDirs(true); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $this->writeCachedContent($tpl2); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl3); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + $this->assertEquals(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2')); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertFalse(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + } + + public function testClearCacheCacheIdCompileId4() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(false); + $this->cleanCacheDir(); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $this->writeCachedContent($tpl2); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl3); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + $this->assertEquals(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2')); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertFalse(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + } + + public function testClearCacheCacheIdCompileId4Sub() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(true); + $this->cleanCacheDir(); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $this->writeCachedContent($tpl2); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl3); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + $this->assertEquals(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2')); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertFalse(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + } + + public function testClearCacheCacheIdCompileId5() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(false); + $this->cleanCacheDir(); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $this->writeCachedContent($tpl2); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl3); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + $this->assertEquals(2, $this->smarty->clearCache(null, null, 'blar')); + $this->assertFalse(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertFalse(file_exists($tpl3->cached->filepath)); + } + + public function testClearCacheCacheIdCompileId5Sub() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(true); + $this->cleanCacheDir(); + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $this->writeCachedContent($tpl2); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $this->writeCachedContent($tpl3); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + $this->assertEquals(2, $this->smarty->clearCache(null, null, 'blar')); + $this->assertFalse(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertFalse(file_exists($tpl3->cached->filepath)); + } + + public function testClearCacheCacheFile() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(false); + $this->cleanCacheDir(); + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->writeCachedContent($tpl); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', null, 'bar'); + $this->writeCachedContent($tpl2); + $tpl3 = $this->smarty->createTemplate('helloworld.tpl', 'buh|blar'); + $this->writeCachedContent($tpl3); + $tpl4 = $this->smarty->createTemplate('helloworld2.tpl'); + $this->writeCachedContent($tpl4); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + $this->assertTrue(file_exists($tpl4->cached->filepath)); + $this->assertEquals(3, $this->smarty->clearCache('helloworld.tpl')); + $this->assertFalse(file_exists($tpl->cached->filepath)); + $this->assertFalse(file_exists($tpl2->cached->filepath)); + $this->assertFalse(file_exists($tpl3->cached->filepath)); + $this->assertTrue(file_exists($tpl4->cached->filepath)); + } + + public function testClearCacheCacheFileSub() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(true); + $this->cleanCacheDir(); + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->writeCachedContent($tpl); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', null, 'bar'); + $this->writeCachedContent($tpl2); + $tpl3 = $this->smarty->createTemplate('helloworld.tpl', 'buh|blar'); + $this->writeCachedContent($tpl3); + $tpl4 = $this->smarty->createTemplate('helloworld2.tpl'); + $this->writeCachedContent($tpl4); + $this->assertTrue(file_exists($tpl->cached->filepath)); + $this->assertTrue(file_exists($tpl2->cached->filepath)); + $this->assertTrue(file_exists($tpl3->cached->filepath)); + $this->assertTrue(file_exists($tpl4->cached->filepath)); + $this->assertEquals(3, $this->smarty->clearCache('helloworld.tpl')); + $this->assertFalse(file_exists($tpl->cached->filepath)); + $this->assertFalse(file_exists($tpl2->cached->filepath)); + $this->assertFalse(file_exists($tpl3->cached->filepath)); + $this->assertTrue(file_exists($tpl4->cached->filepath)); + } + + /** + * test cache->clear_all method + */ + public function testClearCacheAll() + { + $this->cleanCacheDir(); + file_put_contents($this->smarty->getCacheDir() . 'dummy.php', 'test'); + $this->assertEquals(1, $this->smarty->clearAllCache()); + } + + /** + * test cache->clear_all method not expired + */ + public function testClearCacheAllNotExpired() + { + $this->cleanCacheDir(); + file_put_contents($this->smarty->getCacheDir() . 'dummy.php', 'test'); + touch($this->smarty->getCacheDir() . 'dummy.php', time() - 1000); + clearstatcache(); + $this->assertEquals(0, $this->smarty->clearAllCache(2000)); + } + + /** + * test cache->clear_all method expired + */ + public function testClearCacheAllExpired() + { + $this->cleanCacheDir(); + file_put_contents($this->smarty->getCacheDir() . 'dummy.php', 'test'); + touch($this->smarty->getCacheDir() . 'dummy.php', time() - 1000); + clearstatcache(); + $this->assertEquals(1, $this->smarty->clearAllCache(500)); + } + + + private function writeCachedContent($tpl) + { + $tpl->writeCachedContent("echo 'hello world';\n"); + } +} diff --git a/tests/UnitTests/CacheResourceTests/File/cache/.gitignore b/tests/UnitTests/CacheResourceTests/File/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/File/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/CacheResourceTests/File/templates_c/.gitignore b/tests/UnitTests/CacheResourceTests/File/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/File/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php b/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php new file mode 100644 index 00000000..d8d9df1b --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php @@ -0,0 +1,97 @@ +markTestSkipped('Memcache tests are disabled'); + } else { + if (!class_exists('Memcache')) { + $this->markTestSkipped('Memcache not available'); + } + } + $this->setUpSmarty(dirname(__FILE__)); + parent::setUp(); + $this->smarty->setCachingType('memcachetest'); + } + + public function testInit() + { + $this->cleanDirs(); + } + + protected function doClearCacheAssertion($a, $b) + { + $this->assertEquals(- 1, $b); + } + + public function testGetCachedFilepathSubDirs() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $tpl->loadCached(); + $sha1 = $tpl->source->uid . '#helloworld_tpl##'; + $this->assertEquals($sha1, $tpl->cached->filepath); + } + + /** + * test getCachedFilepath with cache_id + */ + public function testGetCachedFilepathCacheId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar'); + $tpl->loadCached(); + $sha1 = $tpl->source->uid . '#helloworld_tpl#foo|bar#'; + $this->assertEquals($sha1, $tpl->cached->filepath); + } + + /** + * test getCachedFilepath with compile_id + */ + public function testGetCachedFilepathCompileId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl', null, 'blar'); + $tpl->loadCached(); + $sha1 = $tpl->source->uid . '#helloworld_tpl##blar'; + $this->assertEquals($sha1, $tpl->cached->filepath); + } + + /** + * test getCachedFilepath with cache_id and compile_id + */ + public function testGetCachedFilepathCacheIdCompileId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $tpl->loadCached(); + $sha1 = $tpl->source->uid . '#helloworld_tpl#foo|bar#blar'; + $this->assertEquals($sha1, $tpl->cached->filepath); + } +} diff --git a/tests/UnitTests/CacheResourceTests/Memcache/templates_c/.gitignore b/tests/UnitTests/CacheResourceTests/Memcache/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/Memcache/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php b/tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php new file mode 100644 index 00000000..eec3fc20 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php @@ -0,0 +1,43 @@ +markTestSkipped('mysql tests are disabled'); + } + if (self::$init) { + $this->getConnection(); + } + $this->setUpSmarty(dirname(__FILE__)); + parent::setUp(); + $this->smarty->setCachingType('mysqltest'); + } + + public function testInit() + { + $this->cleanDirs(); + $this->initMysqlCache(); + } + } +} + diff --git a/tests/UnitTests/CacheResourceTests/Mysql/cache/.gitignore b/tests/UnitTests/CacheResourceTests/Mysql/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/Mysql/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/CacheResourceTests/Mysql/templates_c/.gitignore b/tests/UnitTests/CacheResourceTests/Mysql/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/Mysql/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php b/tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php new file mode 100644 index 00000000..cd025d6b --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php @@ -0,0 +1,47 @@ +markTestSkipped('mysql Pdo tests are disabled'); + } + if (self::$init) { + $this->getConnection(); + } + $this->setUpSmarty(dirname(__FILE__)); + parent::setUp(); + $this->smarty->setCachingType('pdo'); + $this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/'); + $this->assertTrue(false !== $this->smarty->loadPlugin('Smarty_CacheResource_Pdotest'), + 'loadPlugin() could not load PDO cache resource'); + $this->smarty->registerCacheResource('pdo', + new Smarty_CacheResource_Pdotest($this->getPDO(), 'output_cache')); + } + + public function testInit() + { + $this->cleanDirs(); + $this->initMysqlCache(); + } + } +} + diff --git a/tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php b/tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php new file mode 100644 index 00000000..3017232c --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php @@ -0,0 +1,45 @@ +markTestSkipped('mysql Pdo Gzip tests are disabled'); + } + if (self::$init) { + $this->getConnection(); + } + $this->setUpSmarty(dirname(__FILE__)); + parent::setUp(); + $this->smarty->setCachingType('pdo'); + $this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/'); + $this->assertTrue(false !== $this->smarty->loadPlugin('Smarty_CacheResource_Pdo_Gziptest'), + 'loadPlugin() could not load PDOGzip cache resource'); + $this->smarty->registerCacheResource('pdo', new Smarty_CacheResource_Pdo_Gziptest($this->getPDO(), + 'output_cache')); + } + + public function testInit() + { + $this->cleanDirs(); + $this->initMysqlCache(); + } + } +} + diff --git a/tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php b/tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php new file mode 100644 index 00000000..8b03e7b3 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php @@ -0,0 +1,44 @@ +markTestSkipped('mysql tests are disabled'); + } + if (self::$init) { + $this->getConnection(); + } + $this->setUpSmarty(dirname(__FILE__)); + parent::setUp(); + if (!class_exists('Smarty_CacheResource_Mysqltest', false)) { + require_once(dirname(__FILE__) . "/../_shared/PHPunitplugins/cacheresource.mysqltest.php"); + } + $this->smarty->setCachingType('foobar'); + $this->smarty->registerCacheResource('foobar', new Smarty_CacheResource_Mysqltest()); + } + + public function testInit() + { + $this->cleanDirs(); + $this->initMysqlCache(); + } + } +} + diff --git a/tests/UnitTests/CacheResourceTests/Registered/templates_c/.gitignore b/tests/UnitTests/CacheResourceTests/Registered/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/Registered/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php b/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php new file mode 100644 index 00000000..7deaebd2 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php @@ -0,0 +1,569 @@ +smarty->setTemplateDir(dirname(__FILE__) . '/templates'); + $this->smarty->addPluginsDir(dirname(__FILE__) . '/PHPunitplugins'); + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + } + + + protected function doClearCacheAssertion($a, $b) + { + $this->assertEquals($a, $b); + } + + public function compiledPrefilter($text, Smarty_Internal_Template $tpl) + { + return str_replace('#', $tpl->getTemplateVars('test'), $text); + } + + /** + * test getCachedFilepath with configuration['useSubDirs'] enabled + */ + public function testGetCachedFilepathSubDirs() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setUseSubDirs(true); + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertEquals($this->buildCachedPath($tpl), $tpl->cached->filepath); + } + + /** + * test getCachedFilepath with cache_id + */ + public function testGetCachedFilepathCacheId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar'); + $this->assertEquals($this->buildCachedPath($tpl, true, 'foo|bar'), $tpl->cached->filepath); + } + + /** + * test getCachedFilepath with compile_id + */ + public function testGetCachedFilepathCompileId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl', null, 'blar'); + $this->assertEquals($this->buildCachedPath($tpl, true, null, 'blar'), $tpl->cached->filepath); + } + + /** + * test getCachedFilepath with cache_id and compile_id + */ + public function testGetCachedFilepathCacheIdCompileId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $this->assertEquals($this->buildCachedPath($tpl, true, 'foo|bar', 'blar'), $tpl->cached->filepath); + } + + /** + * test cache->clear_all with cache_id and compile_id + */ + public function testClearCacheAllCacheIdCompileId() + { + $this->smarty->clearAllCache(); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $tpl->writeCachedContent('hello world'); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + // Custom CacheResources may return -1 if they can't tell the number of deleted elements + //$this->assertEquals(-1, $this->smarty->clearAllCache()); + } + + /** + * test cache->clear with cache_id and compile_id + */ + public function testClearCacheCacheIdCompileId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $tpl->writeCachedContent('hello world 1'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar2', 'blar'); + $tpl2->writeCachedContent('hello world 2'); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $tpl3->writeCachedContent('hello world 3'); + // test cached content + $this->assertEquals('hello world 1', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world 2', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world 3', $tpl->cached->handler->getCachedContent($tpl3)); + // test number of deleted caches + $this->doClearCacheAssertion(2, $this->smarty->clearCache(null, 'foo|bar')); + // test that caches are deleted properly + $this->assertNull($tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world 2', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl3)); + } + + public function testClearCacheCacheIdCompileId2() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $tpl->writeCachedContent('hello world'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar2', 'blar'); + $tpl2->writeCachedContent('hello world'); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $tpl3->writeCachedContent('hello world'); + // test cached content + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + // test number of deleted caches + $this->doClearCacheAssertion(2, $this->smarty->clearCache('helloworld.tpl')); + // test that caches are deleted properly + $this->assertNull($tpl->cached->handler->getCachedContent($tpl)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + } + + public function testClearCacheCacheIdCompileId2Sub() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $tpl->writeCachedContent('hello world'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar2', 'blar'); + $tpl2->writeCachedContent('hello world'); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $tpl3->writeCachedContent('hello world'); + // test cached content + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + // test number of deleted caches + $this->doClearCacheAssertion(2, $this->smarty->clearCache('helloworld.tpl')); + // test that caches are deleted properly + $this->assertNull($tpl->cached->handler->getCachedContent($tpl)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + } + + public function testClearCacheCacheIdCompileId3() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $tpl->writeCachedContent('hello world'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $tpl2->writeCachedContent('hello world'); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $tpl3->writeCachedContent('hello world'); + // test cached content + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + // test number of deleted caches + $this->doClearCacheAssertion(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2')); + // test that caches are deleted properly + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + } + + public function testClearCacheCacheIdCompileId3Sub() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $tpl->writeCachedContent('hello world'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $tpl2->writeCachedContent('hello world'); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $tpl3->writeCachedContent('hello world'); + // test cached content + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + // test number of deleted caches + $this->doClearCacheAssertion(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2')); + // test that caches are deleted properly + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + } + + public function testClearCacheCacheIdCompileId4() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $tpl->writeCachedContent('hello world'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $tpl2->writeCachedContent('hello world'); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $tpl3->writeCachedContent('hello world'); + // test cached content + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + // test number of deleted caches + $this->doClearCacheAssertion(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2')); + // test that caches are deleted properly + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + } + + public function testClearCacheCacheIdCompileId4Sub() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $tpl->writeCachedContent('hello world'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $tpl2->writeCachedContent('hello world'); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $tpl3->writeCachedContent('hello world'); + // test cached content + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + // test number of deleted caches + $this->doClearCacheAssertion(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2')); + // test that caches are deleted properly + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + } + + public function testClearCacheCacheIdCompileId5() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $tpl->writeCachedContent('hello world'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $tpl2->writeCachedContent('hello world'); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $tpl3->writeCachedContent('hello world'); + // test cached content + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + // test number of deleted caches + $this->doClearCacheAssertion(2, $this->smarty->clearCache(null, null, 'blar')); + // test that caches are deleted properly + $this->assertNull($tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl3)); + } + + public function testClearCacheCacheIdCompileId5Sub() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); + $tpl->writeCachedContent('hello world'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar2'); + $tpl2->writeCachedContent('hello world'); + $tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar'); + $tpl3->writeCachedContent('hello world'); + // test cached content + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + // test number of deleted caches + $this->doClearCacheAssertion(2, $this->smarty->clearCache(null, null, 'blar')); + // test that caches are deleted properly + $this->assertNull($tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl3)); + } + + public function testClearCacheCacheFile() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $tpl->writeCachedContent('hello world'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', null, 'bar'); + $tpl2->writeCachedContent('hello world'); + $tpl3 = $this->smarty->createTemplate('helloworld.tpl', 'buh|blar'); + $tpl3->writeCachedContent('hello world'); + $tpl4 = $this->smarty->createTemplate('helloworld2.tpl'); + $tpl4->writeCachedContent('hello world'); + // test cached content + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4)); + // test number of deleted caches + $this->doClearCacheAssertion(3, $this->smarty->clearCache('helloworld.tpl')); + // test that caches are deleted properly + $this->assertNull($tpl->cached->handler->getCachedContent($tpl)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl2)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl3)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4)); + } + public function testClearCacheExpired() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $tpl->writeCachedContent('hello world'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', null, 'bar'); + $tpl2->writeCachedContent('hello world'); + $tpl3 = $this->smarty->createTemplate('helloworld.tpl', 'buh|blar'); + $tpl3->writeCachedContent('hello world'); + // test cached content + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + sleep(10); + $tpl4 = $this->smarty->createTemplate('helloworld2.tpl'); + $tpl4->writeCachedContent('hello world'); + // test number of deleted caches + $this->doClearCacheAssertion(3,$this->smarty->clearAllCache(5)); + // test that caches are deleted properly + $this->assertNull($tpl->cached->handler->getCachedContent($tpl)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl2)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl3)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4)); + } + + public function testClearCacheCacheFileSub() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->clearAllCache(); + // create and cache templates + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $tpl->writeCachedContent('hello world'); + $tpl2 = $this->smarty->createTemplate('helloworld.tpl', null, 'bar'); + $tpl2->writeCachedContent('hello world'); + $tpl3 = $this->smarty->createTemplate('helloworld.tpl', 'buh|blar'); + $tpl3->writeCachedContent('hello world'); + $tpl4 = $this->smarty->createTemplate('helloworld2.tpl'); + $tpl4->writeCachedContent('hello world'); + // test cached content + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4)); + // test number of deleted caches + $this->doClearCacheAssertion(3, $this->smarty->clearCache('helloworld.tpl')); + // test that caches are deleted properly + $this->assertNull($tpl->cached->handler->getCachedContent($tpl)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl2)); + $this->assertNull($tpl->cached->handler->getCachedContent($tpl3)); + $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4)); + } + /** + * Test caching + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + * + */ + public function testCache($lockTime, $lockTimeout, $compile_id, $cache_id, $isCached, $tmin, $tmax, $forceCompile, $forceCache, $update, $testNumber, $compileTestNumber, $renderTestNumber, $testName) + { + if ($testNumber == 13) { + $i =0; + } + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('test', $testNumber); + if ($lockTimeout) { + $this->smarty->cache_locking = true; + $this->smarty->locking_timeout = $lockTimeout; + } + $this->smarty->compile_id = $compile_id; + $this->smarty->cache_id = $cache_id; + $this->smarty->force_compile = $forceCompile; + $this->smarty->force_cache = $forceCache; + if ($update) { + sleep(1); + $filepath = $this->buildSourcePath(null, 'cacheresource.tpl', 'file'); + touch($filepath, $t = time()); + clearstatcache(); + } + $tpl = $this->smarty->createTemplate('cacheresource.tpl', $this->smarty); + if ($update) { + $this->assertEquals($t,$tpl->source->getTimeStamp(), $testName . ' - source touch'); + } + if ($lockTime) { + $tpl->cached->handler->acquireLock($this->smarty, $tpl->cached); + $tpl->cached->handler->lockTime = $lockTime; + $tpl->cached->is_locked = false; + } + $start = time(); + if (isset($isCached)) { + $this->assertEquals($isCached, $tpl->isCached(), $testName . ' - isCached()'); + if ($lockTimeout) { + $time = time() - $start; + $this->assertTrue($time >= $tmin && $time <= $tmax, $testName . ' - isCached() - lock time'); + $this->assertEquals(!$isCached, $tpl->cached->handler->hasLock($this->smarty, $tpl->cached), $testName . ' - isCached() - lock status'); + } else { + $this->assertFalse($tpl->cached->handler->hasLock($this->smarty, $tpl->cached), $testName . ' - isCached() - unexpected lock'); + } + } + $this->assertEquals("cache resource test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $this->smarty->fetch($tpl), $testName . ' - fetch() failure'); + if ($lockTime) { + $time = time() - $start; + $this->assertTrue($time >= $tmin && $time <= $tmax, $testName . ' - fetch() - lock time'); + } + $this->assertFalse($tpl->cached->handler->hasLock($this->smarty, $tpl->cached, $testName . ' - lock not removed')); + } + + public function data(){ + return array( + /* + * lock time + * locking_timeout 0 = no cache_locking + * compile_id + * cache_id + * isCached() expected result (null = no isCached test) + * min elapsed time + * max elapsed time + * force compile + * force cache + * source update + * test nr + * result compile nr + * result render nr + * text + */ + array(0, 0, null, null, false, 0, 0, false, false, false, 1, 1, 1, 'locking off - create cache'), + array(0, 0, 1, null, false, 0, 0, false, false, false, 2, 2, 2, 'locking off - create cache compile_id'), + array(0, 0, null, 2, false, 0, 0, false, false, false, 3, 1, 3, 'locking off - create cache cache_id'), + array(0, 0, 3, 4, false, 0, 0, false, false, false, 4, 4, 4, 'locking off - create cache cache_id & compile_id'), + array(0, 0, null, null, null, 0, 0, false, false, false, 5, 1, 1, 'locking off - fetch'), + array(0, 0, 1, null, null, 0, 0, false, false, false, 6, 2, 2, 'locking off - fetch compile_id'), + array(0, 0, null, 2, null, 0, 0, false, false, false, 7, 1, 3, 'locking off - fetch cache_id'), + array(0, 0, 3, 4, null, 0, 0, false, false, false, 8, 4, 4, 'locking off - fetch cache_id & compile_id'), + array(0, 0, null, null, true,0, 0, false, false, false, 9, 1, 1, 'locking off - isCached & fetch'), + array(0, 0, 1, null, true, 0, 0, false, false, false, 10, 2, 2, 'locking off - isCached & fetch compile_id'), + array(0, 0, null, 2, true, 0, 0, false, false, false, 11, 1, 3, 'locking off - isCached & fetch cache_id'), + array(0, 0, 3, 4, true, 0, 0, false, false, false, 12, 4, 4, 'locking off - isCached & fetch cache_id & compile_id'), + array(0, 0, null, null, false, 0, 0, true, false, false, 13, 13, 13, 'locking off - force compile'), + array(0, 0, null, null, true, 0, 0, false, false, false, 14, 13, 13, 'locking off - after force compile'), + array(0, 0, null, null, false, 0, 0, false, true, false, 15, 13, 15, 'locking off - force cache'), + array(0, 0, null, null, true, 0, 0, false, false, false, 16, 13, 15, 'locking off - after force cache'), + array(0, 0, null, null, false, 0, 0, false, false, true, 17, 17, 17, 'locking off - new source'), + array(0, 0, null, null, true, 0, 0, false, false, false, 18, 17, 17, 'locking off - after new source'), + array(0, 5, null, null, null, 0, 1, false, false, false, 19, 17, 17, 'not locked - fetch'), + array(0, 5, null, null, true, 0, 1, false, false, false, 20, 17, 17, 'not locked - isCached & fetch'), + array(0, 5, null, null, false, 0, 1, false, false, true, 21, 21, 21, 'not locked - new source'), + array(0, 5, null, null, true, 0, 1, false, false, false, 22, 21, 21, 'not locked - after new source'), + array(4, 10, null, null, null, 2, 10, false, false, false, 23, 21, 21, 'locked - fetch'), + array(4, 10, null, null, true, 2, 10, false, false, false, 24, 21, 21, 'locked - isCached & fetch'), + array(4, 10, null, null, false, 2, 10, false, false, true, 25, 25, 25, 'locked - new source'), + array(4, 10, null, null, true, 2, 10, false, false, false, 26, 25, 25, 'locked - after new source'), + array(10, 4, null, null, null, 2, 10, false, false, false, 27, 25, 25, 'lock timeout - fetch'), + array(10, 4, null, null, true, 2, 10, false, false, false, 28, 25, 25, 'lock timeout - isCached & fetch'), + array(10, 4, null, null, false, 2, 10, false, false, true, 29, 29, 29, 'lock timeout - new source'), + array(10, 4, null, null, true, 2, 10, false, false, false, 30, 29, 29, 'lock timeout - after new source'), + array(4, 10, 5, null, false, 2, 10, false, false, false, 31, 31, 31, 'locked - new compiled'), + array(10, 4, 6, null, false, 2, 10, false, false, false, 32, 32, 32, 'lock timeout - new compiled'), + ); + } + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCachingDisabled1() + { + $this->smarty->assign('test', 50); + $tpl = $this->smarty->createTemplate('cacheresource.tpl', $this->smarty); + $this->assertFalse($tpl->isCached(), 'isCached() status'); + $this->assertEquals('cache resource test:50 compiled:50 rendered:50', $this->smarty->fetch($tpl), 'fetch()'); + } + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCachingDisabled2() + { + $this->smarty->assign('test', 51); + $tpl = $this->smarty->createTemplate('cacheresource.tpl', $this->smarty); + $this->assertFalse($tpl->isCached(), 'isCached() status'); + $this->assertEquals('cache resource test:51 compiled:50 rendered:51', $this->smarty->fetch($tpl), 'fetch()'); + } + + /** + * Test caching + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataDir + * + */ + public function testCachingTemplateDir($folder, $iscached, $merge, $result) + { + $this->smarty->setCaching(true); + if ($folder == 0) { + $this->smarty->setTemplateDir(array(dirname(__FILE__) . '/../_shared/templates', dirname(__FILE__) . '/../_shared/templates/a')); + } else { + $this->smarty->setTemplateDir(array(dirname(__FILE__) . '/../_shared/templates', dirname(__FILE__) . '/../_shared/templates/b')); + } + if ($merge) { + $this->smarty->setCompileId(1); + $this->smarty->setMergeCompiledIncludes(true); + } + $tpl = $this->smarty->createTemplate('templatedir.tpl', $this->smarty); + $this->assertEquals($iscached, $tpl->isCached()); + $this->assertContains($result, $tpl->fetch()); + } + + public function dataDir(){ + return array( + array(0,false,0, 'include a'), + array(0,true,0, 'include a'), + array(1,false,0, 'include b'), + array(1,true,0, 'include b'), + array(0,false,1, 'include a'), + array(0,true,1, 'include a'), + array(1,false,1, 'include b'), + array(1,true,1, 'include b'), + ); + } +} diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php new file mode 100644 index 00000000..a5dddb28 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php @@ -0,0 +1,38 @@ +lockTime) { + $this->lockTime--; + if (!$this->lockTime) { + $this->releaseLock($smarty, $cached); + } + } + return parent::hasLock($smarty, $cached); + } + + public function get(Smarty_Internal_Template $_template) + { + $this->contents = array(); + $this->timestamps = array(); + $t = $this->getContent($_template); + + return $t ? $t : null; + } + + public function __sleep() + { + return array(); + } + + public function __wakeup() + { + $this->__construct(); + } +} diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php new file mode 100644 index 00000000..369460b7 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php @@ -0,0 +1,18 @@ +lockTime) { + $this->lockTime--; + if (!$this->lockTime) { + $this->releaseLock($smarty, $cached); + } + } + return parent::hasLock($smarty, $cached); + } +} diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.memcachetest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.memcachetest.php new file mode 100644 index 00000000..8569ec8a --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.memcachetest.php @@ -0,0 +1,38 @@ +lockTime) { + $this->lockTime--; + if (!$this->lockTime) { + $this->releaseLock($smarty, $cached); + } + } + return parent::hasLock($smarty, $cached); + } + + public function get(Smarty_Internal_Template $_template) + { + $this->contents = array(); + $this->timestamps = array(); + $t = $this->getContent($_template); + + return $t ? $t : null; + } + + public function __sleep() + { + return array(); + } + + public function __wakeup() + { + $this->__construct(); + } +} diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.mysqltest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.mysqltest.php new file mode 100644 index 00000000..47c47e45 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.mysqltest.php @@ -0,0 +1,31 @@ +db = PHPUnit_Smarty::$pdo; + } catch (PDOException $e) { + throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); + } + $this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id'); + $this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id'); + $this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content) + VALUES (:id, :name, :cache_id, :compile_id, :content)'); + } + + public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached) + { + if ($this->lockTime) { + $this->lockTime--; + if (!$this->lockTime) { + $this->releaseLock($smarty, $cached); + } + } + return parent::hasLock($smarty, $cached); + } +} diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdo_gziptest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdo_gziptest.php new file mode 100644 index 00000000..e7dfa5f2 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdo_gziptest.php @@ -0,0 +1,19 @@ +lockTime) { + $this->lockTime--; + if (!$this->lockTime) { + $this->releaseLock($smarty, $cached); + } + } + return parent::hasLock($smarty, $cached); + } +} diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdotest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdotest.php new file mode 100644 index 00000000..4d695983 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdotest.php @@ -0,0 +1,20 @@ +lockTime) { + $this->lockTime--; + if (!$this->lockTime) { + $this->releaseLock($smarty, $cached); + } + } + return parent::hasLock($smarty, $cached); + } +} diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php new file mode 100644 index 00000000..d5676d61 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php @@ -0,0 +1,22 @@ +exists) { + if (isset(CacheResourceTestCommon::$touchResource[$source->filepath])) { + $source->timestamp = CacheResourceTestCommon::$touchResource[$source->filepath]; + } + } + } + +} + diff --git a/tests/UnitTests/CacheResourceTests/_shared/templates/a/include.tpl b/tests/UnitTests/CacheResourceTests/_shared/templates/a/include.tpl new file mode 100644 index 00000000..9f7fedbf --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/templates/a/include.tpl @@ -0,0 +1 @@ +include a diff --git a/tests/UnitTests/CacheResourceTests/_shared/templates/b/include.tpl b/tests/UnitTests/CacheResourceTests/_shared/templates/b/include.tpl new file mode 100644 index 00000000..a7766351 --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/templates/b/include.tpl @@ -0,0 +1 @@ +include b diff --git a/tests/UnitTests/CacheResourceTests/_shared/templates/cacheresource.tpl b/tests/UnitTests/CacheResourceTests/_shared/templates/cacheresource.tpl new file mode 100644 index 00000000..5340ec3f --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/templates/cacheresource.tpl @@ -0,0 +1 @@ +cache resource test:{$test nocache} compiled:# rendered:{$test} \ No newline at end of file diff --git a/tests/UnitTests/CacheResourceTests/_shared/templates/helloworld.tpl b/tests/UnitTests/CacheResourceTests/_shared/templates/helloworld.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/templates/helloworld.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/CacheResourceTests/_shared/templates/helloworld2.tpl b/tests/UnitTests/CacheResourceTests/_shared/templates/helloworld2.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/templates/helloworld2.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/CacheResourceTests/_shared/templates/templatedir.tpl b/tests/UnitTests/CacheResourceTests/_shared/templates/templatedir.tpl new file mode 100644 index 00000000..adb7ed8f --- /dev/null +++ b/tests/UnitTests/CacheResourceTests/_shared/templates/templatedir.tpl @@ -0,0 +1 @@ +{include 'include.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php b/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php new file mode 100644 index 00000000..d83197c0 --- /dev/null +++ b/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php @@ -0,0 +1,71 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test compiler plugin tag in template file + */ + public function testCompilerPluginFunction() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'compilerplugin', 'mycompilerplugin'); + $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')); + } +} + +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 diff --git a/tests/UnitTests/Compiler/CompilerPlugin/cache/.gitignore b/tests/UnitTests/Compiler/CompilerPlugin/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/Compiler/CompilerPlugin/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/Compiler/CompilerPlugin/templates/compilerplugintest.tpl b/tests/UnitTests/Compiler/CompilerPlugin/templates/compilerplugintest.tpl new file mode 100644 index 00000000..b608d569 --- /dev/null +++ b/tests/UnitTests/Compiler/CompilerPlugin/templates/compilerplugintest.tpl @@ -0,0 +1 @@ +{compilerplugin} \ No newline at end of file diff --git a/tests/UnitTests/Compiler/CompilerPlugin/templates_c/.gitignore b/tests/UnitTests/Compiler/CompilerPlugin/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/Compiler/CompilerPlugin/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/Compiler/Delimiter/AutoLiteralTest.php b/tests/UnitTests/Compiler/Delimiter/AutoLiteralTest.php new file mode 100644 index 00000000..32dde734 --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/AutoLiteralTest.php @@ -0,0 +1,90 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../__shared/PHPunitplugins/"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test '{ ' delimiter + */ + public function testSetAutoliteral() + { + $this->smarty->setAutoLiteral(true); + $this->smarty->assign('i','foo'); + $this->assertEquals('{ $i}foo', $this->smarty->fetch('autoliteral.tpl')); + } + + public function testSetAutoliteral2() + { + $this->smarty->setAutoLiteral(false); + $this->smarty->setCompileId(1); + $this->smarty->assign('i','bar'); + $this->assertEquals('barbar', $this->smarty->fetch('autoliteral.tpl')); + } + /** + * test '{ ' delimiter in double quotes auto_literal true + * @runInSeparateProcess + * + */ + public function testSetAutoliteralDoublequote() + { + $this->smarty->setAutoLiteral(true); + $this->assertEquals(' output: double { counter} 1 quote', $this->smarty->fetch('autoliteraldoublequote.tpl')); + } + /** + * test '{ ' delimiter in double quotes auto_literal false + * @runInSeparateProcess + * + */ + public function testSetAutoliteralDoublequote2() + { + $this->smarty->setAutoLiteral(false); + $this->smarty->setCompileId(1); + $this->assertEquals(' output: double 1 2 quote', $this->smarty->fetch('autoliteraldoublequote.tpl')); + } + + /** + * test '{{ ' delimiter in double quotes auto_literal true + * @runInSeparateProcess + * + */ + public function testSetAutoliteralDoublequote3() + { + $this->smarty->setAutoLiteral(true); + $this->assertEquals(' output: double {{ counter} {{ counter}} quote', $this->smarty->fetch('autoliteraldoublequote2.tpl')); + } + + public function testSetAutoliteralBlock() + { + $this->smarty->setAutoLiteral(true); + $this->assertEquals('{ dummyblock}foo{ /dummyblock}', $this->smarty->fetch('autoliteralblock.tpl')); + } + public function testSetAutoliteralBlock1() + { + $this->smarty->setAutoLiteral(false); + $this->smarty->setCompileId(1); + $this->assertEquals('foo', $this->smarty->fetch('autoliteralblock.tpl')); + } + +} diff --git a/tests/UnitTests/Compiler/Delimiter/DelimiterTest.php b/tests/UnitTests/Compiler/Delimiter/DelimiterTest.php new file mode 100644 index 00000000..11e333ef --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/DelimiterTest.php @@ -0,0 +1,102 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test <{ }> delimiter + */ + public function testDelimiter1() + { + $this->smarty->left_delimiter = '<{'; + $this->smarty->right_delimiter = '}>'; + $tpl = $this->smarty->createTemplate('eval:start <{* comment *}>hello <{if true}><{"world"}><{/if}> end'); + $this->assertEquals("start hello world end", $this->smarty->fetch($tpl)); + } + /** + * test <{ }> delimiter + */ + public function testDelimiter10() + { + $this->smarty->left_delimiter = '<'; + $this->smarty->right_delimiter = '>'; + $tpl = $this->smarty->createTemplate('eval:start <* comment *>hello <"world"> end'); + $this->assertEquals("start hello world end", $this->smarty->fetch($tpl)); + } + + /** + * test <-{ }-> delimiter + */ + public function testDelimiter2() + { + $this->smarty->left_delimiter = '<-{'; + $this->smarty->right_delimiter = '}->'; + $tpl = $this->smarty->createTemplate('eval:<-<-{* comment *}-><-{if true}-><-{"hello world"}-><-{/if}->->'); + $this->assertEquals("<-hello world->", $this->smarty->fetch($tpl)); + } + + /** + * test <--{ }--> delimiter + */ + public function testDelimiter3() + { + $this->smarty->left_delimiter = '<--{'; + $this->smarty->right_delimiter = '}-->'; + $tpl = $this->smarty->createTemplate('eval:<--{* comment *}--><--{if true}--><--{"hello world"}--><--{/if}-->'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + /** + * test {{ }} delimiter + */ + public function testDelimiter4() + { + $this->smarty->left_delimiter = '{{'; + $this->smarty->right_delimiter = '}}'; + $tpl = $this->smarty->createTemplate('eval:{{* comment *}}{{if true}}{{"hello world"}}{{/if}}'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + /** + * test {= =} delimiter for conficts with option flags + */ + public function testDelimiter5() + { + $this->smarty->left_delimiter = '{='; + $this->smarty->right_delimiter = '=}'; + $tpl = $this->smarty->createTemplate('eval:{=assign var=foo value="hello world" nocache=}{=$foo=}'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + /** + * test {= =} delimiter for conficts with option flags + */ + public function testDelimiterIssue450() + { + $this->smarty->left_delimiter = '{^'; + $this->smarty->right_delimiter = '^}'; + $tpl = $this->smarty->createTemplate('eval:{^assign var=foo value="hello world" nocache^}{^$foo^}'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/Compiler/Delimiter/UserLiteralTest.php b/tests/UnitTests/Compiler/Delimiter/UserLiteralTest.php new file mode 100644 index 00000000..49f8d79c --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/UserLiteralTest.php @@ -0,0 +1,72 @@ +markTestSkipped('user literal support'); + } else { + $this->setUpSmarty(dirname(__FILE__)); + } + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testUserLiteral() + { + $this->smarty->setAutoLiteral(true); + $this->assertEquals('{{ 1 }}', $this->smarty->fetch('userliteral.tpl')); + } + public function testUserLiteral1() + { + $this->smarty->setAutoLiteral(false); + $this->smarty->setCompileId(1); + $this->assertEquals('1', $this->smarty->fetch('userliteral.tpl')); + } + public function testUserLiteral2() + { + $this->smarty->setAutoLiteral(false); + $this->smarty->setLiterals(array('{{','}}')); + $this->assertEquals('{{1}}', $this->smarty->fetch('userliteral1.tpl')); + } + public function testUserLiteral3() + { + $this->smarty->setAutoLiteral(false); + $this->smarty->setLeftDelimiter('<-'); + $this->smarty->setRightDelimiter('->'); + $this->smarty->setLiterals(array('<--','-->')); + $this->assertEquals('1 <--1-->', $this->smarty->fetch('userliteral2.tpl')); + } + public function testUserLiteral4() + { + $this->smarty->setAutoLiteral(true); + $this->smarty->setLeftDelimiter('<-'); + $this->smarty->setRightDelimiter('->'); + $this->smarty->setCompileId(1); + $this->smarty->setLiterals(array('<--','-->')); + $this->assertEquals('<- 1 -> <--1-->', $this->smarty->fetch('userliteral2.tpl')); + } + public function testUserLiteral5() + { + $this->smarty->setAutoLiteral(true); + $this->smarty->setLiterals(array('{%')); + $this->assertEquals(' output: double {%counter} quote', $this->smarty->fetch('userliteraldoublequote.tpl')); + } +} diff --git a/tests/UnitTests/Compiler/Delimiter/cache/.gitignore b/tests/UnitTests/Compiler/Delimiter/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/Compiler/Delimiter/templates/autoliteral.tpl b/tests/UnitTests/Compiler/Delimiter/templates/autoliteral.tpl new file mode 100644 index 00000000..9f580a8c --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/templates/autoliteral.tpl @@ -0,0 +1 @@ +{ $i}{$i} \ No newline at end of file diff --git a/tests/UnitTests/Compiler/Delimiter/templates/autoliteralblock.tpl b/tests/UnitTests/Compiler/Delimiter/templates/autoliteralblock.tpl new file mode 100644 index 00000000..3e661c92 --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/templates/autoliteralblock.tpl @@ -0,0 +1 @@ +{ dummyblock}foo{ /dummyblock} \ No newline at end of file diff --git a/tests/UnitTests/Compiler/Delimiter/templates/autoliteraldoublequote.tpl b/tests/UnitTests/Compiler/Delimiter/templates/autoliteraldoublequote.tpl new file mode 100644 index 00000000..23913dd3 --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/templates/autoliteraldoublequote.tpl @@ -0,0 +1 @@ +{$foo="double { counter} {counter} quote"} output: {$foo} \ No newline at end of file diff --git a/tests/UnitTests/Compiler/Delimiter/templates/autoliteraldoublequote2.tpl b/tests/UnitTests/Compiler/Delimiter/templates/autoliteraldoublequote2.tpl new file mode 100644 index 00000000..d9dab090 --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/templates/autoliteraldoublequote2.tpl @@ -0,0 +1 @@ +{$foo="double {{ counter} {{ counter}} quote"} output: {$foo} \ No newline at end of file diff --git a/tests/UnitTests/Compiler/Delimiter/templates/userliteral.tpl b/tests/UnitTests/Compiler/Delimiter/templates/userliteral.tpl new file mode 100644 index 00000000..e7dbc1b7 --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/templates/userliteral.tpl @@ -0,0 +1 @@ +{{ 1 }} \ No newline at end of file diff --git a/tests/UnitTests/Compiler/Delimiter/templates/userliteral1.tpl b/tests/UnitTests/Compiler/Delimiter/templates/userliteral1.tpl new file mode 100644 index 00000000..5972cc7b --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/templates/userliteral1.tpl @@ -0,0 +1 @@ +{{1}} \ No newline at end of file diff --git a/tests/UnitTests/Compiler/Delimiter/templates/userliteral2.tpl b/tests/UnitTests/Compiler/Delimiter/templates/userliteral2.tpl new file mode 100644 index 00000000..826660d0 --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/templates/userliteral2.tpl @@ -0,0 +1 @@ +<- 1 -> <--1--> \ No newline at end of file diff --git a/tests/UnitTests/Compiler/Delimiter/templates/userliteraldoublequote.tpl b/tests/UnitTests/Compiler/Delimiter/templates/userliteraldoublequote.tpl new file mode 100644 index 00000000..5e654c06 --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/templates/userliteraldoublequote.tpl @@ -0,0 +1 @@ +{$foo="double {%counter} quote"} output: {$foo} \ No newline at end of file diff --git a/tests/UnitTests/Compiler/Delimiter/templates_c/.gitignore b/tests/UnitTests/Compiler/Delimiter/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/Compiler/Delimiter/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php b/tests/UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php new file mode 100644 index 00000000..458c4d9e --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php @@ -0,0 +1,179 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->setForceCompile(true); + } + + /** + * @expectedException SmartyException + * @expectedExceptionMessage Unable to load config 'file:foo.conf' + * + * test unknown config file + */ + public function testUnknownConfigFile() + { + $this->smarty->configLoad('foo.conf'); + } + + /** + * @expectedException SmartyException + * @expectedExceptionMessage Default config handler + * @expectedExceptionMessage not callable + * + * test register unknown default config handler + * + */ + public function testRegisterUnknownDefaultConfigHandler() + { + $this->smarty->registerDefaultConfigHandler('foo'); + } + + /** + * test default config handler replacement (config data) + * + * @throws \Exception + * @throws \SmartyException + */ + public function testDefaultConfigHandlerReplacement() + { + $this->smarty->registerDefaultConfigHandler('configHandlerData'); + $this->smarty->configLoad('foo.conf'); + $this->assertEquals("bar", $this->smarty->fetch('foo.tpl')); + } + + /** + * test default config handler replacement (other config file) + * + * @throws \Exception + * @throws \SmartyException + */ + public function testDefaultConfigHandlerReplacementByConfigFile() + { + $this->smarty->registerDefaultConfigHandler('configHandlerFile'); + $this->smarty->configLoad('foo.conf'); + $this->assertEquals("123.4", $this->smarty->fetch('number.tpl')); + } + + /** + * @expectedException SmartyException + * @expectedExceptionMessage Unable to load config default file 'no.conf' for 'file:fo.conf' + * + * + */ + public function testDefaultConfigHandlerReplacementByConfigFileFail() + { + $this->smarty->registerDefaultConfigHandler('configHandlerFile'); + $this->smarty->configLoad('fo.conf'); + $this->assertEquals("123.4", $this->smarty->fetch('number.tpl')); + } + + /** + * @expectedException SmartyException + * @expectedExceptionMessage Unable to load config 'file:foo.conf' + * + * + * test default config handler replacement (return false) + * + */ + public function testDefaultConfigHandlerReplacementReturningFalse() + { + $this->smarty->configLoad('foo.conf'); + } + + /** + * @expectedException SmartyException + * @expectedExceptionMessage No config default content for 'file:bla.conf' + * + * + * test default config handler replacement (return false) + * + */ + public function testDefaultConfigHandlerReplacementReturningFalse1() + { + $this->smarty->registerDefaultConfigHandler('configHandlerData'); + $this->smarty->configLoad('bla.conf'); + } + +} + +/** + * config handler returning config data + * + * @param $resource_type + * @param $resource_name + * @param $config_source + * @param $config_timestamp + * @param \Smarty $smarty + * + * @return bool + */ +function configHandlerData($resource_type, $resource_name, &$config_source, &$config_timestamp, Smarty $smarty) +{ + if ($resource_name !== 'foo.conf') { + return false; + } + $output = "foo = 'bar'\n"; + $config_source = $output; + $config_timestamp = time(); + + return true; +} + +/** + * config handler returning config file + * + * @param $resource_type + * @param $resource_name + * @param $config_source + * @param $config_timestamp + * @param \Smarty $smarty + * + * @return string + */ +function configHandlerFile($resource_type, $resource_name, &$config_source, &$config_timestamp, Smarty $smarty) +{ + if ($resource_name !== 'foo.conf') { + return 'no.conf'; + } + + return $smarty->getConfigDir(0) . 'test.conf'; +} + +/** + * config handler returning false + * + * @param $resource_type + * @param $resource_name + * @param $config_source + * @param $config_timestamp + * @param \Smarty $smarty + * + * @return bool + */ +function configHandlerFalse($resource_type, $resource_name, &$config_source, &$config_timestamp, Smarty $smarty) +{ + return false; +} diff --git a/tests/UnitTests/ConfigFileTests/defaultHandler/configs/test.conf b/tests/UnitTests/ConfigFileTests/defaultHandler/configs/test.conf new file mode 100644 index 00000000..9bd1731c --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/defaultHandler/configs/test.conf @@ -0,0 +1,49 @@ +title = Welcome to Smarty! + +overwrite = Overwrite1 +overwrite = Overwrite2 + +booleanon = on + +Intro = """This is a value that spans more + than one line. you must enclose + it in triple quotes.""" + +Number = 123.4 + +text = 123bvc + +line = 123 This is a line + +sec1 = Global Section1 + +sec2 = Global Section2 + +sec = Global char +[/] +sec = special char + +[foo/bar] +sec = section foo/bar + +[section1] +sec1 = Hello Section1 + +[section2] +sec2 = 'Hello Section2' + +[.hidden] +hiddentext = Hidden Section + +#Comment +# Comment with a space first line first + #Comment line starting with space + # Space before and after # +#The line below only contains a # +# +# +# title = This is not the correct title + +#[section1] +#sec1 = Wrong text + diff --git a/tests/UnitTests/ConfigFileTests/defaultHandler/templates/foo.tpl b/tests/UnitTests/ConfigFileTests/defaultHandler/templates/foo.tpl new file mode 100644 index 00000000..bf8cc975 --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/defaultHandler/templates/foo.tpl @@ -0,0 +1 @@ +{#foo#} \ No newline at end of file diff --git a/tests/UnitTests/ConfigFileTests/defaultHandler/templates/number.tpl b/tests/UnitTests/ConfigFileTests/defaultHandler/templates/number.tpl new file mode 100644 index 00000000..966a9f73 --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/defaultHandler/templates/number.tpl @@ -0,0 +1 @@ +{#Number#} \ No newline at end of file diff --git a/tests/UnitTests/ConfigFileTests/defaultHandler/templates_c/.gitignore b/tests/UnitTests/ConfigFileTests/defaultHandler/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/defaultHandler/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php b/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php new file mode 100644 index 00000000..8a23ba3d --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php @@ -0,0 +1,409 @@ +setUpSmarty(dirname(__FILE__)); + } + + /** + * empty templat_c and cache folders + */ + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test number config variable + */ + public function testConfigNumber() + { + $this->smarty->configLoad('test.conf'); + $this->assertEquals("123.4", $this->smarty->fetch('number.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test string config variable + */ + public function testConfigText() + { + $this->smarty->configLoad('test.conf'); + $this->assertEquals("123bvc", $this->smarty->fetch('text.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test line string config variable + */ + public function testConfigLine() + { + $this->smarty->configLoad('test.conf'); + $this->assertEquals("123 This is a line", $this->smarty->fetch('eval:{#line#}')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test config variables in global sections + */ + public function testConfigVariableGlobalSections() + { + $this->smarty->configLoad('test.conf'); + $this->assertEquals("Welcome to Smarty! Global Section1 Global Section2", $this->smarty->fetch('sec1sec2.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test config variables loading section2 + */ + public function testConfigVariableSection2() + { + $this->smarty->configLoad('test.conf', 'section2'); + $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('sec1sec2.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test config variables loading section special char + */ + public function testConfigVariableSectionSpecialChar() + { + $this->smarty->configLoad('test.conf', '/'); + $this->assertEquals("Welcome to Smarty! special char", $this->smarty->fetch('sec.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test config variables loading section foo/bar + */ + public function testConfigVariableSectionFooBar() + { + $this->smarty->configLoad('test.conf', 'foo/bar'); + $this->assertEquals("Welcome to Smarty! section foo/bar", $this->smarty->fetch('sec.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test config variables loaded in different scopes from different sections (Smarty and template) + */ + public function testConfigDifferentScope() + { + $this->smarty->configLoad('test.conf', 'section2'); + $tpl = $this->smarty->createTemplate('sec1sec2.tpl'); + $tpl->configLoad('test.conf', 'section1'); + $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('sec1sec2.tpl')); + $this->assertEquals("Welcome to Smarty! Hello Section1 Global Section2", $this->smarty->fetch($tpl)); + } + + /** + * test config variables of hidden sections + * shall display variables from hidden section + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableHidden() + { + $this->smarty->config_read_hidden = true; + $this->smarty->configLoad('test.conf', 'hidden'); + $this->assertEquals("Welcome to Smarty!Hidden Section", $this->smarty->fetch('hidden.tpl')); + } + + /** + * test config variables of disabled hidden sections + * shall display not variables from hidden section + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableHiddenDisable() + { + $this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + $this->smarty->config_read_hidden = false; + $this->smarty->configLoad('test.conf', 'hidden'); + $this->assertEquals("Welcome to Smarty!", $this->smarty->fetch('hidden.tpl')); + } + + /** + * test getConfigVars + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigGetSingleConfigVar() + { + $this->smarty->configLoad('test.conf'); + $this->assertEquals("Welcome to Smarty!", $this->smarty->getConfigVars('title')); + } + + /** + * test getConfigVars return all variables + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigGetAllConfigVars() + { + $this->smarty->configLoad('test.conf'); + $vars = $this->smarty->getConfigVars(); + $this->assertTrue(is_array($vars)); + $this->assertEquals("Welcome to Smarty!", $vars['title']); + $this->assertEquals("Global Section1", $vars['sec1']); + } + + /** + * test clearConfig for single variable + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigClearSingleConfigVar() + { + $this->smarty->configLoad('test.conf'); + $this->smarty->clearConfig('title'); + $this->assertEquals("", $this->smarty->getConfigVars('title')); + } + + /** + * test clearConfig for all variables + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigClearConfigAll() + { + $this->smarty->configLoad('test.conf'); + $this->smarty->clearConfig(); + $vars = $this->smarty->getConfigVars(); + $this->assertTrue(is_array($vars)); + $this->assertTrue(empty($vars)); + } + + /** + * test config vars on data object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigTextData() + { + $data = $this->smarty->createData(); + $data->configLoad('test.conf'); + $this->assertEquals("123bvc", $this->smarty->fetch('text.tpl', $data)); + } + + /** + * test getConfigVars on data object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigGetSingleConfigVarData() + { + $data = $this->smarty->createData(); + $data->configLoad('test.conf'); + $this->assertEquals("Welcome to Smarty!", $data->getConfigVars('title')); + } + + /** + * test getConfigVars return all variables on data object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigGetAllConfigVarsData() + { + $data = $this->smarty->createData(); + $data->configLoad('test.conf'); + $vars = $data->getConfigVars(); + $this->assertTrue(is_array($vars)); + $this->assertEquals("Welcome to Smarty!", $vars['title']); + $this->assertEquals("Global Section1", $vars['sec1']); + } + + /** + * test clearConfig for single variable on data object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigClearSingleConfigVarData() + { + $data = $this->smarty->createData(); + $data->configLoad('test.conf'); + $data->clearConfig('title'); + $this->assertEquals("", $data->getConfigVars('title')); + $this->assertEquals("Global Section1", $data->getConfigVars('sec1')); + } + + /** + * test clearConfig for all variables on data object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigClearConfigAllData() + { + $data = $this->smarty->createData(); + $data->configLoad('test.conf'); + $data->clearConfig(); + $vars = $data->getConfigVars(); + $this->assertTrue(is_array($vars)); + $this->assertTrue(empty($vars)); + } + + /** + * test config vars on template object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigTextTemplate() + { + $tpl = $this->smarty->createTemplate('text.tpl'); + $tpl->configLoad('test.conf'); + $this->assertEquals("123bvc", $this->smarty->fetch($tpl)); + } + + /** + * test getConfigVars on template object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigGetSingleConfigVarTemplate() + { + $tpl = $this->smarty->createTemplate('text.tpl'); + $tpl->configLoad('test.conf'); + $this->assertEquals("Welcome to Smarty!", $tpl->getConfigVars('title')); + } + + /** + * test getConfigVariable on template object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigGetSingleConfigVarTemplate2() + { + $tpl = $this->smarty->createTemplate('text.tpl'); + $tpl->configLoad('test.conf'); + $this->assertEquals("Welcome to Smarty!", $tpl->getConfigVariable('title')); + } + + /** + * test getConfigVars return all variables on template object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigGetAllConfigVarsTemplate() + { + $tpl = $this->smarty->createTemplate('text.tpl'); + $tpl->configLoad('test.conf'); + $vars = $tpl->getConfigVars(); + $this->assertTrue(is_array($vars)); + $this->assertEquals("Welcome to Smarty!", $vars['title']); + $this->assertEquals("Global Section1", $vars['sec1']); + } + + /** + * test clearConfig for single variable on template object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigClearSingleConfigVarTemplate() + { + $tpl = $this->smarty->createTemplate('text.tpl'); + $tpl->configLoad('test.conf'); + $tpl->clearConfig('title'); + $this->assertEquals("", $tpl->getConfigVars('title')); + $this->assertEquals("Global Section1", $tpl->getConfigVars('sec1')); + } + + /** + * test clearConfig for all variables on template object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigClearConfigAllTemplate() + { + $tpl = $this->smarty->createTemplate('text.tpl'); + $tpl->configLoad('test.conf'); + $tpl->clearConfig(); + $vars = $tpl->getConfigVars(); + $this->assertTrue(is_array($vars)); + $this->assertTrue(empty($vars)); + } + + /** + * test config variables loading from absolute file path + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigAbsolutePath() + { + $file = realpath($this->smarty->getConfigDir(0) . 'test.conf'); + $this->smarty->configLoad($file); + $this->assertEquals("123.4", $this->smarty->fetch('number.tpl')); + } + + public function testConfigResourceDb4() + { + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->smarty->configLoad('db4:foo.conf'); + $this->assertEquals("bar", $this->smarty->fetch('foo.tpl')); + } + public function testConfigUndefinedSilent() + { + $this->assertEquals("", $this->smarty->fetch('foo.tpl')); + } + + public function testConfigUndefinedNotice() + { + $this->smarty->error_unassigned = true; + try { + $this->assertEquals("", $this->smarty->fetch('foo.tpl')); + } + catch (Exception $e) { + $this->assertEquals('Undefined variable: foo', $e->getMessage()); + } + } +} diff --git a/tests/UnitTests/ConfigFileTests/file/PHPunitplugins/resource.db4.php b/tests/UnitTests/ConfigFileTests/file/PHPunitplugins/resource.db4.php new file mode 100644 index 00000000..920c349a --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/file/PHPunitplugins/resource.db4.php @@ -0,0 +1,27 @@ +filepath = 'db4:'; + $source->uid = sha1($source->resource); + $source->timestamp = 0; + $source->exists = true; + } + + public function getContent(Smarty_Template_Source $source) + { + return "foo = 'bar'\n"; + } +} diff --git a/tests/UnitTests/ConfigFileTests/file/configs/test.conf b/tests/UnitTests/ConfigFileTests/file/configs/test.conf new file mode 100644 index 00000000..9bd1731c --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/file/configs/test.conf @@ -0,0 +1,49 @@ +title = Welcome to Smarty! + +overwrite = Overwrite1 +overwrite = Overwrite2 + +booleanon = on + +Intro = """This is a value that spans more + than one line. you must enclose + it in triple quotes.""" + +Number = 123.4 + +text = 123bvc + +line = 123 This is a line + +sec1 = Global Section1 + +sec2 = Global Section2 + +sec = Global char +[/] +sec = special char + +[foo/bar] +sec = section foo/bar + +[section1] +sec1 = Hello Section1 + +[section2] +sec2 = 'Hello Section2' + +[.hidden] +hiddentext = Hidden Section + +#Comment +# Comment with a space first line first + #Comment line starting with space + # Space before and after # +#The line below only contains a # +# +# +# title = This is not the correct title + +#[section1] +#sec1 = Wrong text + diff --git a/tests/UnitTests/ConfigFileTests/file/templates/foo.tpl b/tests/UnitTests/ConfigFileTests/file/templates/foo.tpl new file mode 100644 index 00000000..bf8cc975 --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/file/templates/foo.tpl @@ -0,0 +1 @@ +{#foo#} \ No newline at end of file diff --git a/tests/UnitTests/ConfigFileTests/file/templates/hidden.tpl b/tests/UnitTests/ConfigFileTests/file/templates/hidden.tpl new file mode 100644 index 00000000..0395fcc4 --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/file/templates/hidden.tpl @@ -0,0 +1 @@ +{#title#}{#hiddentext#} \ No newline at end of file diff --git a/tests/UnitTests/ConfigFileTests/file/templates/number.tpl b/tests/UnitTests/ConfigFileTests/file/templates/number.tpl new file mode 100644 index 00000000..966a9f73 --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/file/templates/number.tpl @@ -0,0 +1 @@ +{#Number#} \ No newline at end of file diff --git a/tests/UnitTests/ConfigFileTests/file/templates/sec.tpl b/tests/UnitTests/ConfigFileTests/file/templates/sec.tpl new file mode 100644 index 00000000..62c459cd --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/file/templates/sec.tpl @@ -0,0 +1 @@ +{#title#} {#sec#} \ No newline at end of file diff --git a/tests/UnitTests/ConfigFileTests/file/templates/sec1sec2.tpl b/tests/UnitTests/ConfigFileTests/file/templates/sec1sec2.tpl new file mode 100644 index 00000000..2a6846c0 --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/file/templates/sec1sec2.tpl @@ -0,0 +1 @@ +{#title#} {#sec1#} {#sec2#} \ No newline at end of file diff --git a/tests/UnitTests/ConfigFileTests/file/templates/text.tpl b/tests/UnitTests/ConfigFileTests/file/templates/text.tpl new file mode 100644 index 00000000..2257209c --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/file/templates/text.tpl @@ -0,0 +1 @@ +{#text#} \ No newline at end of file diff --git a/tests/UnitTests/ConfigFileTests/file/templates_c/.gitignore b/tests/UnitTests/ConfigFileTests/file/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ConfigFileTests/file/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php b/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php new file mode 100644 index 00000000..b16af7dc --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php @@ -0,0 +1,121 @@ +setUpSmarty(dirname(__FILE__)); + require_once dirname(__FILE__) . '/PHPunitplugins/resource.ambiguous.php'; + + // empty the template dir + $this->smarty->setTemplateDir(array()); + + // kill cache for unit test + // Smarty::$_resource_cache = array(); + } + + public function testInit() + { + $this->cleanDirs(); + } + + protected function relative($path) + { + $path = str_replace(dirname(__FILE__), '.', $path); + if (DIRECTORY_SEPARATOR == "\\") { + $path = str_replace("\\", "/", $path); + } + + return $path; + } + + public function testNone() + { + $resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/'); + $this->smarty->registerResource('ambiguous', $resource_handler); + $this->smarty->setDefaultResourceType('ambiguous'); + $this->smarty->setAllowAmbiguousResources(true); + + $tpl = $this->smarty->createTemplate('foobar.tpl'); + $this->assertFalse($tpl->source->exists); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCase1() + { + $resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/'); + $this->smarty->registerResource('ambiguous', $resource_handler); + $this->smarty->setDefaultResourceType('ambiguous'); + $this->smarty->setAllowAmbiguousResources(true); + + $resource_handler->setSegment('case1'); + + $tpl = $this->smarty->createTemplate('foobar.tpl'); + $this->assertTrue($tpl->source->exists); + $this->assertEquals('case1', $tpl->source->getContent()); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCase2() + { + $resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/'); + $this->smarty->registerResource('ambiguous', $resource_handler); + $this->smarty->setDefaultResourceType('ambiguous'); + $this->smarty->setAllowAmbiguousResources(true); + + $resource_handler->setSegment('case2'); + + $tpl = $this->smarty->createTemplate('foobar.tpl'); + $this->assertTrue($tpl->source->exists); + $this->assertEquals('case2', $tpl->source->getContent()); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCaseSwitching() + { + $resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/'); + $this->smarty->registerResource('ambiguous', $resource_handler); + $this->smarty->setDefaultResourceType('ambiguous'); + $this->smarty->setAllowAmbiguousResources(true); + + $resource_handler->setSegment('case1'); + $tpl = $this->smarty->createTemplate('foobar.tpl'); + $this->assertTrue($tpl->source->exists); + $this->assertEquals('case1', $tpl->source->getContent()); + + $resource_handler->setSegment('case2'); + $tpl = $this->smarty->createTemplate('foobar.tpl'); + $this->assertTrue($tpl->source->exists); + $this->assertEquals('case2', $tpl->source->getContent()); + } +} diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php b/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php new file mode 100644 index 00000000..f161844a --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php @@ -0,0 +1,58 @@ +directory = rtrim($directory, "/\\") . DIRECTORY_SEPARATOR; + // parent::__construct(); + } + + public function setSegment($segment) + { + $this->segment = $segment; + } + + /** + * modify resource_name according to resource handlers specifications + * + * @param Smarty $smarty Smarty instance + * @param string $resource_name resource_name to make unique + * + * @return string unique resource name + */ + public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) + { + return get_class($this) . '#' . $this->segment . '#' . $resource_name; + } + + /** + * populate Source Object with meta data from Resource + * + * @param Smarty_Template_Source $source source object + * @param Smarty_Internal_Template $_template template object + */ + public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) + { + $segment = ''; + if ($this->segment) { + $segment = rtrim($this->segment, "/\\") . DIRECTORY_SEPARATOR; + } + + $source->filepath = $this->directory . $segment . $source->name; + $source->uid = sha1($source->filepath); + if ($_template->smarty->getCompileCheck() && !isset($source->timestamp)) { + $source->timestamp = @filemtime($source->filepath); + $source->exists = !!$source->timestamp; + } + } +} diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/cache/.gitignore b/tests/UnitTests/ResourceTests/Custom/Ambiguous/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/resource.tpl b/tests/UnitTests/ResourceTests/Custom/Ambiguous/resource.tpl new file mode 100644 index 00000000..e69de29b diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates/ambiguous/case1/foobar.tpl b/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates/ambiguous/case1/foobar.tpl new file mode 100644 index 00000000..a5b129ba --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates/ambiguous/case1/foobar.tpl @@ -0,0 +1 @@ +case1 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates/ambiguous/case2/foobar.tpl b/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates/ambiguous/case2/foobar.tpl new file mode 100644 index 00000000..065ab5bc --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates/ambiguous/case2/foobar.tpl @@ -0,0 +1 @@ +case2 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates_c/.gitignore b/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php new file mode 100644 index 00000000..e89e11bc --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php @@ -0,0 +1,165 @@ +setUpSmarty(dirname(__FILE__)); + } + + 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',)); + + $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',)); + + $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 templates1

data1 from templates3

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 templates1

data1 from templates3

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 templates1

data1 from templates3

data1 from templates2

data2 from templates1

', + $this->smarty->fetch('template.tpl')); + } +} diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/cache/.gitignore b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall.tpl new file mode 100644 index 00000000..ab061b43 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall.tpl @@ -0,0 +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 new file mode 100644 index 00000000..ab061b43 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates/extendsall2.tpl @@ -0,0 +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_2/helloworld.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_2/helloworld.php new file mode 100644 index 00000000..77eb622a --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_2/helloworld.php @@ -0,0 +1 @@ +php hello world \ No newline at end of file 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 new file mode 100644 index 00000000..ee9e030a --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_3/extendsall.tpl @@ -0,0 +1,6 @@ +{strip} +{block name="alpha"}templates_3{/block} +{block name="bravo"} + {block name="bravo_1"}templates_3{/block} + {block name="bravo_2"}templates_3{/block} +{/block} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_4/extendsall.tpl b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_4/extendsall.tpl new file mode 100644 index 00000000..c2d7cade --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_4/extendsall.tpl @@ -0,0 +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 diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_c/.gitignore b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/PHPunitplugins/resource.mysqlstest.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/PHPunitplugins/resource.mysqlstest.php new file mode 100644 index 00000000..f64ab457 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/PHPunitplugins/resource.mysqlstest.php @@ -0,0 +1,18 @@ +db = PHPUnit_Smarty::$pdo; + } + catch + (PDOException $e) { + throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); + } + $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); + } +} + diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/PHPunitplugins/resource.mysqltest.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/PHPunitplugins/resource.mysqltest.php new file mode 100644 index 00000000..2b05da9d --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/PHPunitplugins/resource.mysqltest.php @@ -0,0 +1,19 @@ +db = PHPUnit_Smarty::$pdo; + } + catch + (PDOException $e) { + throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); + } + $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); + $this->mtime = $this->db->prepare('SELECT modified FROM templates WHERE name = :name'); + } +} + diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php new file mode 100644 index 00000000..23d0c0e1 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php @@ -0,0 +1,151 @@ +markTestSkipped('Msqlresource tests are disabled'); + } + if (self::$init) { + $this->getConnection(); + } + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("./PHPunitplugins/"); + } + + /** + * + */ + public function testInit() + { + $this->cleanDirs(); + $this->initMysqlResource(); + PHPUnit_Smarty::$pdo->exec("REPLACE INTO templates (name, source) VALUES ('test.tpl', '{\$x = \'hello world\'}{\$x}')"); + } + + /** + * test resource plugin rendering of a custom resource + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testResourcePluginMysql() + { + $this->assertEquals('hello world', $this->smarty->fetch('mysqltest:test.tpl')); + } + + /** + * test must compile + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testMustCompile() + { + $tpl = $this->smarty->createTemplate('mysqltest:test.tpl'); + $this->assertFalse($tpl->mustCompile()); + } + + /** + * test must compile + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testMustCompile2() + { + sleep(2); + PHPUnit_Smarty::$pdo->exec("REPLACE INTO templates (name, source) VALUES ('test.tpl', '{\$x = \'hello smarty\'}{\$x}' )"); + $tpl = $this->smarty->createTemplate('mysqltest:test.tpl'); + $this->assertTrue($tpl->mustCompile()); + } + + /** + * test resource plugin rendering of a custom resource + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testResourcePluginMysql2() + { + $this->assertEquals('hello smarty', $this->smarty->fetch('mysqltest:test.tpl')); + } + + /** + * test clear compiled + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testClearCompiled() + { + $this->assertEquals(1, $this->smarty->clearCompiledTemplate('mysqltest:test.tpl')); + } + + /** + * test must compile + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testMustCompile3() + { + $tpl = $this->smarty->createTemplate('mysqltest:test.tpl'); + $this->assertTrue($tpl->mustCompile()); + } + + /** + * test resource plugin compiledFilepath of a custom resource + */ + public function testResourcePluginMysqlCompiledFilepath() + { + //$this->smarty->addPluginsDir("./PHPunitplugins/"); + $tpl = $this->smarty->createTemplate('mysqltest:test.tpl'); + $this->assertEquals($this->buildCompiledPath($tpl, false, false, null, 'test.tpl', 'mysqltest', $this->smarty->getTemplateDir(0)), $tpl->compiled->filepath); + } + + public function testResourcePluginMysqlCompiledFilepathCache() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setForceCompile(true); + $this->smarty->fetch('mysqltest:test.tpl'); + $tpl = $this->smarty->createTemplate('mysqltest:test.tpl'); + $this->assertEquals($this->buildCompiledPath($tpl, false, true, null, 'test.tpl', 'mysqltest', $this->smarty->getTemplateDir(0)), $tpl->compiled->filepath); + $this->smarty->caching = false; + } + + /** + * test unknown template + * + * @expectedException SmartyException + * @expectedExceptionMessage Unable to load template 'mysqlstest:foo.tpl' + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testUnknownTemplate() { + $this->assertEquals('foo', $this->smarty->fetch('mysqlstest:foo.tpl')); + } + } +} diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/cache/.gitignore b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/templates_c/.gitignore b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/DefaultHandler/DefaultTemplateHandlerTest.php b/tests/UnitTests/ResourceTests/DefaultHandler/DefaultTemplateHandlerTest.php new file mode 100644 index 00000000..63dc3604 --- /dev/null +++ b/tests/UnitTests/ResourceTests/DefaultHandler/DefaultTemplateHandlerTest.php @@ -0,0 +1,113 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->setForceCompile(true); + $this->smarty->disableSecurity(); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test error on unknow template + */ + public function testUnknownTemplate() + { + try { + $this->smarty->fetch('foo.tpl'); + } + catch (Exception $e) { + $this->assertContains('Unable to load template', $e->getMessage()); + + return; + } + $this->fail('Exception for none existing template has not been raised.'); + } + + /** + * test error on registration on none existent handler function. + */ + public function testRegisterNoneExistentHandlerFunction() + { + try { + $this->smarty->registerDefaultTemplateHandler('foo'); + } + catch (Exception $e) { + $this->assertContains("Default template handler", $e->getMessage()); + $this->assertContains("not callable", $e->getMessage()); + + return; + } + $this->fail('Exception for none callable function has not been raised.'); + } + /** + * test replacement by default template handler + */ + /** + * public function testDefaultTemplateHandlerReplacement() + * { + * $this->smarty->register->defaultTemplateHandler('my_template_handler'); + * $this->assertEquals("Recsource foo.tpl of type file not found", $this->smarty->fetch('foo.tpl')); + * } + */ + public function testDefaultTemplateHandlerReplacementByTemplateFile() + { + $this->smarty->registerDefaultTemplateHandler('my_template_handler_file'); + $this->assertEquals("hello world", $this->smarty->fetch('foo.tpl')); + } + + /** + * test default template handler returning fals + */ + public function testDefaultTemplateHandlerReturningFalse() + { + $this->smarty->registerDefaultTemplateHandler('my_false'); + try { + $this->smarty->fetch('foo.tpl'); + } + catch (Exception $e) { + $this->assertContains('Default handler: No template default content for \'file:foo.tpl\'', $e->getMessage()); + + return; + } + $this->fail('Exception for none existing template has not been raised.'); + } +} + +function my_template_handler($resource_type, $resource_name, &$template_source, &$template_timestamp, Smarty $smarty) +{ + $output = "Recsource $resource_name of type $resource_type not found"; + $template_source = $output; + $template_timestamp = time(); + + return true; +} + +function my_template_handler_file($resource_type, $resource_name, &$template_source, &$template_timestamp, Smarty $smarty) +{ + return $smarty->getTemplateDir(0) . 'helloworld.tpl'; +} + +function my_false($resource_type, $resource_name, &$template_source, &$template_timestamp, Smarty $smarty) +{ + return false; +} diff --git a/tests/UnitTests/ResourceTests/DefaultHandler/cache/.gitignore b/tests/UnitTests/ResourceTests/DefaultHandler/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/DefaultHandler/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/DefaultHandler/templates/helloworld.tpl b/tests/UnitTests/ResourceTests/DefaultHandler/templates/helloworld.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/ResourceTests/DefaultHandler/templates/helloworld.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/DefaultHandler/templates_c/.gitignore b/tests/UnitTests/ResourceTests/DefaultHandler/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/DefaultHandler/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php b/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php new file mode 100644 index 00000000..27635f02 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php @@ -0,0 +1,188 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test template eval exits + */ + public function testTemplateEvalExists1() + { + $tpl = $this->smarty->createTemplate('eval:{$foo}'); + $this->assertTrue($tpl->source->exists); + } + + public function testTemplateEvalExists2() + { + $this->assertTrue($this->smarty->templateExists('eval:{$foo}')); + } + + /** + * test getTemplateFilepath + */ + public function testGetTemplateFilepath() + { + $tpl = $this->smarty->createTemplate('eval:hello world'); + $this->assertEquals('2aae6c35c94fcfb415dbe95f408b9ce91ee846ed', $tpl->source->filepath); + } + + /** + * test getTemplateTimestamp + */ + public function testGetTemplateTimestamp() + { + $tpl = $this->smarty->createTemplate('eval:hello world'); + $this->assertTrue($tpl->source->getTimeStamp()); + } + + /** + * test getTemplateSource + */ + public function testGetTemplateSource() + { + $tpl = $this->smarty->createTemplate('eval:hello world{$foo}'); + $this->assertEquals('hello world{$foo}', $tpl->source->getContent()); + } + + /** + * test empty templates + */ + public function testEmptyTemplate() + { + $tpl = $this->smarty->createTemplate('eval:'); + $this->assertEquals('', $this->smarty->fetch($tpl)); + } + + /** + * test usesCompiler + */ + public function testUsesCompiler() + { + $tpl = $this->smarty->createTemplate('eval:hello world'); + $this->assertFalse($tpl->source->handler->uncompiled); + } + + /** + * test isEvaluated + */ + public function testIsEvaluated() + { + $tpl = $this->smarty->createTemplate('eval:hello world'); + $this->assertTrue($tpl->source->handler->recompiled); + } + + /** + * test mustCompile + */ + public function testMustCompile() + { + $tpl = $this->smarty->createTemplate('eval:hello world'); + $this->assertTrue($tpl->mustCompile()); + } + + /** + * test getCompiledFilepath + */ + public function testGetCompiledFilepath() + { + $tpl = $this->smarty->createTemplate('eval:hello world'); + $this->assertFalse($tpl->compiled->filepath); + } + + /** + * test getCompiledTimestamp + */ + public function testGetCompiledTimestamp() + { + $tpl = $this->smarty->createTemplate('eval:hello world'); + $this->assertFalse($tpl->compiled->getTimeStamp()); + } + + /** + * test isCached + */ + public function testIsCached() + { + $tpl = $this->smarty->createTemplate('eval:hello world'); + $this->assertFalse($tpl->isCached()); + } + + /** + * test getRenderedTemplate + */ + public function testGetRenderedTemplate() + { + $tpl = $this->smarty->createTemplate('eval:hello world'); + $this->assertEquals('hello world', $tpl->fetch()); + } + + /** + * test that no complied template and cache file was produced + */ + public function testNoFiles() + { + $this->cleanDir($this->smarty->getCacheDir()); + $this->cleanDir($this->smarty->getCompileDir()); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 20; + $tpl = $this->smarty->createTemplate('eval:hello world'); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + $this->assertEquals(0, $this->smarty->clearAllCache()); + $this->assertEquals(0, $this->smarty->clearCompiledTemplate()); + } + + /** + * test $smarty->is_cached + */ + public function testSmartyIsCached() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 20; + $tpl = $this->smarty->createTemplate('eval:hello world'); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + $this->assertFalse($this->smarty->isCached($tpl)); + } + + public function testUrlencodeTemplate() + { + $tpl = $this->smarty->createTemplate('eval:urlencode:%7B%22foobar%22%7Cescape%7D'); + $this->assertEquals('foobar', $tpl->fetch()); + } + + public function testBase64Template() + { + $tpl = $this->smarty->createTemplate('eval:base64:eyJmb29iYXIifGVzY2FwZX0='); + $this->assertEquals('foobar', $tpl->fetch()); + } + + /** + * test clearCompiledTemplate() + */ + public function testClearCompiled() + { + $this->assertEquals(0, $this->smarty->clearCompiledTemplate('eval:hello world')); + } + +} diff --git a/tests/UnitTests/ResourceTests/Eval/cache/.gitignore b/tests/UnitTests/ResourceTests/Eval/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Eval/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Eval/templates_c/.gitignore b/tests/UnitTests/ResourceTests/Eval/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Eval/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php b/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php new file mode 100644 index 00000000..3012f34f --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php @@ -0,0 +1,326 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->enableSecurity(); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + public function compiledPrefilter($text, Smarty_Internal_Template $tpl) + { + return str_replace('#', $tpl->getTemplateVars('test'), $text); + } + + /** + * test child/parent template chain with prepend + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildPrepend_003($caching, $merge, $testNumber, $compileTestNumber, $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->caching = $caching; + $this->smarty->merge_compiled_includes = $merge; + if ($merge) { + $this->smarty->compile_id = 1; + } + $result = $this->smarty->fetch('extends:003_parent.tpl|003_child_prepend.tpl'); + $this->assertContains("prepend - Default Title", $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $testName . ' - fetch() failure'); + } + /** + * test child/parent template chain with apppend + * @run InSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildAppend_004($caching, $merge, $testNumber, $compileTestNumber, $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->caching = $caching; + $this->smarty->merge_compiled_includes = $merge; + if ($merge) { + $this->smarty->compile_id = 1; + } + $result = $this->smarty->fetch('extends:004_parent.tpl|004_child_append.tpl'); + $this->assertContains("Default Title - append", $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with apppend + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockAssignInChild_040($caching, $merge, $testNumber, $compileTestNumber, $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->caching = $caching; + $this->smarty->merge_compiled_includes = $merge; + if ($merge) { + $this->smarty->compile_id = 1; + } + $result = $this->smarty->fetch('extends:040_parent.tpl|040_child.tpl'); + $this->assertContains("var-bar-var", $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $testName . ' - fetch() failure'); + } + + /** + * test grandchild/child/parent dependency test1 + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testCompileBlockGrandChildMustCompile_021_1() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('Grandchild Page Title', $result); + } + + /** + * test grandchild/child/parent dependency test1 + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testCompileBlockGrandChildMustCompile_021_12() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('Grandchild Page Title', $result); + } + + /** + * test grandchild/child/parent dependency test2 + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_2() + { + sleep(2); + touch($this->smarty->getTemplateDir(0) . '021_grandchild.tpl'); + clearstatcache(); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('Grandchild Page Title', $result); + } + /** + * test grandchild/child/parent dependency test2 + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_22() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('Grandchild Page Title', $result); + } + + /** + * test grandchild/child/parent dependency test3 + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_3() + { + sleep(2); + touch($this->smarty->getTemplateDir(0) . '021_child.tpl'); + clearstatcache(); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('Grandchild Page Title', $result); + } + /** + * test grandchild/child/parent dependency test3 + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_32() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('Grandchild Page Title', $result); + } + + /** + * test grandchild/child/parent dependency test4 + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_4() + { + sleep(2); + touch($this->smarty->getTemplateDir(0) . '021_parent.tpl'); + clearstatcache(); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('Grandchild Page Title', $result); + } + /** + * test grandchild/child/parent dependency test4 + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_42() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); + $this->assertTrue($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('Grandchild Page Title', $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('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( + /* + * caching + * merging + * test nr + * result compile nr + * result render nr + * text + */ + array(false, false, 1, 1, 1, 'no caching, no merge - new'), + array(false, false, 2, 1, 2, 'no caching, no merge - exits'), + array(true, false, 3, 3, 3, 'caching, no merge - new'), + array(true, false, 4, 3, 3, 'caching, no merge - exits'), + array(false, true, 5, 5, 5, 'no caching, merge - new'), + array(false, true, 6, 5, 6, 'no caching, merge - exits'), + array(true, true, 7, 7, 7, 'caching, merge - new'), + array(true, true, 8, 7, 7, 'caching, merge - exits'), + ); + } + /** + * test relative includes in {block} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data2 + */ + public function testCompileBlockExtendsRecursion_034($extends_recursion, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + if (!property_exists($this->smarty, 'extends_recursion')) { + $this->markTestSkipped('no extends_recursion'); + } else { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setExtendsRecursion($extends_recursion); + $this->smarty->setMergeCompiledIncludes($merge); + $cid = 0; + if ($merge) { + $cid = 1; + } + if ($extends_recursion) { + $cid += 2; + } + $this->smarty->setCompileId($cid); + $result = $this->smarty->fetch('extends:034_parent.tpl|034_grandchild.tpl'); + $this->assertContains('grandchild - grandchild', $result, $testName . ' - grand'); + $this->assertContains('parent - parent', $result, $testName . ' - grand'); + $this->assertContains($extends_recursion ? 'child - child' : 'child - parent', $result, + $testName . ' - grand'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", + $result, $testName . ' - fetch() failure'); + } + } + public function data2(){ + return array( + /* + * extends_recursion + * merging + * test nr + * result compile nr + * result render nr + * text + */ + array(false, false, 1, 1, 1, 'no EXTENDS; no merge - new'), + array(false, false, 2, 1, 2, 'no EXTENDS; no merge - exits'), + array(true, false, 3, 3, 3, 'EXTENDS; no merge - new'), + array(true, false, 4, 3, 4, 'EXTENDS; no merge - exits'), + array(false, true, 5, 5, 5, 'no EXTENDS; merge - new'), + array(false, true, 6, 5, 6, 'no EXTENDS; merge - exits'), + array(true, true, 7, 7, 7, 'EXTENDS; merge - new'), + array(true, true, 8, 7, 8, 'EXTENDS; merge - exits'), + ); + } + +} + diff --git a/tests/UnitTests/ResourceTests/Extends/cache/.gitignore b/tests/UnitTests/ResourceTests/Extends/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Extends/templates/003_child_prepend.tpl b/tests/UnitTests/ResourceTests/Extends/templates/003_child_prepend.tpl new file mode 100644 index 00000000..0e0d05bf --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/003_child_prepend.tpl @@ -0,0 +1 @@ +{block name='title' prepend}prepend - {/block} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/003_parent.tpl b/tests/UnitTests/ResourceTests/Extends/templates/003_parent.tpl new file mode 100644 index 00000000..afcf7d7c --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/003_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='title'}Default Title{/block} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/004_child_append.tpl b/tests/UnitTests/ResourceTests/Extends/templates/004_child_append.tpl new file mode 100644 index 00000000..e18550fb --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/004_child_append.tpl @@ -0,0 +1 @@ +{block name='title' append} - append{/block} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/004_parent.tpl b/tests/UnitTests/ResourceTests/Extends/templates/004_parent.tpl new file mode 100644 index 00000000..afcf7d7c --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/004_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='title'}Default Title{/block} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/021_child.tpl b/tests/UnitTests/ResourceTests/Extends/templates/021_child.tpl new file mode 100644 index 00000000..7c5bda39 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/021_child.tpl @@ -0,0 +1 @@ +{block name='title'}Page Title{/block} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/021_grandchild.tpl b/tests/UnitTests/ResourceTests/Extends/templates/021_grandchild.tpl new file mode 100644 index 00000000..afedae7c --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/021_grandchild.tpl @@ -0,0 +1 @@ +{block name='title'}Grandchild Page Title{/block} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/021_parent.tpl b/tests/UnitTests/ResourceTests/Extends/templates/021_parent.tpl new file mode 100644 index 00000000..e007864b --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/021_parent.tpl @@ -0,0 +1 @@ +{block name='title'}Default Title{/block} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/022_child.tpl b/tests/UnitTests/ResourceTests/Extends/templates/022_child.tpl new file mode 100644 index 00000000..305d805b --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/022_child.tpl @@ -0,0 +1,4 @@ +{extends file='022_parent.tpl'} +{block name='title'}Page Title{/block} + + 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/034_child.tpl b/tests/UnitTests/ResourceTests/Extends/templates/034_child.tpl new file mode 100644 index 00000000..0ef80b8b --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/034_child.tpl @@ -0,0 +1,3 @@ +{block 'grandchild'}grandchild - child{/block} +{block 'child'}child - child{/block} + diff --git a/tests/UnitTests/ResourceTests/Extends/templates/034_grandchild.tpl b/tests/UnitTests/ResourceTests/Extends/templates/034_grandchild.tpl new file mode 100644 index 00000000..cd036c5b --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/034_grandchild.tpl @@ -0,0 +1,3 @@ +{extends '034_child.tpl'} +{block 'grandchild'}grandchild - grandchild{/block} + diff --git a/tests/UnitTests/ResourceTests/Extends/templates/034_parent.tpl b/tests/UnitTests/ResourceTests/Extends/templates/034_parent.tpl new file mode 100644 index 00000000..d57c39ee --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/034_parent.tpl @@ -0,0 +1,4 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block 'grandchild'}grandchild - parent{/block} +{block 'child'}child - parent{/block} +{block 'parent'}parent - parent{/block} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/040_child.tpl b/tests/UnitTests/ResourceTests/Extends/templates/040_child.tpl new file mode 100644 index 00000000..54e64f92 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/040_child.tpl @@ -0,0 +1 @@ +{$foo = 'bar'} diff --git a/tests/UnitTests/ResourceTests/Extends/templates/040_parent.tpl b/tests/UnitTests/ResourceTests/Extends/templates/040_parent.tpl new file mode 100644 index 00000000..85d2795a --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates/040_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='test'}var-{$foo}-var{/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/ResourceTests/Extends/templates_c/.gitignore b/tests/UnitTests/ResourceTests/Extends/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Extends/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/File/FileResourceTest.php b/tests/UnitTests/ResourceTests/File/FileResourceTest.php new file mode 100644 index 00000000..1a1d615a --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/FileResourceTest.php @@ -0,0 +1,602 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->enableSecurity(); + } + + public function testInit() + { + $this->cleanDirs(); + } + + protected function relative($path) + { + $path = str_replace(str_replace("\\", "/", dirname(__FILE__)), '.', str_replace("\\", "/", $path)); + + return $path; + } + + /** + * + */ + public function testGetTemplateFilepath() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertEquals($this->normalizePath("./templates/helloworld.tpl"), $tpl->source->filepath); + } + + public function testTemplateFileExists1() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertTrue($tpl->source->exists); + } + + public function testTemplateFileExists2() + { + $this->assertTrue($this->smarty->templateExists('helloworld.tpl')); + } + + public function testTemplateFileNotExists1() + { + $tpl = $this->smarty->createTemplate('notthere.tpl'); + $this->assertFalse($tpl->source->exists); + } + + public function testTemplateFileNotExists2() + { + $this->assertFalse($this->smarty->templateExists('notthere.tpl')); + } + + /** + * @expectedException SmartyException + * @expectedExceptionMessage Unable to + * @expectedExceptionMessage notthere.tpl + * + * test not existing file + */ + public function testTemplateFileNotExists3() + { + + $result = $this->smarty->fetch('notthere.tpl'); + } + + public function testGetTemplateTimestamp() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertTrue(is_integer($tpl->source->getTimeStamp())); + $this->assertEquals(10, strlen($tpl->source->getTimeStamp())); + } + + public function testGetTemplateSource() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertEquals('hello world', $tpl->source->getContent()); + } + + public function testUsesCompiler() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertFalse($tpl->source->handler->uncompiled); + } + + public function testIsEvaluated() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertFalse($tpl->source->handler->recompiled); + } + + public function testGetCompiledFilepath() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertEquals($this->buildCompiledPath($tpl, false, false, null, 'helloworld.tpl', 'file', $this->smarty->getTemplateDir(0)) + , $tpl->compiled->filepath + ); + } + + public function testGetCompiledTimestampPrepare() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + // create dummy compiled file + file_put_contents($tpl->compiled->filepath, ''); + touch($tpl->compiled->filepath, $tpl->source->getTimeStamp()); + } + + /** + * + */ + public function testGetCompiledTimestamp() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertTrue(is_integer($tpl->compiled->getTimeStamp())); + $this->assertEquals(10, strlen($tpl->compiled->getTimeStamp())); + $this->assertEquals($tpl->compiled->getTimeStamp(), $tpl->source->getTimeStamp()); + } + + public function testMustCompileExisting() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertFalse($tpl->mustCompile()); + } + + public function testMustCompileAtForceCompile() + { + $this->smarty->setForceCompile(true); + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertTrue($tpl->mustCompile()); + } + + public function testMustCompileTouchedSourcePrepare() + { + // touch to prepare next test + sleep(2); + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + touch($tpl->source->filepath); + } + public function testMustCompileTouchedSource() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertTrue($tpl->mustCompile()); + // clean up for next tests + $this->cleanDir($this->smarty->getCompileDir()); + } + + public function testCompileTemplateFile() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $tpl->compileTemplateSource(); + $this->assertTrue(file_exists($tpl->compiled->filepath)); + } + + public function testGetCachedFilepath() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertEquals($this->buildCachedPath($tpl, false, null, null, 'helloworld.tpl', 'file', $this->smarty->getTemplateDir(0), 'file') + , $tpl->cached->filepath + ); + } + + public function testGetCachedTimestamp() + { + // create dummy cache file for the following test + file_put_contents($this->buildCachedPath($this->smarty, false, null, null, 'helloworld.tpl', 'file', $this->smarty->getTemplateDir(0), 'file') + , ''); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertTrue(is_integer($tpl->cached->timestamp)); + $this->assertEquals(10, strlen($tpl->cached->timestamp)); + } + + + public function testGetRenderedTemplate() + { + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $this->assertEquals('hello world', $tpl->fetch()); + } + + public function testRelativeInclude() + { + $result = $this->smarty->fetch('relative.tpl'); + $this->assertContains('hello world', $result); + } + + /** + * + * @run InSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRelativeIncludeSub() + { + $result = $this->smarty->fetch('sub/relative.tpl'); + $this->assertContains('hello world', $result); + } + /** + * @expectedException SmartyException + * @expectedExceptionMessage Unable to + * @expectedExceptionMessage notthereh.tpl + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test relative include fail + */ + public function testRelativeIncludeFail() + { + $result = $this->smarty->fetch('relative_sub.tpl'); + } + /** + * @expectedException SmartyException + * @expectedExceptionMessage ./hello.tpl + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test relative include fail other dir + */ + public function testRelativeIncludeFailOtherDir() + { + $this->smarty->addTemplateDir('./templates_2'); + $result = $this->smarty->fetch('relative_notexist.tpl'); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRelativeFetch() + { + $this->smarty->setTemplateDir(array( + dirname(__FILE__) . '/does-not-exist/', + dirname(__FILE__) . '/templates/sub/', + )); + $this->smarty->security_policy = null; + $this->assertEquals('hello world', $this->smarty->fetch('./relative.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRelativeFetch2() + { + $this->smarty->setTemplateDir(array( + dirname(__FILE__) . '/does-not-exist/', + dirname(__FILE__) . '/templates/sub/', + )); + $this->smarty->security_policy = null; + $this->assertEquals('hello world', $this->smarty->fetch('../helloworld.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRelativeFetchCwd() + { + $cwd = getcwd(); + chdir(dirname(__FILE__) . '/templates/sub/'); + $dn = dirname(__FILE__); + $this->smarty->setCompileDir($dn . '/templates_c/'); + $this->smarty->setCacheDir($dn . '/cache/'); + $this->smarty->setTemplateDir(array( + dirname(__FILE__) . '/does-not-exist/', + )); + $this->smarty->security_policy = null; + $this->assertEquals('hello world', $this->smarty->fetch('./relative.tpl')); + chdir($cwd); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRelativeFetchCwd2() + { + $cwd = getcwd(); + chdir(dirname(__FILE__) . '/templates/sub/'); + $dn = dirname(__FILE__); + $this->smarty->setCompileDir($dn . '/templates_c/'); + $this->smarty->setCacheDir($dn . '/cache/'); + $this->smarty->setTemplateDir(array( + dirname(__FILE__) . '/does-not-exist/', + )); + $this->smarty->security_policy = null; + $this->assertEquals('hello world', $this->smarty->fetch('../helloworld.tpl')); + chdir($cwd); + } + + protected function _relativeMap($map, $cwd = null) + { + foreach ($map as $file => $result) { + $this->cleanDir($this->smarty->getCompileDir()); + $this->cleanDir($this->smarty->getCacheDir()); + + if ($result === null) { + try { + $this->smarty->fetch($file); + if ($cwd !== null) { + chdir($cwd); + } + + $this->fail('Exception expected for ' . $file); + + return; + } + catch (SmartyException $e) { + // this was expected to fail + } + } else { + try { + $_res = $this->smarty->fetch($file); + $this->assertEquals(str_replace("\r", '', $result), $_res, $file); + } + catch (Exception $e) { + if ($cwd !== null) { + chdir($cwd); + } + + throw $e; + } + } + } + + if ($cwd !== null) { + chdir($cwd); + } + } + + public function testRelativity() + { + $this->smarty->security_policy = null; + + $cwd = getcwd(); + $dn = dirname(__FILE__); + $this->smarty->setCompileDir($dn . '/templates_c/'); + $this->smarty->setCacheDir($dn . '/cache/'); + $this->smarty->setTemplateDir(array($dn . '/templates/relativity/theory/',)); + + $map = array('foo.tpl' => 'theory', './foo.tpl' => 'theory', '././foo.tpl' => 'theory', + '.././foo.tpl' => 'relativity', './../foo.tpl' => 'relativity', + 'einstein/foo.tpl' => 'einstein', './einstein/foo.tpl' => 'einstein', + '../theory/einstein/foo.tpl' => 'einstein', 'templates/relativity/relativity.tpl' => 'relativity', + './templates/relativity/relativity.tpl' => 'relativity',); + + $this->_relativeMap($map); + } + + public function testRelativity2() + { + $this->smarty->security_policy = null; + + $cwd = getcwd(); + $dn = dirname(__FILE__); + $this->smarty->setCompileDir($dn . '/templates_c/'); + $this->smarty->setCacheDir($dn . '/cache/'); + + + $this->smarty->setTemplateDir(array( + './templates/relativity/theory/', + )); + + $map = array( + 'foo.tpl' => 'theory', + './foo.tpl' => 'theory', + '././foo.tpl' => 'theory', + '../foo.tpl' => 'relativity', + '.././foo.tpl' => 'relativity', + './../foo.tpl' => 'relativity', + 'einstein/foo.tpl' => 'einstein', + './einstein/foo.tpl' => 'einstein', + '../theory/einstein/foo.tpl' => 'einstein', + 'templates/relativity/relativity.tpl' => 'relativity', + './templates/relativity/relativity.tpl' => 'relativity', + ); + + $this->_relativeMap($map); + } + + public function testRelativityCwd() + { + $this->smarty->security_policy = null; + + $cwd = getcwd(); + $dn = dirname(__FILE__); + + $this->smarty->setCompileDir($dn . '/templates_c/'); + $this->smarty->setCacheDir($dn . '/cache/'); + chdir($dn . '/templates/relativity/theory/'); + $this->smarty->setTemplateDir(array( + $dn . '/templates/', + )); + + $map = array( + 'foo.tpl' => 'theory', + './foo.tpl' => 'theory', + '././foo.tpl' => 'theory', + '../foo.tpl' => 'relativity', + '.././foo.tpl' => 'relativity', + './../foo.tpl' => 'relativity', + 'einstein/foo.tpl' => 'einstein', + './einstein/foo.tpl' => 'einstein', + '../theory/einstein/foo.tpl' => 'einstein', + ); + + $this->_relativeMap($map, $cwd); + } + + public function testRelativityPrecedence() + { + $this->smarty->security_policy = null; + + $cwd = getcwd(); + $dn = dirname(__FILE__); + + $this->smarty->setCompileDir($dn . '/templates_c/'); + $this->smarty->setCacheDir($dn . '/cache/'); + $this->smarty->setTemplateDir(array($dn . '/templates/relativity/theory/einstein/',)); + + $map = array('foo.tpl' => 'einstein', './foo.tpl' => 'einstein', '././foo.tpl' => 'einstein', + '../foo.tpl' => 'theory', '.././foo.tpl' => 'theory', './../foo.tpl' => 'theory', + '../../foo.tpl' => 'relativity',); + + chdir($dn . '/templates/relativity/theory/'); + $this->smarty->setTemplateDir(array($dn . '/templates/relativity/theory/einstein/',)); + $this->_relativeMap($map, $cwd); + } + + public function testRelativityPrecedence2() + { + $this->smarty->security_policy = null; + + $cwd = getcwd(); + $dn = dirname(__FILE__); + + $this->smarty->setCompileDir($dn . '/templates_c/'); + $this->smarty->setCacheDir($dn . '/cache/'); + $this->smarty->setTemplateDir(array( + $dn . '/templates/relativity/theory/einstein/', + )); + + + $map = array( + '../theory.tpl' => 'theory', + './theory.tpl' => 'theory', + '../../relativity.tpl' => 'relativity', + '../relativity.tpl' => 'relativity', + './einstein.tpl' => 'einstein', + 'einstein/einstein.tpl' => 'einstein', + './einstein/einstein.tpl' => 'einstein', + ); + + chdir($dn . '/templates/relativity/theory/'); + $this->smarty->setTemplateDir(array( + $dn . '/templates/relativity/theory/einstein/', + )); + $this->_relativeMap($map, $cwd); + } + + public function testRelativityRelRel() + { + $this->smarty->security_policy = null; + + $cwd = getcwd(); + $dn = dirname(__FILE__); + + $this->smarty->setCompileDir($dn . '/templates_c/'); + $this->smarty->setCacheDir($dn . '/cache/'); + $this->smarty->setTemplateDir(array('../..',)); + + $map = array('foo.tpl' => 'relativity', './foo.tpl' => 'relativity', '././foo.tpl' => 'relativity',); + + chdir($dn . '/templates/relativity/theory/einstein'); + $this->smarty->setTemplateDir(array('../..',)); + $this->_relativeMap($map, $cwd); + } + + public function testRelativityRelRel2() + { + $this->smarty->security_policy = null; + + $cwd = getcwd(); + $dn = dirname(__FILE__); + + $this->smarty->setCompileDir($dn . '/templates_c/'); + $this->smarty->setCacheDir($dn . '/cache/'); + $this->smarty->setTemplateDir(array('../..',)); + + $map = + array('relativity.tpl' => 'relativity', './relativity.tpl' => 'relativity', 'theory/theory.tpl' => 'theory', + './theory/theory.tpl' => 'theory',); + + chdir($dn . '/templates/relativity/theory/einstein/'); + $this->smarty->setTemplateDir(array('../..',)); + $this->_relativeMap($map, $cwd); + } + public function testRelativityRelRel3() + { + $this->smarty->security_policy = null; + + $cwd = getcwd(); + $dn = dirname(__FILE__); + + $this->smarty->setCompileDir($dn . '/templates_c/'); + $this->smarty->setCacheDir($dn . '/cache/'); + $this->smarty->setTemplateDir(array( + '../..', + )); + + + $map = array( + 'foo.tpl' => 'theory', + './foo.tpl' => 'theory', + 'theory.tpl' => 'theory', + './theory.tpl' => 'theory', + 'einstein/einstein.tpl' => 'einstein', + './einstein/einstein.tpl' => 'einstein', + '../theory/einstein/einstein.tpl' => 'einstein', + '../relativity.tpl' => 'relativity', + './../relativity.tpl' => 'relativity', + '.././relativity.tpl' => 'relativity', + ); + + chdir($dn . '/templates/relativity/theory/einstein/'); + $this->smarty->setTemplateDir(array( + '..', + )); + $this->_relativeMap($map, $cwd); + } + + public function testRelativityRelRel1() + { + $this->smarty->security_policy = null; + + $cwd = getcwd(); + $dn = dirname(__FILE__); + $this->smarty->setCompileDir($dn . '/templates_c/'); + $this->smarty->setCacheDir($dn . '/cache/'); + $this->smarty->setTemplateDir(array( + '..', + )); + + $map = array( + 'foo.tpl' => 'theory', + './foo.tpl' => 'theory', + 'theory.tpl' => 'theory', + './theory.tpl' => 'theory', + 'einstein/einstein.tpl' => 'einstein', + './einstein/einstein.tpl' => 'einstein', + '../theory/einstein/einstein.tpl' => 'einstein', + '../relativity.tpl' => 'relativity', + './../relativity.tpl' => 'relativity', + '.././relativity.tpl' => 'relativity', + ); + + chdir($dn . '/templates/relativity/theory/einstein/'); + $this->smarty->setTemplateDir(array( + '..', + )); + $this->_relativeMap($map, $cwd); + } + + /** + * test {$smarty.template} + * + */ + public function testSmartyTemplate() { + $this->assertEquals('template = 001_smarty_template.tpl', $this->smarty->fetch('001_smarty_template.tpl')); + } + /** + * test {$smarty.current_dir} + * + */ + public function testSmartyCurrentDir() { + $dirname = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates'; + $this->assertEquals('current_dir = ' . $dirname, $this->smarty->fetch('001_smarty_current_dir.tpl')); + } +} diff --git a/tests/UnitTests/ResourceTests/File/cache/.gitignore b/tests/UnitTests/ResourceTests/File/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/File/templates/001_smarty_current_dir.tpl b/tests/UnitTests/ResourceTests/File/templates/001_smarty_current_dir.tpl new file mode 100644 index 00000000..9dfa5fe8 --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/001_smarty_current_dir.tpl @@ -0,0 +1 @@ +current_dir = {$smarty.current_dir} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/001_smarty_template.tpl b/tests/UnitTests/ResourceTests/File/templates/001_smarty_template.tpl new file mode 100644 index 00000000..b1c00b29 --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/001_smarty_template.tpl @@ -0,0 +1 @@ +template = {$smarty.template} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/dirname.tpl b/tests/UnitTests/ResourceTests/File/templates/dirname.tpl new file mode 100644 index 00000000..f10e14ab --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/dirname.tpl @@ -0,0 +1 @@ +templates \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/helloworld.tpl b/tests/UnitTests/ResourceTests/File/templates/helloworld.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/helloworld.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/relative.tpl b/tests/UnitTests/ResourceTests/File/templates/relative.tpl new file mode 100644 index 00000000..5f34e470 --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/relative.tpl @@ -0,0 +1 @@ +{include file="./helloworld.tpl"} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/relative_notexist.tpl b/tests/UnitTests/ResourceTests/File/templates/relative_notexist.tpl new file mode 100644 index 00000000..11fad976 --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/relative_notexist.tpl @@ -0,0 +1 @@ +{include file="./hello.tpl"} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/relative_sub.tpl b/tests/UnitTests/ResourceTests/File/templates/relative_sub.tpl new file mode 100644 index 00000000..0185682d --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/relative_sub.tpl @@ -0,0 +1 @@ +{include file="../helloworld.tpl"} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/relativity/foo.tpl b/tests/UnitTests/ResourceTests/File/templates/relativity/foo.tpl new file mode 100644 index 00000000..bf4a29c0 --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/relativity/foo.tpl @@ -0,0 +1 @@ +relativity \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/relativity/relativity.tpl b/tests/UnitTests/ResourceTests/File/templates/relativity/relativity.tpl new file mode 100644 index 00000000..bf4a29c0 --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/relativity/relativity.tpl @@ -0,0 +1 @@ +relativity \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/relativity/theory/einstein/einstein.tpl b/tests/UnitTests/ResourceTests/File/templates/relativity/theory/einstein/einstein.tpl new file mode 100644 index 00000000..88e90d97 --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/relativity/theory/einstein/einstein.tpl @@ -0,0 +1 @@ +einstein \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/relativity/theory/einstein/foo.tpl b/tests/UnitTests/ResourceTests/File/templates/relativity/theory/einstein/foo.tpl new file mode 100644 index 00000000..88e90d97 --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/relativity/theory/einstein/foo.tpl @@ -0,0 +1 @@ +einstein \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/relativity/theory/foo.tpl b/tests/UnitTests/ResourceTests/File/templates/relativity/theory/foo.tpl new file mode 100644 index 00000000..195d46ee --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/relativity/theory/foo.tpl @@ -0,0 +1 @@ +theory \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/relativity/theory/theory.tpl b/tests/UnitTests/ResourceTests/File/templates/relativity/theory/theory.tpl new file mode 100644 index 00000000..195d46ee --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/relativity/theory/theory.tpl @@ -0,0 +1 @@ +theory \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates/sub/relative.tpl b/tests/UnitTests/ResourceTests/File/templates/sub/relative.tpl new file mode 100644 index 00000000..0185682d --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates/sub/relative.tpl @@ -0,0 +1 @@ +{include file="../helloworld.tpl"} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates_2/hello.tpl b/tests/UnitTests/ResourceTests/File/templates_2/hello.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates_2/hello.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/File/templates_c/.gitignore b/tests/UnitTests/ResourceTests/File/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/File/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php b/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php new file mode 100644 index 00000000..8ba53fb3 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php @@ -0,0 +1,67 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->use_include_path = true; + $this->smarty->setTemplateDir(array('./templates', './templates_2', './include')); + $this->smarty->enableSecurity(); + $ds = DIRECTORY_SEPARATOR; + set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Tpl{$ds}", true) . PATH_SEPARATOR . get_include_path()); + } + + /** + * Tears down the fixture + * This method is called after a test is executed. + * + */ + protected function tearDown() + { + ini_restore('include_path'); + $this->smarty->disableSecurity(); + parent::tearDown(); + } + public function testInit() + { + $this->cleanDirs(); + } + public function testInclude1() + { + $this->assertContains('include_test1', $this->smarty->fetch('test1.tpl')); + } + public function testInclude2() + { + $this->assertContains('include_test2', $this->smarty->fetch('test2.tpl')); + } + public function testInclude3() + { + $this->assertContains('include_test3', $this->smarty->fetch('test3.tpl')); + } + public function testInclude31() + { + $this->smarty->use_include_path = false; + $this->smarty->security_policy->secure_dir = getcwd(); + $this->assertContains('include_test3', $this->smarty->fetch('test3.tpl')); + } + public function testInclude4() + { + $this->assertContains('include_test4', $this->smarty->fetch('test4.tpl')); + } + public function testInclude5() + { + $this->smarty->setTemplateDir(array('./')); + $this->assertContains('include path root', $this->smarty->fetch('test5.tpl')); + } + + } diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/cache/.gitignore b/tests/UnitTests/ResourceTests/FileIncludePath/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/include_test3.tpl b/tests/UnitTests/ResourceTests/FileIncludePath/include_test3.tpl new file mode 100644 index 00000000..61298afb --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/include_test3.tpl @@ -0,0 +1 @@ +include_test3 diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/templates/dirname.tpl b/tests/UnitTests/ResourceTests/FileIncludePath/templates/dirname.tpl new file mode 100644 index 00000000..f10e14ab --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/templates/dirname.tpl @@ -0,0 +1 @@ +templates \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/templates/test1.tpl b/tests/UnitTests/ResourceTests/FileIncludePath/templates/test1.tpl new file mode 100644 index 00000000..dcc96887 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/templates/test1.tpl @@ -0,0 +1 @@ +{include 'include_test1.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/templates/test2.tpl b/tests/UnitTests/ResourceTests/FileIncludePath/templates/test2.tpl new file mode 100644 index 00000000..b5d41850 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/templates/test2.tpl @@ -0,0 +1 @@ +{include 'include_test2.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/templates/test3.tpl b/tests/UnitTests/ResourceTests/FileIncludePath/templates/test3.tpl new file mode 100644 index 00000000..5d5690be --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/templates/test3.tpl @@ -0,0 +1 @@ +{include 'include_test3.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/templates_2/dirname.tpl b/tests/UnitTests/ResourceTests/FileIncludePath/templates_2/dirname.tpl new file mode 100644 index 00000000..b6e9ce55 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/templates_2/dirname.tpl @@ -0,0 +1 @@ +templates_2 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/templates_2/include_test1.tpl b/tests/UnitTests/ResourceTests/FileIncludePath/templates_2/include_test1.tpl new file mode 100644 index 00000000..c8d49087 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/templates_2/include_test1.tpl @@ -0,0 +1 @@ +include_test1 diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/templates_3/dirname.tpl b/tests/UnitTests/ResourceTests/FileIncludePath/templates_3/dirname.tpl new file mode 100644 index 00000000..404b4397 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/templates_3/dirname.tpl @@ -0,0 +1 @@ +templates_3 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/templates_4/dirname.tpl b/tests/UnitTests/ResourceTests/FileIncludePath/templates_4/dirname.tpl new file mode 100644 index 00000000..b744ef31 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/templates_4/dirname.tpl @@ -0,0 +1 @@ +templates_4 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/templates_c/.gitignore b/tests/UnitTests/ResourceTests/FileIncludePath/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/FileIndexed/FileResourceIndexedTest.php b/tests/UnitTests/ResourceTests/FileIndexed/FileResourceIndexedTest.php new file mode 100644 index 00000000..9a1cf606 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/FileResourceIndexedTest.php @@ -0,0 +1,115 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_2'); + // note that 10 is a string! + $this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_3', '10'); + $this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_4', 'foo'); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testGetTemplateFilepath() + { + $tpl = $this->smarty->createTemplate('dirname.tpl'); + $this->assertEquals($this->normalizePath("./templates/dirname.tpl"), $tpl->source->filepath); + } + + public function testGetTemplateFilepathNumber() + { + $tpl = $this->smarty->createTemplate('[1]dirname.tpl'); + $this->assertEquals($this->normalizePath('./templates_2/dirname.tpl'), $tpl->source->filepath); + } + + public function testGetTemplateFilepathNumeric() + { + $tpl = $this->smarty->createTemplate('[10]dirname.tpl'); + $this->assertEquals($this->normalizePath('./templates_3/dirname.tpl'), $tpl->source->filepath); + } + + public function testGetTemplateFilepathName() + { + $tpl = $this->smarty->createTemplate('[foo]dirname.tpl'); + $this->assertEquals($this->normalizePath('./templates_4/dirname.tpl'), $tpl->source->filepath); + } + + public function testFetch() + { + $tpl = $this->smarty->createTemplate('dirname.tpl'); + $this->assertEquals('templates', $this->smarty->fetch($tpl)); + } + + public function testFetchNumber() + { + $tpl = $this->smarty->createTemplate('[1]dirname.tpl'); + $this->assertEquals('templates_2', $this->smarty->fetch($tpl)); + } + + public function testFetchNumeric() + { + $tpl = $this->smarty->createTemplate('[10]dirname.tpl'); + $this->assertEquals('templates_3', $this->smarty->fetch($tpl)); + } + public function testFetchNumeric2() + { + $tpl = $this->smarty->createTemplate('[10, 1]dirname10.tpl'); + $this->assertEquals('templates_3', $this->smarty->fetch($tpl)); + } + public function testFetchNumeric3() + { + $tpl = $this->smarty->createTemplate('[10, 1]dirname1.tpl'); + $this->assertEquals('templates_2', $this->smarty->fetch($tpl)); + } + + public function testFetchName() + { + $tpl = $this->smarty->createTemplate('[foo]dirname.tpl'); + $this->assertEquals('templates_4', $this->smarty->fetch($tpl)); + } + public function testFetchName1() + { + $tpl = $this->smarty->createTemplate('[10,0,1,foo]dirname_foo.tpl'); + $this->assertEquals('dirname_foo', $this->smarty->fetch($tpl)); + } + public function testFetchName2() + { + $tpl = $this->smarty->createTemplate('[0,1,foo,10]dirname_x.tpl'); + $this->assertEquals('templates_2', $this->smarty->fetch($tpl)); + } + public function testFetchName3() + { + $tpl = $this->smarty->createTemplate('[0,10,foo,1]dirname_x.tpl'); + $this->assertEquals('templates_4', $this->smarty->fetch($tpl)); + } + + public function testGetCompiledFilepath() + { + $tpl = $this->smarty->createTemplate('[foo]dirname.tpl'); + $this->assertEquals($this->buildCompiledPath($tpl, false, false, null, 'dirname.tpl', 'file', $this->smarty->getTemplateDir('foo')), $tpl->compiled->filepath); + } + + public function testGetCachedFilepath() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('[foo]dirname.tpl'); + $this->assertEquals($this->buildCachedPath($tpl, false, null, null, 'dirname.tpl', 'file', $this->smarty->getTemplateDir('foo')) + , $tpl->cached->filepath); + } +} diff --git a/tests/UnitTests/ResourceTests/FileIndexed/cache/.gitignore b/tests/UnitTests/ResourceTests/FileIndexed/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/FileIndexed/templates/dirname.tpl b/tests/UnitTests/ResourceTests/FileIndexed/templates/dirname.tpl new file mode 100644 index 00000000..f10e14ab --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/templates/dirname.tpl @@ -0,0 +1 @@ +templates \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname.tpl b/tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname.tpl new file mode 100644 index 00000000..b6e9ce55 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname.tpl @@ -0,0 +1 @@ +templates_2 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname1.tpl b/tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname1.tpl new file mode 100644 index 00000000..b6e9ce55 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname1.tpl @@ -0,0 +1 @@ +templates_2 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname_x.tpl b/tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname_x.tpl new file mode 100644 index 00000000..b6e9ce55 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/templates_2/dirname_x.tpl @@ -0,0 +1 @@ +templates_2 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIndexed/templates_3/dirname.tpl b/tests/UnitTests/ResourceTests/FileIndexed/templates_3/dirname.tpl new file mode 100644 index 00000000..404b4397 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/templates_3/dirname.tpl @@ -0,0 +1 @@ +templates_3 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIndexed/templates_3/dirname10.tpl b/tests/UnitTests/ResourceTests/FileIndexed/templates_3/dirname10.tpl new file mode 100644 index 00000000..404b4397 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/templates_3/dirname10.tpl @@ -0,0 +1 @@ +templates_3 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname.tpl b/tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname.tpl new file mode 100644 index 00000000..b744ef31 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname.tpl @@ -0,0 +1 @@ +templates_4 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname_foo.tpl b/tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname_foo.tpl new file mode 100644 index 00000000..17cac3cb --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname_foo.tpl @@ -0,0 +1 @@ +dirname_foo \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname_x.tpl b/tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname_x.tpl new file mode 100644 index 00000000..b744ef31 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/templates_4/dirname_x.tpl @@ -0,0 +1 @@ +templates_4 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIndexed/templates_c/.gitignore b/tests/UnitTests/ResourceTests/FileIndexed/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIndexed/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php b/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php new file mode 100644 index 00000000..dd4f20f0 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php @@ -0,0 +1,300 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + protected function relative($path) + { + $path = str_replace(str_replace("\\", "/", dirname(__FILE__)), '.', str_replace("\\", "/", $path)); + + return $path; + } + + /** + * test getTemplateFilepath + */ + public function testGetTemplateFilepath() + { + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertEquals($this->normalizePath("./templates/phphelloworld.php"), $tpl->source->filepath); + } + + /** + * test getTemplateTimestamp + */ + public function testGetTemplateTimestamp() + { + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertTrue(is_integer($tpl->source->getTimeStamp())); + $this->assertEquals(10, strlen($tpl->source->getTimeStamp())); + } + + /** + * test getTemplateSource + *-/ + * public function testGetTemplateSource() + * { + * $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + * $this->assertContains('php hello world', $tpl->source->getContent()); + * } + * /** + * test usesCompiler + */ + public function testUsesCompiler() + { + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertTrue($tpl->source->handler->uncompiled); + } + + /** + * test isEvaluated + */ + public function testIsEvaluated() + { + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertFalse($tpl->source->handler->recompiled); + } + + /** + * test mustCompile + */ + public function testMustCompile() + { + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertFalse($tpl->mustCompile()); + } + + /** + * test getCachedFilepath + */ + public function testGetCachedFilepath() + { + $this->smarty->setAllowPhpTemplates(true); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $expected = $this->buildCachedPath($tpl, false, null, null, 'phphelloworld.php', 'php', + $this->smarty->getTemplateDir(0), 'file'); + $this->assertEquals($expected, $tpl->cached->filepath); + } + + /** + * test create cache file used by the following tests + */ + public function testCreateCacheFile() + { + // create dummy cache file + $this->smarty->setAllowPhpTemplates(true); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertContains('php hello world', $this->smarty->fetch($tpl)); + } + + /** + * test getCachedTimestamp caching enabled + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testGetCachedTimestamp() + { + $this->smarty->setAllowPhpTemplates(true); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertTrue(is_integer($tpl->cached->timestamp)); + $this->assertEquals(10, strlen($tpl->cached->timestamp)); + } + + /** + * test isCached + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testIsCached() + { + $this->smarty->setAllowPhpTemplates(true); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 10000; + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertTrue($tpl->isCached()); + } + + /** + * test isCached caching disabled + */ + public function testIsCachedCachingDisabled() + { + $this->smarty->setAllowPhpTemplates(true); + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertFalse($tpl->isCached()); + } + + /** + * test isCached on touched source + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testIsCachedTouchedSourcePrepare() + { + $this->smarty->setAllowPhpTemplates(true); + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + sleep(2); + touch($tpl->source->filepath); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testIsCachedTouchedSource() + { + $this->smarty->setAllowPhpTemplates(true); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertFalse($tpl->isCached()); + } + + /** + * test is cache file is written + */ + public function testWriteCachedContent() + { + $this->smarty->setAllowPhpTemplates(true); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->cleanCacheDir(); + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->smarty->fetch($tpl); + $this->assertTrue(file_exists($tpl->cached->filepath)); + } + + /** + * test getRenderedTemplate + */ + public function testGetRenderedTemplate() + { + $this->smarty->setAllowPhpTemplates(true); + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertContains('php hello world', $tpl->fetch()); + } + + /** + * test $smarty->is_cached + */ + public function testSmartyIsCachedPrepare() + { + // clean up for next tests + $this->cleanCacheDir(); + $this->smarty->setAllowPhpTemplates(true); + // prepare files for next test + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->smarty->fetch($tpl); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testSmartyIsCached() + { + $this->smarty->setAllowPhpTemplates(true); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertTrue($this->smarty->isCached($tpl)); + } + + /** + * test $smarty->is_cached caching disabled + */ + public function testSmartyIsCachedCachingDisabled() + { + $this->smarty->setAllowPhpTemplates(true); + $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); + $this->assertFalse($this->smarty->isCached($tpl)); + } + + public function testGetTemplateFilepathName() + { + $this->smarty->addTemplateDir('./templates_2', 'foo'); + $tpl = $this->smarty->createTemplate('php:[foo]helloworld.php'); + $this->assertEquals('./templates_2/helloworld.php', $this->relative($tpl->source->filepath)); + } + + public function testGetCachedFilepathName() + { + $this->smarty->addTemplateDir('./templates_2', 'foo'); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('php:[foo]helloworld.php'); + $path = $tpl->cached->filepath; + $expected = $this->buildCachedPath($tpl, false, null, null, 'helloworld.php', 'php', + $this->smarty->getTemplateDir('foo'), 'file'); + $this->assertEquals($expected, $path); + } + + /** + * test {include} php resource + */ + public function testIncludePhpTemplate() + { + $this->smarty->setAllowPhpTemplates(true); + $this->assertContains('php hello world', $this->smarty->fetch('includephp.tpl')); + } + + /** + * test {include} php resource caching + */ + public function testIncludePhpTemplateCaching() + { + $this->smarty->caching = true; + $this->smarty->setAllowPhpTemplates(true); + $this->assertContains('php hello world', $this->smarty->fetch('includephp.tpl')); + } + + /** + * test clearCompiledTemplate() + */ + public function testClearCompiled() + { + $this->smarty->setAllowPhpTemplates(true); + $this->assertEquals(0, $this->smarty->clearCompiledTemplate('php:phphelloworld.php')); + } + +} diff --git a/tests/UnitTests/ResourceTests/Php/cache/.gitignore b/tests/UnitTests/ResourceTests/Php/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Php/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Php/templates/includephp.tpl b/tests/UnitTests/ResourceTests/Php/templates/includephp.tpl new file mode 100644 index 00000000..5baa76d2 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Php/templates/includephp.tpl @@ -0,0 +1 @@ +{include 'php:phphelloworld.php'} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/Php/templates/phphelloworld.php b/tests/UnitTests/ResourceTests/Php/templates/phphelloworld.php new file mode 100644 index 00000000..6fe5b4ba --- /dev/null +++ b/tests/UnitTests/ResourceTests/Php/templates/phphelloworld.php @@ -0,0 +1 @@ +php hello world diff --git a/tests/UnitTests/ResourceTests/Php/templates_2/helloworld.php b/tests/UnitTests/ResourceTests/Php/templates_2/helloworld.php new file mode 100644 index 00000000..6fe5b4ba --- /dev/null +++ b/tests/UnitTests/ResourceTests/Php/templates_2/helloworld.php @@ -0,0 +1 @@ +php hello world diff --git a/tests/UnitTests/ResourceTests/Php/templates_c/.gitignore b/tests/UnitTests/ResourceTests/Php/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Php/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Registered/RegisteredResourceTest.php b/tests/UnitTests/ResourceTests/Registered/RegisteredResourceTest.php new file mode 100644 index 00000000..d55a1852 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Registered/RegisteredResourceTest.php @@ -0,0 +1,162 @@ +resource + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for register->resource tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class RegisteredResourceTest extends PHPUnit_Smarty +{ + + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + + $this->smarty->registerResource("rr", array("rr_get_template", + "rr_get_timestamp", + "rr_get_secure", + "rr_get_trusted")); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test resource plugin rendering + */ + public function testResourcePlugin() + { + $this->assertEquals('hello world', $this->smarty->fetch('rr:test')); + } + + public function testClearCompiledResourcePlugin() + { + $this->assertEquals(1, $this->smarty->clearCompiledTemplate('rr:test')); + } + + /** + * test resource plugin timesatmp + */ + public function testResourcePluginTimestamp() + { + $tpl = $this->smarty->createTemplate('rr:test'); + $this->assertTrue(is_integer($tpl->source->getTimeStamp())); + $this->assertEquals(10, strlen($tpl->source->getTimeStamp())); + } + + /** + * test compile_id change + */ + public function testResourceCompileIdChange() + { + $this->smarty->registerResource('myresource', array('getSource', 'getTimestamp', 'getSecure', 'getTrusted')); + $this->smarty->compile_id = 'a'; + $this->assertEquals('this is template 1', $this->smarty->fetch('myresource:some')); + $this->assertEquals('this is template 1', $this->smarty->fetch('myresource:some')); + $this->smarty->compile_id = 'b'; + $this->assertEquals('this is template 2', $this->smarty->fetch('myresource:some')); + $this->assertEquals('this is template 2', $this->smarty->fetch('myresource:some')); + } + /** + * test {$smarty.template} + * + */ + public function testSmartyTemplate() { + $this->smarty->registerResource('mytpl', array('getTemplate', 'getTimestamp', 'getSecure', 'getTrusted')); + $this->assertEquals('template = mytpl:foo', $this->smarty->fetch('mytpl:foo')); + } + /** + * test {$smarty.current_dir} + * + */ + public function testSmartyCurrentDir() { + $this->smarty->registerResource('mytpl', array('getCurrentDir', 'getTimestamp', 'getSecure', 'getTrusted')); + $this->assertEquals('current_dir = .', $this->smarty->fetch('mytpl:bar')); + } +} + + +/** + * resource functions + */ +function rr_get_template($tpl_name, &$tpl_source, $smarty_obj) +{ + // populating $tpl_source + $tpl_source = '{$x="hello world"}{$x}'; + + return true; +} + +function rr_get_timestamp($tpl_name, &$tpl_timestamp, $smarty_obj) +{ + // $tpl_timestamp. + $tpl_timestamp = (int) floor(time() / 100) * 100; + + return true; +} + +function rr_get_secure($tpl_name, $smarty_obj) +{ + // assume all templates are secure + return true; +} + +function rr_get_trusted($tpl_name, $smarty_obj) +{ + // not used for templates +} + +// resource functions for compile_id change test + +function getSecure($name, $smarty) +{ + return true; +} + +function getTrusted($name, $smarty) +{ +} + +function getSource($name, &$source, $smarty) +{ + // we update a counter, so that we return a new source for every call + static $counter = 0; + $counter ++; + + // construct a new source + $source = "this is template $counter"; + + return true; +} +function getTemplate($name, &$source, $smarty) +{ + // construct a new source + $source = 'template = {$smarty.template}'; + + return true; +} +function getCurrentDir($name, &$source, $smarty) +{ + // construct a new source + $source = 'current_dir = {$smarty.current_dir}'; + + return true; +} + +function getTimestamp($name, &$timestamp, $smarty) +{ + // always pretend the template is brand new + $timestamp = (int) floor(time() / 100) * 100; + + return true; +} diff --git a/tests/UnitTests/ResourceTests/Registered/cache/.gitignore b/tests/UnitTests/ResourceTests/Registered/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Registered/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Registered/templates_c/.gitignore b/tests/UnitTests/ResourceTests/Registered/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Registered/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db.php b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db.php new file mode 100644 index 00000000..3b066db1 --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db.php @@ -0,0 +1,37 @@ +filepath = 'db2:'; + $source->uid = sha1($source->resource); + $source->timestamp = 0; + $source->exists = true; + } + + public function getContent(Smarty_Template_Source $source) + { + return '{$x="hello world"}{$x}'; + } +} diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db3.php b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db3.php new file mode 100644 index 00000000..0b07233b --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db3.php @@ -0,0 +1,32 @@ +filepath = 'db3:'; + $source->uid = sha1($source->resource); + $source->timestamp = 0; + $source->exists = true; + } + + public function getContent(Smarty_Template_Source $source) + { + return '{$x="hello world"}{$x}'; + } + + public function getCompiledFilepath(Smarty_Internal_Template $_template) + { + return false; + } +} diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db4.php b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db4.php new file mode 100644 index 00000000..611d3e43 --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db4.php @@ -0,0 +1,31 @@ +filepath = 'db4:'; + $source->uid = sha1($source->resource); + $source->timestamp = 0; + $source->exists = true; + } + + public function getContent(Smarty_Template_Source $source) + { + if ($source->is_config) { + return "foo = 'bar'\n"; + } + + return '{$x="hello world"}{$x}'; + } +} diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/ResourcePluginTest.php b/tests/UnitTests/ResourceTests/ResourcePlugins/ResourcePluginTest.php new file mode 100644 index 00000000..ba8d9162 --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/ResourcePluginTest.php @@ -0,0 +1,80 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test resource plugin rendering + */ + public function testResourcePlugin() + { + $this->smarty->addPluginsDir("./PHPunitplugins/"); + $this->assertEquals('hello world', $this->smarty->fetch('db:test')); + } + + /** + * test resource plugin rendering + */ + public function testResourcePluginObject() + { + $this->smarty->addPluginsDir("./PHPunitplugins/"); + $this->assertEquals('hello world', $this->smarty->fetch('db2:test')); + } + + /** + * test resource plugin rendering of a registered object + */ + public function testResourcePluginRegisteredInstance() + { + $this->smarty->addPluginsDir("./PHPunitplugins/"); + $this->smarty->loadPlugin('Smarty_Resource_Db2'); + $this->smarty->registerResource('db2a', new Smarty_Resource_Db2('db2a')); + $this->assertEquals('hello world', $this->smarty->fetch('db2a:test')); + } + + /** + * test resource plugin non-existent compiled cache of a recompiling resource + */ + public function testResourcePluginRecompiledCompiledFilepath() + { + $this->smarty->addPluginsDir("./PHPunitplugins/"); + $tpl = $this->smarty->createTemplate('db2:test.tpl'); + $expected = realpath('./templates_c/' . sha1('db2:test.tpl') . '.db2.test.tpl.php'); + $this->assertFalse(!!$expected); + $this->assertFalse($tpl->compiled->filepath); + } + + /** + * test resource plugin timestamp + */ + public function testResourcePluginTimestamp() + { + $this->smarty->addPluginsDir("./PHPunitplugins/"); + $tpl = $this->smarty->createTemplate('db:test'); + $this->assertTrue(is_integer($tpl->source->getTimeStamp())); + $this->assertEquals(10, strlen($tpl->source->getTimeStamp())); + } +} + diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/cache/.gitignore b/tests/UnitTests/ResourceTests/ResourcePlugins/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/templates/extendsall.tpl b/tests/UnitTests/ResourceTests/ResourcePlugins/templates/extendsall.tpl new file mode 100644 index 00000000..988c37e0 --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/templates/extendsall.tpl @@ -0,0 +1,2 @@ +{block name="alpha"}templates{/block} +{block name="bravo_2"}templates{/block} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/templates/extendsall2.tpl b/tests/UnitTests/ResourceTests/ResourcePlugins/templates/extendsall2.tpl new file mode 100644 index 00000000..988c37e0 --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/templates/extendsall2.tpl @@ -0,0 +1,2 @@ +{block name="alpha"}templates{/block} +{block name="bravo_2"}templates{/block} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/ambiguous/case1/foobar.tpl b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/ambiguous/case1/foobar.tpl new file mode 100644 index 00000000..b6e9ce55 --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/ambiguous/case1/foobar.tpl @@ -0,0 +1 @@ +templates_2 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/dirname.tpl b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/dirname.tpl new file mode 100644 index 00000000..b6e9ce55 --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/dirname.tpl @@ -0,0 +1 @@ +templates_2 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/hello.tpl b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/hello.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/hello.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/helloworld.php b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/helloworld.php new file mode 100644 index 00000000..77eb622a --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_2/helloworld.php @@ -0,0 +1 @@ +php hello world \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/templates_3/dirname.tpl b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_3/dirname.tpl new file mode 100644 index 00000000..404b4397 --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_3/dirname.tpl @@ -0,0 +1 @@ +templates_3 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/templates_3/extendsall.tpl b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_3/extendsall.tpl new file mode 100644 index 00000000..0b79019d --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_3/extendsall.tpl @@ -0,0 +1,5 @@ +{block name="alpha"}templates_3{/block} +{block name="bravo"} + {block name="bravo_1"}templates_3{/block} + {block name="bravo_2"}templates_3{/block} +{/block} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/templates_4/dirname.tpl b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_4/dirname.tpl new file mode 100644 index 00000000..b744ef31 --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_4/dirname.tpl @@ -0,0 +1 @@ +templates_4 \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/templates_4/extendsall.tpl b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_4/extendsall.tpl new file mode 100644 index 00000000..93557dca --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_4/extendsall.tpl @@ -0,0 +1,3 @@ +{block name="alpha"}templates_4{/block} +{block name="bravo"}templates_4{/block} +{block name="charlie"}templates_4{/block} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/templates_c/.gitignore b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php b/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php new file mode 100644 index 00000000..73584f09 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php @@ -0,0 +1,279 @@ +setUpSmarty(dirname(__FILE__)); + + $this->smarty->assign('foo', 'bar'); + stream_wrapper_register("global", "ResourceStream") + or die("Failed to register protocol"); + $fp = fopen("global://mytest", "r+"); + fwrite($fp, 'hello world {$foo}'); + fclose($fp); + } + + + public function testInit() + { + $this->cleanDirs(); + } + public function tearDown() + { + parent::tearDown(); + stream_wrapper_unregister("global"); + } + + /** + * test getTemplateFilepath + */ + public function testGetTemplateFilepath() + { + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertEquals('global://mytest', $tpl->source->filepath); + } + + /** + * test getTemplateTimestamp + */ + public function testGetTemplateTimestamp() + { + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertTrue($tpl->source->getTimeStamp()); + } + + /** + * test getTemplateSource + */ + public function testGetTemplateSource() + { + $tpl = $this->smarty->createTemplate('global:mytest', null, null, $this->smarty); + $this->assertEquals('hello world {$foo}', $tpl->source->getContent()); + } + + /** + * test usesCompiler + */ + public function testUsesCompiler() + { + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertFalse($tpl->source->handler->uncompiled); + } + + /** + * test isEvaluated + */ + public function testIsEvaluated() + { + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertTrue($tpl->source->handler->recompiled); + } + + /** + * test mustCompile + */ + public function testMustCompile() + { + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertTrue($tpl->mustCompile()); + } + + /** + * test getCompiledFilepath + */ + public function testGetCompiledFilepath() + { + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertFalse($tpl->compiled->filepath); + } + + /** + * test getCompiledTimestamp + */ + public function testGetCompiledTimestamp() + { + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertFalse($tpl->compiled->getTimeStamp()); + } + + /** + * test template file exits + */ + public function testTemplateStreamExists1() + { + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertTrue($tpl->source->exists); + } + + public function testTemplateStreamExists2() + { + $this->assertTrue($this->smarty->templateExists('global:mytest')); + } + + /** + * test template is not existing + */ + public function testTemplateStreamNotExists1() + { + $tpl = $this->smarty->createTemplate('global:notthere'); + $this->assertFalse($tpl->source->exists); + } + + public function testTemplateStramNotExists2() + { + $this->assertFalse($this->smarty->templateExists('global:notthere')); + } + /** + * @expectedException SmartyException + * @expectedExceptionMessage 'global:notthere' + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test not existing template + */ + + public function testTemplateStramNotExists3() + { + $result = $this->smarty->fetch('global:notthere'); + } + + /** + * test writeCachedContent + */ + public function testWriteCachedContent() + { + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertFalse($tpl->writeCachedContent('dummy')); + } + + /** + * test isCached + */ + public function testIsCached() + { + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertFalse($tpl->isCached()); + } + + /** + * test getRenderedTemplate + */ + public function testGetRenderedTemplate() + { + $tpl = $this->smarty->createTemplate('global:mytest', null, null, $this->smarty); + $this->assertEquals('hello world bar', $tpl->fetch()); + } + + /** + * test that no complied template and cache file was produced + */ + public function testNoFiles() + { + $this->cleanDir($this->smarty->getCacheDir()); + $this->cleanDir($this->smarty->getCompileDir()); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 20; + $tpl = $this->smarty->createTemplate('global:mytest', null, null, $this->smarty); + $this->assertEquals('hello world bar', $this->smarty->fetch($tpl)); + $this->assertEquals(0, $this->smarty->clearAllCache()); + $this->assertEquals(0, $this->smarty->clearCompiledTemplate()); + } + + /** + * test $smarty->is_cached + */ + public function testSmartyIsCached() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 20; + $tpl = $this->smarty->createTemplate('global:mytest', null, null, $this->smarty); + $this->assertEquals('hello world bar', $this->smarty->fetch($tpl)); + $this->assertFalse($this->smarty->isCached($tpl)); + } +} + +class ResourceStream +{ + private $position; + private $varname; + + public function stream_open($path, $mode, $options, &$opened_path) + { + $url = parse_url($path); + $this->varname = $url["host"]; + $this->position = 0; + + return true; + } + + public function stream_read($count) + { + $p = &$this->position; + $ret = substr($GLOBALS[$this->varname], $p, $count); + $p += strlen($ret); + + return $ret; + } + + public function stream_write($data) + { + $v = &$GLOBALS[$this->varname]; + $l = strlen($data); + $p = &$this->position; + $v = substr($v, 0, $p) . $data . substr($v, $p += $l); + + return $l; + } + + public function stream_tell() + { + return $this->position; + } + + public function stream_eof() + { + if (!isset($GLOBALS[$this->varname])) { + return true; + } + + return $this->position >= strlen($GLOBALS[$this->varname]); + } + + public function stream_seek($offset, $whence) + { + $l = strlen($GLOBALS[$this->varname]); + $p = &$this->position; + switch ($whence) { + case SEEK_SET: + $newPos = $offset; + break; + case SEEK_CUR: + $newPos = $p + $offset; + break; + case SEEK_END: + $newPos = $l + $offset; + break; + default: + return false; + } + $ret = ($newPos >= 0 && $newPos <= $l); + if ($ret) { + $p = $newPos; + } + return $ret; + } +} diff --git a/tests/UnitTests/ResourceTests/Stream/cache/.gitignore b/tests/UnitTests/ResourceTests/Stream/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Stream/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/Stream/templates_c/.gitignore b/tests/UnitTests/ResourceTests/Stream/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/Stream/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/String/StringResourceTest.php b/tests/UnitTests/ResourceTests/String/StringResourceTest.php new file mode 100644 index 00000000..7c938842 --- /dev/null +++ b/tests/UnitTests/ResourceTests/String/StringResourceTest.php @@ -0,0 +1,198 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + protected function relative($path) + { + $path = str_replace(dirname(__FILE__), '.', $path); + if (DIRECTORY_SEPARATOR == "\\") { + $path = str_replace("\\", "/", $path); + } + + return $path; + } + + /** + * test template string exits + */ + public function testTemplateStringExists1() + { + $tpl = $this->smarty->createTemplate('string:{$foo}'); + $this->assertTrue($tpl->source->exists); + } + + public function testTemplateStringExists2() + { + $this->assertTrue($this->smarty->templateExists('string:{$foo}')); + } + + /** + * test getTemplateFilepath + */ + public function testGetTemplateFilepath() + { + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertEquals($this->buildSourcePath($tpl), $tpl->source->filepath); + } + + /** + * test getTemplateTimestamp + */ + public function testGetTemplateTimestamp() + { + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertTrue($tpl->source->getTimeStamp()); + } + + /** + * test getTemplateSource + */ + public function testGetTemplateSource() + { + $tpl = $this->smarty->createTemplate('string:hello world{$foo}'); + $this->assertEquals('hello world{$foo}', $tpl->source->getContent()); + } + + /** + * test usesCompiler + */ + public function testUsesCompiler() + { + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertFalse($tpl->source->handler->uncompiled); + } + + /** + * test isEvaluated + */ + public function testIsEvaluated() + { + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertFalse($tpl->source->handler->recompiled); + } + + /** + * test mustCompile + */ + public function testMustCompile() + { + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertTrue($tpl->mustCompile()); + } + + /** + * test getCompiledFilepath + */ + public function testGetCompiledFilepath() + { + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertEquals($this->buildCompiledPath($tpl, false, false, null, 'hello world', 'string', $this->smarty->getTemplateDir(0)), $tpl->compiled->filepath); + } + + /** + * test getCompiledTimestamp + */ + public function testGetCompiledTimestamp() + { + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertFalse($tpl->compiled->getTimeStamp()); + } + + /** + * test empty templates + */ + public function testEmptyTemplate() + { + $tpl = $this->smarty->createTemplate('string:'); + $this->assertEquals('', $this->smarty->fetch($tpl)); + } + + /** + * test getCachedTimestamp + */ + public function testGetCachedTimestamp() + { + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertFalse($tpl->cached->timestamp); + } + + /** + * test writeCachedContent + */ + public function testWriteCachedContent() + { + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertFalse($tpl->writeCachedContent('dummy')); + } + + /** + * test isCached + */ + public function testIsCached() + { + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertFalse($tpl->isCached()); + } + + /** + * test getRenderedTemplate + */ + public function testGetRenderedTemplate() + { + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertEquals('hello world', $tpl->fetch()); + } + + /** + * test $smarty->is_cached + */ + public function testSmartyIsCached() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 20; + $tpl = $this->smarty->createTemplate('string:hello world'); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + $this->assertTrue($this->smarty->isCached($tpl)); + } + + public function testUrlencodeTemplate() + { + $tpl = $this->smarty->createTemplate('string:urlencode:%7B%22foobar%22%7Cescape%7D'); + $this->assertEquals('foobar', $tpl->fetch()); + } + + public function testBase64Template() + { + $tpl = $this->smarty->createTemplate('string:base64:eyJmb29iYXIifGVzY2FwZX0='); + $this->assertEquals('foobar', $tpl->fetch()); + } + public function testClearCompiled() + { + $this->smarty->fetch('string:string:hello uwe'); + $this->assertEquals(1, $this->smarty->clearCompiledTemplate('string:')); + } +} diff --git a/tests/UnitTests/ResourceTests/String/cache/.gitignore b/tests/UnitTests/ResourceTests/String/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/String/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/ResourceTests/String/templates_c/.gitignore b/tests/UnitTests/ResourceTests/String/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/ResourceTests/String/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SecurityTests/FunctionTest.php b/tests/UnitTests/SecurityTests/FunctionTest.php new file mode 100644 index 00000000..0706f23b --- /dev/null +++ b/tests/UnitTests/SecurityTests/FunctionTest.php @@ -0,0 +1,44 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test unknown function error + */ + public function testUnknownFunction() + { + $this->smarty->enableSecurity(); + try { + $this->smarty->fetch('eval:{unknown()}'); + } + catch (Exception $e) { + $this->assertContains("PHP function 'unknown' not allowed by security setting", $e->getMessage()); + + return; + } + $this->fail('Exception for unknown function has not been raised.'); + } +} diff --git a/tests/UnitTests/SecurityTests/SecurityTest.php b/tests/UnitTests/SecurityTests/SecurityTest.php new file mode 100644 index 00000000..2a4d3e59 --- /dev/null +++ b/tests/UnitTests/SecurityTests/SecurityTest.php @@ -0,0 +1,471 @@ +setUpSmarty(dirname(__FILE__)); + + $this->smarty->setForceCompile(true); + $this->smarty->enableSecurity(); + $this->smartyBC->setForceCompile(true); + $this->smartyBC->enableSecurity(); + } + public function testInit() + { + $this->cleanDirs(); + } + +/** + * test that security is loaded +' *'/ + public function testSecurityReenable() + { + $this->smarty->disableSecurity(); + $this->smarty->enableSecurity('Security'); + $this->smarty->fetch('helloworld.tpl'); + $this->smarty->disableSecurity(); + $this->smarty->enableSecurity('Security'); + $this->smarty->fetch('helloworld.tpl'); + } +/** +* test that security is loaded + */ + public function testSecurityLoaded() + { + $this->assertTrue(is_object($this->smarty->security_policy)); + } + +/** + * test trusted PHP function + */ + public function testTrustedPHPFunction() + { + $this->assertEquals("5", $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{count($foo)}')); + } + +/** + * test not trusted PHP function + * @expectedException SmartyException + * @expectedExceptionMessage PHP function 'count' not allowed by security setting + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testNotTrustedPHPFunction() + { + $this->smarty->security_policy->php_functions = array('null'); + $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{count($foo)}'); + } + +/** + * test not trusted PHP function at disabled security + */ + public function testDisabledTrustedPHPFunction() + { + $this->smarty->security_policy->php_functions = array('null'); + $this->smarty->disableSecurity(); + $this->assertEquals("5", $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{count($foo)}')); + } + +/** + * test trusted modifier + */ + public function testTrustedModifier() + { + $this->assertEquals("5", $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@count}')); + } + +/** + * test not trusted modifier + * @expectedException SmartyException + * @expectedExceptionMessage modifier 'count' not allowed by security setting + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testNotTrustedModifier() + { + $this->smarty->security_policy->php_modifiers = array('null'); + $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@count}'); + } + +/** + * test not trusted modifier at disabled security + */ + public function testDisabledTrustedModifier() + { + $this->smarty->security_policy->php_modifiers = array('null'); + $this->smarty->disableSecurity(); + $this->assertEquals("5", $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@count}')); + } + +/** + * test allowed tags + */ + public function testAllowedTags1() + { + $this->smarty->security_policy->allowed_tags = array('counter'); + $this->assertEquals("1", $this->smarty->fetch('string:{counter start=1}')); + } + +/** + * test not allowed tag + * @expectedException SmartyException + * @expectedExceptionMessage tag 'cycle' not allowed by security setting + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testNotAllowedTags2() + { + $this->smarty->security_policy->allowed_tags = array('counter'); + $this->smarty->fetch('string:{counter}{cycle values="1,2"}'); + } + +/** + * test disabled tag + * @expectedException SmartyException + * @expectedExceptionMessage tag 'cycle' disabled by security setting + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testDisabledTags() + { + $this->smarty->security_policy->disabled_tags = array('cycle'); + $this->smarty->fetch('string:{counter}{cycle values="1,2"}'); + } + +/** + * test allowed modifier + */ + public function testAllowedModifier1() + { + error_reporting(E_ALL & E_STRICT); + $this->smarty->security_policy->allowed_modifiers = array('capitalize'); + $this->assertEquals("Hello World", $this->smarty->fetch('string:{"hello world"|capitalize}')); + error_reporting(E_ALL | E_STRICT); + } + + public function testAllowedModifier2() + { + $this->smarty->security_policy->allowed_modifiers = array('upper'); + $this->assertEquals("HELLO WORLD", $this->smarty->fetch('string:{"hello world"|upper}')); + } + +/** + * test not allowed modifier + * @expectedException SmartyException + * @expectedExceptionMessage modifier 'lower' not allowed by security setting + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testNotAllowedModifier() + { + $this->smarty->security_policy->allowed_modifiers = array('upper'); + $this->smarty->fetch('string:{"hello"|upper}{"world"|lower}'); + } + +/** + * test disabled modifier + * @expectedException SmartyException + * @expectedExceptionMessage modifier 'lower' disabled by security setting + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testDisabledModifier() + { + $this->smarty->security_policy->disabled_modifiers = array('lower'); + $this->smarty->fetch('string:{"hello"|upper}{"world"|lower}'); + } + +/** + * test Smarty::PHP_QUOTE + */ + public function testSmartyPhpQuote() + { + $this->smarty->security_policy->php_handling = Smarty::PHP_QUOTE; + $this->assertEquals('<?php echo "hello world"; ?>', $this->smarty->fetch('string:')); + } + + public function testSmartyPhpQuoteAsp() + { + // NOTE: asp_tags cannot be changed by ini_set() + if (!ini_get('asp_tags')) { + $this->markTestSkipped('asp tags disabled in php.ini'); + } + $this->smarty->security_policy->php_handling = Smarty::PHP_QUOTE; + $this->assertEquals('<% echo "hello world"; %>', $this->smarty->fetch('string:<% echo "hello world"; %>')); + } + +/** + * test Smarty::PHP_REMOVE + */ + public function testSmartyPhpRemove() + { + $this->smarty->security_policy->php_handling = Smarty::PHP_REMOVE; + $this->assertEquals('', $this->smarty->fetch('string:')); + } + + public function testSmartyPhpRemoveAsp() + { + // NOTE: asp_tags cannot be changed by ini_set() + if (!ini_get('asp_tags')) { + $this->markTestSkipped('asp tags disabled in php.ini'); + } + $this->smarty->security_policy->php_handling = Smarty::PHP_REMOVE; + $this->assertEquals('', $this->smarty->fetch('string:<% echo "hello world"; %>')); + } + +/** + * test Smarty::PHP_ALLOW + */ + public function testSmartyPhpAllow() + { + $this->smartyBC->security_policy->php_handling = Smarty::PHP_ALLOW; + $this->assertEquals('hello world', $this->smartyBC->fetch('string:')); + } + + public function testSmartyPhpAllowAsp() + { + // NOTE: asp_tags cannot be changed by ini_set() + if (!ini_get('asp_tags')) { + $this->markTestSkipped('asp tags disabled in php.ini'); + } + $this->smartyBC->security_policy->php_handling = Smarty::PHP_ALLOW; + $this->assertEquals('hello world', $this->smartyBC->fetch('string:<% echo "hello world"; %>')); + } + +/** + * test standard directory + */ + public function testStandardDirectory() + { + $content = $this->smarty->fetch('string:{include file="helloworld.tpl"}'); + $this->assertEquals("hello world", $content); + } + +/** + * test trusted directory + */ + public function testTrustedDirectory() + { + $this->smarty->security_policy->secure_dir = array('.' . DIRECTORY_SEPARATOR . 'templates_2' . DIRECTORY_SEPARATOR); + $this->assertEquals("hello world", $this->smarty->fetch('string:{include file="templates_2/hello.tpl"}')); + } + +/** + * test not trusted directory + * + * @expectedException SmartyException + * @expectedExceptionMessage not trusted file path + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testNotTrustedDirectory() + { + $this->smarty->security_policy->secure_dir = array(str_replace('\\', '/', dirname(__FILE__) . '/templates_3/')); + $this->smarty->fetch('string:{include file="templates_2/hello.tpl"}'); + } + +/** + * test disabled security for not trusted dir + */ + public function testDisabledTrustedDirectory() + { + $this->smarty->disableSecurity(); + $this->assertEquals("hello world", $this->smarty->fetch('string:{include file="templates_2/hello.tpl"}')); + } + +/** + * test trusted static class + */ + public function testTrustedStaticClass() + { + $this->smarty->security_policy->static_classes = array('mysecuritystaticclass'); + $tpl = $this->smarty->createTemplate('string:{mysecuritystaticclass::square(5)}'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } + +/** + * test not trusted PHP function + * @expectedException SmartyException + * @expectedExceptionMessage access to static class 'mysecuritystaticclass' not allowed by security setting + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testNotTrustedStaticClass() + { + $this->smarty->security_policy->static_classes = array('null'); + $this->smarty->fetch('string:{mysecuritystaticclass::square(5)}'); + } + + public function testChangedTrustedDirectory() + { + $this->smarty->security_policy->secure_dir = array( + '.' . DIRECTORY_SEPARATOR . 'templates_2' . DIRECTORY_SEPARATOR, + ); + $this->assertEquals("hello world", $this->smarty->fetch('string:{include file="templates_2/hello.tpl"}')); + + $this->smarty->security_policy->secure_dir = array( + '.' . DIRECTORY_SEPARATOR . 'templates_2' . DIRECTORY_SEPARATOR, + '.' . DIRECTORY_SEPARATOR . 'templates_3' . DIRECTORY_SEPARATOR, + ); + $this->assertEquals("templates_3", $this->smarty->fetch('string:{include file="templates_3/dirname.tpl"}')); + } +/** + * test template file exits + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testTemplateTrustedStream() + { + stream_wrapper_register("global", "ResourceStreamSecurity") + or die("Failed to register protocol"); + $fp = fopen("global://mytest", "r+"); + fwrite($fp, 'hello world {$foo}'); + fclose($fp); + $this->smarty->security_policy->streams= array('global'); + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertTrue($tpl->source->exists); + } +/** + * @expectedException SmartyException + * @expectedExceptionMessage stream 'global' not allowed by security setting + * @runInSeparateProcess + * @preserveGlobalState disabled + * test template file exits + */ + public function testTemplateNotTrustedStream() + { + stream_wrapper_register("global", "ResourceStreamSecurity") + or die("Failed to register protocol"); + $fp = fopen("global://mytest", "r+"); + fwrite($fp, 'hello world {$foo}'); + fclose($fp); + $this->smarty->security_policy->streams= array('notrusted'); + $tpl = $this->smarty->createTemplate('global:mytest'); + $this->assertTrue($tpl->source->exists); + } +/** + * @runInSeparateProcess + * @preserveGlobalState disabled +*/ + public function testTrustedUri() + { + $this->smarty->security_policy->trusted_uri = array( + '#https://www.smarty.net$#i' + ); + $this->assertContains('Preface | Smarty', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}')); + } + +/** + * @expectedException SmartyException + * @expectedExceptionMessage URI 'https://www.smarty.net/docs/en/preface.tpl' not allowed by security setting + * @runInSeparateProcess + * @preserveGlobalState disabled +*/ + public function testNotTrustedUri() + { + $this->smarty->security_policy->trusted_uri = array(); + $this->assertContains('Preface | Smarty', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}')); + } +} + +class mysecuritystaticclass +{ + const STATIC_CONSTANT_VALUE = 3; + static $static_var = 5; + + static function square($i) + { + return $i * $i; + } +} +class Security extends Smarty_Security +{ + +} +class ResourceStreamSecurity +{ + private $position; + private $varname; + + public function stream_open($path, $mode, $options, &$opened_path) + { + $url = parse_url($path); + $this->varname = $url["host"]; + $this->position = 0; + + return true; + } + + public function stream_read($count) + { + $p = &$this->position; + $ret = substr($GLOBALS[$this->varname], $p, $count); + $p += strlen($ret); + + return $ret; + } + + public function stream_write($data) + { + $v = &$GLOBALS[$this->varname]; + $l = strlen($data); + $p = &$this->position; + $v = substr($v, 0, $p) . $data . substr($v, $p += $l); + + return $l; + } + + public function stream_tell() + { + return $this->position; + } + + public function stream_eof() + { + if (!isset($GLOBALS[$this->varname])) { + return true; + } + + return $this->position >= strlen($GLOBALS[$this->varname]); + } + + public function stream_seek($offset, $whence) + { + $l = strlen($GLOBALS[$this->varname]); + $p = &$this->position; + switch ($whence) { + case SEEK_SET: + $newPos = $offset; + break; + case SEEK_CUR: + $newPos = $p + $offset; + break; + case SEEK_END: + $newPos = $l + $offset; + break; + default: + return false; + } + $ret = ($newPos >= 0 && $newPos <= $l); + if ($ret) { + $p = $newPos; + } + return $ret; + } +} diff --git a/tests/UnitTests/SecurityTests/cache/.gitignore b/tests/UnitTests/SecurityTests/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SecurityTests/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SecurityTests/templates/helloworld.tpl b/tests/UnitTests/SecurityTests/templates/helloworld.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/SecurityTests/templates/helloworld.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/SecurityTests/templates_2/hello.tpl b/tests/UnitTests/SecurityTests/templates_2/hello.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/SecurityTests/templates_2/hello.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/SecurityTests/templates_3/dirname.tpl b/tests/UnitTests/SecurityTests/templates_3/dirname.tpl new file mode 100644 index 00000000..404b4397 --- /dev/null +++ b/tests/UnitTests/SecurityTests/templates_3/dirname.tpl @@ -0,0 +1 @@ +templates_3 \ No newline at end of file diff --git a/tests/UnitTests/SecurityTests/templates_c/.gitignore b/tests/UnitTests/SecurityTests/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SecurityTests/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/Append/AppendTest.php b/tests/UnitTests/SmartyMethodsTests/Append/AppendTest.php new file mode 100644 index 00000000..4955b7d7 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/Append/AppendTest.php @@ -0,0 +1,86 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test append + */ + public function testAppend() + { + $this->smarty->assign('foo', 'bar'); + $this->smarty->append('foo', 'bar2'); + $this->assertEquals('bar bar2', $this->smarty->fetch('eval:{$foo[0]} {$foo[1]}')); + } + + /** + * test append to unassigned variable + */ + public function testAppendUnassigned() + { + $this->smarty->append('foo', 'bar'); + $this->assertEquals('bar', $this->smarty->fetch('eval:{$foo[0]}')); + } + + /** + * test append merge + */ + public function testAppendMerge() + { + $this->smarty->assign('foo', array('a' => 'a', 'b' => 'b', 'c' => 'c')); + $this->smarty->append('foo', array('b' => 'd'), true); + $this->assertEquals('a d c', $this->smarty->fetch('eval:{$foo["a"]} {$foo["b"]} {$foo["c"]}')); + } + + /** + * test append array merge + */ + public function testAppendArrayMerge() + { + $this->smarty->assign('foo', array('b' => 'd')); + $this->smarty->append('foo', array('a' => 'a', 'b' => 'b', 'c' => 'c'), true); + $this->assertEquals('a b c', $this->smarty->fetch('eval:{$foo["a"]} {$foo["b"]} {$foo["c"]}')); + } + + /** + * test array append + */ + public function testArrayAppend() + { + $this->smarty->assign('foo', 'foo'); + $this->smarty->append(array('bar' => 'bar2', 'foo' => 'foo2')); + $this->assertEquals('foo foo2 bar2', $this->smarty->fetch('eval:{$foo[0]} {$foo[1]} {$bar[0]}')); + } + + /** + * test array append array merge + */ + public function testArrayAppendArrayMerge() + { + $this->smarty->assign('foo', array('b' => 'd')); + $this->smarty->append(array('bar' => 'bar', 'foo' => array('a' => 'a', 'b' => 'b', 'c' => 'c')), null, true); + $this->assertEquals('a b c bar', $this->smarty->fetch('eval:{$foo["a"]} {$foo["b"]} {$foo["c"]} {$bar[0]}')); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/Append/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/Append/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/Append/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/Append/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/Append/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/Append/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefBCTest.php b/tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefBCTest.php new file mode 100644 index 00000000..0c8a759e --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefBCTest.php @@ -0,0 +1,48 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testSmarty2AppendByRef() + { + $bar = 'bar'; + $bar2 = 'bar2'; + $this->smartyBC->append_by_ref('foo', $bar); + $this->smartyBC->append_by_ref('foo', $bar2); + $bar = 'newbar'; + $bar2 = 'newbar2'; + $this->assertEquals('newbar newbar2', $this->smartyBC->fetch('eval:{$foo[0]} {$foo[1]}')); + } + + public function testSmarty2AppendByRefUnassigned() + { + $bar2 = 'bar2'; + $this->smartyBC->append_by_ref('foo', $bar2); + $bar2 = 'newbar2'; + $this->assertEquals('newbar2', $this->smartyBC->fetch('eval:{$foo[0]}')); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefTest.php b/tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefTest.php new file mode 100644 index 00000000..7a52d700 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefTest.php @@ -0,0 +1,64 @@ +setUpSmarty(dirname(__FILE__)); + } + + /** + * test appendByRef + */ + public function testAppendByRef() + { + $bar = 'bar'; + $bar2 = 'bar2'; + $this->smarty->appendByRef('foo', $bar); + $this->smarty->appendByRef('foo', $bar2); + $bar = 'newbar'; + $bar2 = 'newbar2'; + $this->assertEquals('newbar newbar2', $this->smarty->fetch('eval:{$foo[0]} {$foo[1]}')); + } + + /** + * test appendByRef to unassigned variable + */ + public function testAppendByRefUnassigned() + { + $bar2 = 'bar2'; + $this->smarty->appendByRef('foo', $bar2); + $bar2 = 'newbar2'; + $this->assertEquals('newbar2', $this->smarty->fetch('eval:{$foo[0]}')); + } + + /** + * test appendByRef merge + * + * @todo fix testAppendByRefMerge + */ + public function testAppendByRefMerge() + { + $foo = array('a' => 'a', 'b' => 'b', 'c' => 'c'); + $bar = array('b' => 'd'); + $this->smarty->assignByRef('foo', $foo); + $this->smarty->appendByRef('foo', $bar, true); + $this->assertEquals('a d c', $this->smarty->fetch('eval:{$foo["a"]} {$foo["b"]} {$foo["c"]}')); + $bar = array('b' => 'newd'); + $this->smarty->appendByRef('foo', $bar, true); + $this->assertEquals('a newd c', $this->smarty->fetch('eval:{$foo["a"]} {$foo["b"]} {$foo["c"]}')); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/AppendByRef/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/AppendByRef/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/AppendByRef/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/AppendByRef/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/AppendByRef/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/AppendByRef/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/Assign/AssignTest.php b/tests/UnitTests/SmartyMethodsTests/Assign/AssignTest.php new file mode 100644 index 00000000..cc45a5c9 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/Assign/AssignTest.php @@ -0,0 +1,45 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test simple assign + */ + public function testSimpleAssign() + { + $this->smarty->assign('foo', 'bar'); + $this->assertEquals('bar', $this->smarty->fetch('eval:{$foo}')); + } + + /** + * test assign array of variables + */ + public function testArrayAssign() + { + $this->smarty->assign(array('foo' => 'bar', 'foo2' => 'bar2')); + $this->assertEquals('bar bar2', $this->smarty->fetch('eval:{$foo} {$foo2}')); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/Assign/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/Assign/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/Assign/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/Assign/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/Assign/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/Assign/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefBCTest.php b/tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefBCTest.php new file mode 100644 index 00000000..902d27ac --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefBCTest.php @@ -0,0 +1,51 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test Smarty2 assign_By_Ref + */ + public function testSmarty2AssignByRef() + { + $bar = 'bar'; + $this->smartyBC->assign_by_ref('foo', $bar); + $bar = 'newbar'; + $this->assertEquals('newbar', $this->smartyBC->fetch('eval:{$foo}')); + } + + /** + * test Smarty2's behaviour of assign_By_Ref (Issue 88) + */ + public function testSmarty2AssignByRef2() + { + $bar = 'bar'; + $this->smartyBC->assign_by_ref('foo', $bar); + $this->smartyBC->fetch('eval:{$foo = "newbar"}'); + $this->assertEquals('newbar', $bar); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefTest.php b/tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefTest.php new file mode 100644 index 00000000..6c393d86 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefTest.php @@ -0,0 +1,33 @@ +setUpSmarty(dirname(__FILE__)); + } + + /** + * test simple assignByRef + */ + public function testSimpleAssignByRef() + { + $bar = 'bar'; + $this->smarty->assignByRef('foo', $bar); + $bar = 'newbar'; + $this->assertEquals('newbar', $this->smarty->fetch('eval:{$foo}')); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/AssignByRef/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/AssignByRef/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/AssignByRef/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/AssignByRef/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/AssignByRef/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/AssignByRef/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/AssignGlobal/AssignGlobalTest.php b/tests/UnitTests/SmartyMethodsTests/AssignGlobal/AssignGlobalTest.php new file mode 100644 index 00000000..ecd4130b --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/AssignGlobal/AssignGlobalTest.php @@ -0,0 +1,70 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test assignGlobal and getGlobal + */ + public function testAssignGlobalGetGlobal() + { + $this->smarty->assignGlobal('foo', 'bar'); + $this->assertEquals('bar', $this->smarty->getGlobal('foo')); + } + + /** + * test assignGlobal and getGlobal on arrays + */ + public function testAssignGlobalGetGlobalArray() + { + $this->smarty->assignGlobal('foo', array('foo' => 'bar', 'foo2' => 'bar2')); + $a1 = array('foo' => array('foo' => 'bar', 'foo2' => 'bar2')); + $a2 = $this->smarty->getGlobal(); + unset($a2['SCRIPT_NAME']); + $this->assertTrue($a1 === $a2); + } + + /** + * test assignGlobal tag + */ + public function testAssignGlobalTag() + { + $this->smarty->assignGlobal('foo', 'bar'); + $this->assertEquals('bar', $this->smarty->fetch('eval:{$foo}')); + $this->assertEquals('buh', $this->smarty->fetch('eval:{assign var=foo value=buh scope=global}{$foo}')); + $this->assertEquals('buh', $this->smarty->fetch('eval:{$foo}')); + $this->assertEquals('buh', $this->smarty->getGlobal('foo')); + } + + /** + * test global var array element tag + */ + public function testGlobalVarArrayTag() + { + $this->smarty->assignGlobal('foo', array('foo' => 'bar', 'foo2' => 'bar2')); + $this->assertEquals('bar2', $this->smarty->fetch('eval:{$foo.foo2}')); + $this->assertEquals('bar', $this->smarty->fetch('eval:{$foo.foo}')); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/AssignGlobal/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/AssignGlobal/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/AssignGlobal/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/AssignGlobal/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/AssignGlobal/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/AssignGlobal/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignBCTest.php b/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignBCTest.php new file mode 100644 index 00000000..eff71dee --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignBCTest.php @@ -0,0 +1,40 @@ +setUpSmarty(dirname(__FILE__)); + + $this->smartyBC->assign('foo', 'foo'); + $this->_dataBC = $this->smartyBC->createData($this->smartyBC); + $this->_dataBC->assign('bar', 'bar'); + $this->_tplBC = $this->smartyBC->createTemplate('eval:{$foo}{$bar}{$blar}', null, null, $this->_dataBC); + $this->_tplBC->assign('blar', 'blar'); + } + + public function testSmarty2ClearAllAssignInSmarty() + { + error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE))); + $this->smartyBC->clear_all_assign(); + $this->assertEquals('barblar', $this->smartyBC->fetch($this->_tplBC)); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignTest.php b/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignTest.php new file mode 100644 index 00000000..2b3b3cac --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignTest.php @@ -0,0 +1,73 @@ +setUpSmarty(dirname(__FILE__)); + + $this->smarty->assign('foo', 'foo'); + $this->_data = $this->smarty->createData($this->smarty); + $this->_data->assign('bar', 'bar'); + $this->_tpl = $this->smarty->createTemplate('eval:{$foo}{$bar}{$blar}', null, null, $this->_data); + $this->_tpl->assign('blar', 'blar'); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test all variables accessable + */ + public function testAllVariablesAccessable() + { + $this->assertEquals('foobarblar', $this->smarty->fetch($this->_tpl)); + } + + /** + * test clear all assign in template + */ + public function testClearAllAssignInTemplate() + { + error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE))); + $this->_tpl->clearAllAssign(); + $this->assertEquals('foobar', $this->smarty->fetch($this->_tpl)); + } + + /** + * test clear all assign in data + */ + public function testClearAllAssignInData() + { + error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE))); + $this->_data->clearAllAssign(); + $this->assertEquals('fooblar', $this->smarty->fetch($this->_tpl)); + } + + /** + * test clear all assign in Smarty object + */ + public function testClearAllAssignInSmarty() + { + error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE))); + $this->smarty->clearAllAssign(); + $this->assertEquals('barblar', $this->smarty->fetch($this->_tpl)); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignBCTest.php b/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignBCTest.php new file mode 100644 index 00000000..17a0ed5f --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignBCTest.php @@ -0,0 +1,47 @@ +setUpSmarty(dirname(__FILE__)); + + $this->smartyBC->assign('foo', 'foo'); + $this->smartyBC->assign('bar', 'bar'); + $this->smartyBC->assign('blar', 'blar'); + } + + + public function testInit() + { + $this->cleanDirs(); + } + public function testSmarty2ClearAssign() + { + $this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + $this->smartyBC->clear_assign('blar'); + $this->assertEquals('foobar', $this->smartyBC->fetch('eval:{$foo}{$bar}{$blar}')); + } + + public function testSmarty2ArrayClearAssign() + { + $this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + $this->smartyBC->clear_assign(array('blar', 'foo')); + $this->assertEquals('bar', $this->smartyBC->fetch('eval:{$foo}{$bar}{$blar}')); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignTest.php b/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignTest.php new file mode 100644 index 00000000..d47e9da6 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignTest.php @@ -0,0 +1,53 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->assign('foo', 'foo'); + $this->smarty->assign('bar', 'bar'); + $this->smarty->assign('blar', 'blar'); + } + + /** + * test all variables accessable + */ + public function testAllVariablesAccessable() + { + $this->assertEquals('foobarblar', $this->smarty->fetch('eval:{$foo}{$bar}{$blar}')); + } + + /** + * test simple clear assign + */ + public function testClearAssign() + { + $this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + $this->smarty->clearAssign('blar'); + $this->assertEquals('foobar', $this->smarty->fetch('eval:{$foo}{$bar}{$blar}')); + } + + /** + * test clear assign array of variables + */ + public function testArrayClearAssign() + { + $this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + $this->smarty->clearAssign(array('blar', 'foo')); + $this->assertEquals('bar', $this->smarty->fetch('eval:{$foo}{$bar}{$blar}')); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAssign/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/ClearAssign/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAssign/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAssign/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/ClearAssign/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAssign/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledBCTest.php b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledBCTest.php new file mode 100644 index 00000000..9cf3f127 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledBCTest.php @@ -0,0 +1,29 @@ +setUpSmarty(dirname(__FILE__)); + $this->smartyBC->addTemplateDir('./templates_2/'); + $this->methodName = 'clear_compiled_tpl'; + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php new file mode 100644 index 00000000..51fe36b5 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php @@ -0,0 +1,454 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addTemplateDir('./templates_2/'); + $this->methodName = 'clearCompiledTemplate'; + } + + + public function testInit() + { + $this->cleanDirs(); + } + // helpers + /** + * clear $smarty->compile_dir + * + * @return void + */ + protected function clearFiles() + { + $this->cleanCompileDir(); + } + + /** + * list of compiled files + * + * @var array + */ + protected $_files = array(); + + /** + * generate compiled files + * + * @uses $_files to store references + * @return array list of files array( id => path ) + */ + protected function makeFiles() + { + $this->_files = array(); + $directory_length = strlen($this->getSmartyObj()->getCompileDir()); + $templates = array( + 'helloworld.tpl' => array(null, 'compile1', 'compile2'), + 'helloworld2.tpl' => array(null, 'compile1', 'compile2'), + 'ambiguous/case1/foobar.tpl' => array(null, 'compile1', 'compile2'), + '[1]ambiguous/case1/foobar.tpl' => array(null, 'compile1', 'compile2'), + ); + + foreach ($templates as $template => $compile_ids) { + foreach ($compile_ids as $compile_id) { + $tpl = $this->getSmartyObj()->createTemplate($template, null, $compile_id); + $tpl->fetch(); + $this->_files[$template . '#' . $compile_id] = substr($tpl->compiled->filepath, $directory_length); + } + } + // TODO + //Smarty::$_resource_cache = array(); + //$this->getSmartyObj()->_cache['template_objects'] = array(); + + return $this->_files; + } + + /** + * Transform $id to $path + * + * @param array $keys IDs like "template#compile_id" + * + * @return array list of (sorted) compiled file paths + */ + protected function expectFiles($keys) + { + $files = array(); + foreach ($keys as $key) { + if (isset($this->_files[$key])) { + $files[] = $this->_files[$key]; + } + } + sort($files); + + return $files; + } + + /** + * update mtime of compiled files + * + * @param array $keys IDs like "template#compile_id" + * @param string $offset time offset added to time() + * + * @return void + */ + protected function touchFiles($keys, $offset = 0) + { + $base = $this->getSmartyObj()->getCompileDir(); + $time = time(); + foreach ($keys as $key) { + if (isset($this->_files[$key])) { + file_put_contents($base . $this->_files[$key], ' #'); + touch($base . $this->_files[$key], $time + $offset); + } + } + clearstatcache(); + } + + /** + * find all compiled files + * + * @return array list of (sorted) compiled file paths + */ + protected function getFiles() + { + $directory = realpath($this->getSmartyObj()->getCompileDir()); + if (!$directory) { + return array(); + } + + $directory_length = strlen($directory); + $files = array(); + + $di = new RecursiveDirectoryIterator($directory); + $it = new RecursiveIteratorIterator($di); + foreach ($it as $file) { + $_file = $file->__toString(); + // skip anything with a /. in it. + if (preg_match("#[\\\\/]\.#", $_file) || substr((string)$file,-4) === '.txt' || !$file->isFile()) { + continue; + } + + $files[] = substr($file->__toString(), $directory_length + 1); + } + sort($files); + + return $files; + } + + // Smarty::clearCompiledTemplate(null, null, null) + public function testClearAll() + { + $this->runClearAll(false); + } + + public function testSubsClearAll() + { + $this->runClearAll(true); + } + + public function runClearAll($useSubDirs) + { + $this->getSmartyObj()->setUseSubDirs($useSubDirs); + $this->clearFiles(); + $this->makeFiles(); + + $expected = array(); + $this->assertEquals(12, $this->getSmartyObj()->{$this->methodName}()); + + $this->assertEquals($this->expectFiles($expected), $this->getFiles()); + $this->clearFiles(); + } + + // Smarty::clearCompiledTemplate($template, null, null) + public function testClearTemplate() + { + $this->runClearTemplate(false); + } + + public function testSubsClearTemplate() + { + $this->runClearTemplate(true); + } + + public function testClearOtherTemplate() + { + $this->runClearOtherTemplate(false); + } + + public function testSubsClearOtherTemplate() + { + $this->runClearOtherTemplate(true); + } + + public function runClearTemplate($useSubDirs) + { + $this->getSmartyObj()->setUseSubDirs($useSubDirs); + $this->clearFiles(); + $this->makeFiles(); + + $expected = array( + 'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2', + 'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2', + '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', + ); + $this->assertEquals(3, $this->getSmartyObj()->{$this->methodName}('helloworld.tpl')); + + $this->assertEquals($this->expectFiles($expected), $this->getFiles()); + $this->clearFiles(); + } + + public function runClearOtherTemplate($useSubDirs) + { + $this->getSmartyObj()->setUseSubDirs($useSubDirs); + $this->clearFiles(); + $this->makeFiles(); + + $expected = array_keys($this->_files); + $this->assertEquals(0, $this->getSmartyObj()->{$this->methodName}('foobar.tpl')); + + $this->assertEquals($this->expectFiles($expected), $this->getFiles()); + $this->clearFiles(); + } + + // Smarty::clearCompiledTemplate(null, $cache_id, null) + public function testClearCompileid() + { + $this->runClearCompileid(false); + } + + public function testSubsClearCompileid() + { + $this->runClearCompileid(true); + } + + public function testClearOtherCompileid() + { + $this->runClearOtherCompileid(false); + } + + public function testSubsClearOtherCompileid() + { + $this->runClearOtherCompileid(true); + } + + public function runClearCompileid($useSubDirs) + { + $this->getSmartyObj()->setUseSubDirs($useSubDirs); + $this->clearFiles(); + $this->makeFiles(); + + $expected = array( + 'helloworld.tpl#', 'helloworld.tpl#compile2', + 'helloworld2.tpl#', 'helloworld2.tpl#compile2', + 'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile2', + '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile2', + ); + $count = $this->getSmartyObj()->{$this->methodName}(null, 'compile1'); + $this->assertEquals(4, $count); + + $this->assertEquals($this->expectFiles($expected), $this->getFiles()); + $this->clearFiles(); + } + + public function runClearOtherCompileid($useSubDirs) + { + $this->getSmartyObj()->setUseSubDirs($useSubDirs); + $this->clearFiles(); + $this->makeFiles(); + + $expected = array_keys($this->_files); + $this->assertEquals(0, $this->getSmartyObj()->{$this->methodName}(null, 'other')); + + $this->assertEquals($this->expectFiles($expected), $this->getFiles()); + $this->clearFiles(); + } + + // Smarty::clearCompiledTemplate(null, null, $expired) + public function testClearExpired() + { + $this->runClearExpired(false); + } + + public function testSubsClearExpired() + { + $this->runClearExpired(true); + } + + public function runClearExpired($useSubDirs) + { + $this->getSmartyObj()->setUseSubDirs($useSubDirs); + $this->clearFiles(); + $this->makeFiles(); + + $expected = array('helloworld.tpl#', 'helloworld2.tpl#'); + $this->touchFiles(array_diff(array_keys($this->_files), $expected), - 1000); + $this->assertEquals(10, $this->getSmartyObj()->{$this->methodName}(null, null, 500)); + + $this->assertEquals($this->expectFiles($expected), $this->getFiles()); + $this->clearFiles(); + } + + // Smarty::clearCompiledTemplate($template, null, $expired) + public function testClearTemplateExpired() + { + $this->runClearTemplateExpired(false); + } + + public function testSubsClearTemplateExpired() + { + $this->runClearTemplateExpired(true); + } + + public function runClearTemplateExpired($useSubDirs) + { + $this->getSmartyObj()->setUseSubDirs($useSubDirs); + $this->clearFiles(); + $this->makeFiles(); + + $expected = array( + 'helloworld.tpl#', 'helloworld.tpl#compile2', + 'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2', + 'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2', + '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', + ); + $this->touchFiles(array('helloworld.tpl#compile1'), - 1000); + $this->assertEquals(1, $this->getSmartyObj()->{$this->methodName}("helloworld.tpl", null, 500)); + + $this->assertEquals($this->expectFiles($expected), $this->getFiles()); + $this->clearFiles(); + } + + // Smarty::clearCompiledTemplate($template, $cache_id, $expired) + public function testClearTemplateCacheidExpired() + { + $this->runClearTemplateCacheidExpired(false); + } + + public function testSubsClearTemplateCacheidExpired() + { + $this->runClearTemplateCacheidExpired(true); + } + + public function runClearTemplateCacheidExpired($useSubDirs) + { + $this->getSmartyObj()->setUseSubDirs($useSubDirs); + $this->clearFiles(); + $this->makeFiles(); + + $expected = array( + 'helloworld.tpl#', 'helloworld.tpl#compile2', + 'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2', + 'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2', + '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', + ); + $this->touchFiles(array('helloworld.tpl#compile1', 'helloworld.tpl#compile2'), - 1000); + $this->assertEquals(1, $this->getSmartyObj()->{$this->methodName}("helloworld.tpl", "compile1", 500)); + + $this->assertEquals($this->expectFiles($expected), $this->getFiles()); + $this->clearFiles(); + } + + // Smarty::clearCompiledTemplate(null, $cache_id, $expired) + public function testClearCacheidExpired() + { + $this->runClearCacheidExpired(false); + } + + public function testSubsClearCacheidExpired() + { + $this->runClearCacheidExpired(true); + } + + public function runClearCacheidExpired($useSubDirs) + { + $this->getSmartyObj()->setUseSubDirs($useSubDirs); + $this->clearFiles(); + $this->makeFiles(); + + $expected = array( + 'helloworld.tpl#', 'helloworld.tpl#compile2', + 'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2', + 'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2', + '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', + ); + $this->touchFiles(array('helloworld.tpl#compile1'), - 1000); + $this->assertEquals(1, $this->getSmartyObj()->{$this->methodName}(null, "compile1", 500)); + + $this->assertEquals($this->expectFiles($expected), $this->getFiles()); + $this->clearFiles(); + } + + // Smarty::clearCompiledTemplate($template, $cache_id, null) + public function testClearTemplateCacheid() + { + $this->runClearTemplateCacheid(false); + } + + public function testSubsClearTemplateCacheid() + { + $this->runClearTemplateCacheid(true); + } + + public function runClearTemplateCacheid($useSubDirs) + { + $this->getSmartyObj()->setUseSubDirs($useSubDirs); + $this->clearFiles(); + $this->makeFiles(); + + $expected = array( + 'helloworld.tpl#', 'helloworld.tpl#compile2', + 'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2', + 'ambiguous/case1/foobar.tpl#', 'ambiguous/case1/foobar.tpl#compile1', 'ambiguous/case1/foobar.tpl#compile2', + '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', + ); + $this->assertEquals(1, $this->getSmartyObj()->{$this->methodName}("helloworld.tpl", "compile1")); + + $this->assertEquals($this->expectFiles($expected), $this->getFiles()); + $this->clearFiles(); + } + + public function testClearAmbiguousTemplate() + { + $this->runClearAmbiguousTemplate(false); + } + + public function testSubsAmbiguousTemplate() + { + $this->runClearAmbiguousTemplate(true); + } + + public function runClearAmbiguousTemplate($useSubDirs) + { + $this->getSmartyObj()->setUseSubDirs($useSubDirs); + $this->clearFiles(); + $this->makeFiles(); + + // TODO: uwe.tews - shouldn't clearCompiledTemplate("foo.tpl") remove "{$template_dir[0]}/foo.tpl" AND "{$template_dir[1]}/foo.tpl"? + // currently it kills only the first one found (through regular template file identification methods) + + $expected = array( + 'helloworld.tpl#', 'helloworld.tpl#compile1', 'helloworld.tpl#compile2', + 'helloworld2.tpl#', 'helloworld2.tpl#compile1', 'helloworld2.tpl#compile2', + '[1]ambiguous/case1/foobar.tpl#', '[1]ambiguous/case1/foobar.tpl#compile1', '[1]ambiguous/case1/foobar.tpl#compile2', + ); + $this->assertEquals(3, $this->getSmartyObj()->{$this->methodName}("ambiguous/case1/foobar.tpl")); + + $this->assertEquals($this->expectFiles($expected), $this->getFiles()); + $this->clearFiles(); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/ambiguous/case1/foobar.tpl b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/ambiguous/case1/foobar.tpl new file mode 100644 index 00000000..b6e9ce55 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/ambiguous/case1/foobar.tpl @@ -0,0 +1 @@ +templates_2 \ No newline at end of file diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/helloworld.tpl b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/helloworld.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/helloworld.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/helloworld2.tpl b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/helloworld2.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates/helloworld2.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/ambiguous/case1/foobar.tpl b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/ambiguous/case1/foobar.tpl new file mode 100644 index 00000000..b6e9ce55 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/ambiguous/case1/foobar.tpl @@ -0,0 +1 @@ +templates_2 \ No newline at end of file diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/dirname.tpl b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/dirname.tpl new file mode 100644 index 00000000..b6e9ce55 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/dirname.tpl @@ -0,0 +1 @@ +templates_2 \ No newline at end of file diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/hello.tpl b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/hello.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/hello.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/helloworld.php b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/helloworld.php new file mode 100644 index 00000000..6fe5b4ba --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_2/helloworld.php @@ -0,0 +1 @@ +php hello world diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsBCTest.php b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsBCTest.php new file mode 100644 index 00000000..816c9f50 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsBCTest.php @@ -0,0 +1,54 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test root get_template_vars single value + */ + public function testGetSingleTemplateVarScopeRoot() + { + $this->smartyBC->assign('foo', 'bar'); + $this->smartyBC->assign('blar', 'buh'); + $this->assertEquals("bar", $this->smartyBC->get_template_vars('foo')); + } + + /** + * test root get_template_vars all values + */ + public function testGetAllTemplateVarsScopeRoot() + { + $this->smartyBC->assign('foo', 'bar'); + $this->smartyBC->assign('blar', 'buh'); + $vars = $this->smartyBC->get_template_vars(); + $this->assertTrue(is_array($vars)); + $this->assertEquals("bar", $vars['foo']); + $this->assertEquals("buh", $vars['blar']); + } + +} diff --git a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsTest.php b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsTest.php new file mode 100644 index 00000000..7fd71f1e --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsTest.php @@ -0,0 +1,112 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test root getTemplateVars single value + */ + public function testGetSingleTemplateVarScopeRoot() + { + $this->smarty->assign('foo', 'bar'); + $this->smarty->assign('blar', 'buh'); + $this->assertEquals("bar", $this->smarty->getTemplateVars('foo')); + } + + /** + * test root getTemplateVars all values + */ + public function testGetAllTemplateVarsScopeRoot() + { + $this->smarty->assign('foo', 'bar'); + $this->smarty->assign('blar', 'buh'); + $vars = $this->smarty->getTemplateVars(); + $this->assertTrue(is_array($vars)); + $this->assertEquals("bar", $vars['foo']); + $this->assertEquals("buh", $vars['blar']); + } + + /** + * test single variable with data object chain + */ + public function testGetSingleTemplateVarScopeAll() + { + $data1 = $this->smarty->createData($this->smarty); + $data2 = $this->smarty->createData($data1); + $this->smarty->assign('foo', 'bar'); + $this->smarty->assign('blar', 'buh'); + $this->assertEquals("bar", $this->smarty->getTemplateVars('foo', $data2)); + } + + /** + * test get all variables with data object chain + */ + public function testGetAllTemplateVarsScopeAll() + { + $data1 = $this->smarty->createData($this->smarty); + $data2 = $this->smarty->createData($data1); + $this->smarty->assign('foo', 'bar'); + $data1->assign('blar', 'buh'); + $data2->assign('foo2', 'bar2'); + $vars = $this->smarty->getTemplateVars(null, $data2); + $this->assertTrue(is_array($vars)); + $this->assertEquals("bar", $vars['foo']); + $this->assertEquals("bar2", $vars['foo2']); + $this->assertEquals("buh", $vars['blar']); + } + + /** + * test get all variables with data object chain search parents disabled + */ + public function testGetAllTemplateVarsScopeAllNoParents() + { + $data1 = $this->smarty->createData($this->smarty); + $data2 = $this->smarty->createData($data1); + $this->smarty->assign('foo', 'bar'); + $data1->assign('blar', 'buh'); + $data2->assign('foo2', 'bar2'); + $vars = $this->smarty->getTemplateVars(null, $data2, false); + $this->assertTrue(is_array($vars)); + $this->assertFalse(isset($vars['foo'])); + $this->assertEquals("bar2", $vars['foo2']); + $this->assertFalse(isset($vars['blar'])); + } + + /** + * test get single variables with data object chain search parents disabled + */ + public function testGetSingleTemplateVarsScopeAllNoParents() + { + error_reporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + $data1 = $this->smarty->createData($this->smarty); + $data2 = $this->smarty->createData($data1); + $this->smarty->assign('foo', 'bar'); + $data1->assign('blar', 'buh'); + $data2->assign('foo2', 'bar2'); + $this->assertEquals("", $this->smarty->getTemplateVars('foo', $data2, false)); + $this->assertEquals("bar2", $this->smarty->getTemplateVars('foo2', $data2, false)); + $this->assertEquals("", $this->smarty->getTemplateVars('blar', $data2, false)); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php new file mode 100644 index 00000000..5d5f845f --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php @@ -0,0 +1,312 @@ +block / unregister->block methods + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for register->block / unregister->block methods tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class RegisterBlockTest extends PHPUnit_Smarty +{ + public $loadSmartyBC = true; + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->disableSecurity(); + $this->smartyBC->disableSecurity(); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test registerPlugin method for block function + */ + public function testRegisterBlockFunction() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); + $this->smarty->assign('value', 1); + $this->assertEquals('function hello world 1 1 function hello world 1 2 function hello world 1 3 ', $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock}')); + } + + public function testRegisterBlockFunctionModifier1() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); + $this->smarty->assign('value', 1); + $this->assertEquals(strtoupper('function hello world 1 1 function hello world 1 2 function hello world 1 3 '), $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock|strtoupper}')); + } + + public function testRegisterBlockFunctionModifier2() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); + $this->smarty->assign('value', 1); + $this->assertEquals(strtoupper('function hello world 1 1 function hello world 1 2 function hello world 1 3 '), $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock|default:""|strtoupper}')); + } + + public function testRegisterBlockFunctionWrapper() + { + $this->smartyBC->register_block('testblock', 'myblock'); + $this->smartyBC->assign('value', 1); + $this->assertEquals('function hello world 1 1 function hello world 1 2 function hello world 1 3 ', $this->smartyBC->fetch('eval:{testblock}hello world {$value}{/testblock}')); + } + + /** + * test registerPlugin method for block class + */ + public function testRegisterBlockClass() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', array('myblockclass', 'static_method')); + $this->smarty->assign('value', 2); + $this->assertEquals('static hello world 2 1 static hello world 2 2 static hello world 2 3 ', $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock}')); + } + + public function testRegisterBlockClassWrapper() + { + $this->smartyBC->register_block('testblock', array('myblockclass', 'static_method')); + $this->smartyBC->assign('value', 2); + $this->assertEquals('static hello world 2 1 static hello world 2 2 static hello world 2 3 ', $this->smartyBC->fetch('eval:{testblock}hello world {$value}{/testblock}')); + } + + /** + * test registerPlugin method for block object + */ + public function testRegisterBlockObject() + { + $myblock_object = new myblockclass; + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', array($myblock_object, 'object_method')); + $this->smarty->assign('value', 3); + $this->assertEquals('object hello world 3 1 object hello world 3 2 object hello world 3 3 ', $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock}')); + } + + public function testRegisterBlockObjectWrapper() + { + $myblock_object = new myblockclass; + $this->smartyBC->register_block('testblock', array($myblock_object, 'object_method')); + $this->smartyBC->assign('value', 3); + $this->assertEquals('object hello world 3 1 object hello world 3 2 object hello world 3 3 ', $this->smartyBC->fetch('eval:{testblock}hello world {$value}{/testblock}')); + } + + /** + * test registerPlugin method for block with caching + */ + public function testRegisterBlockCaching1() + { + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setForceCompile(true); + $this->smarty->assign('x', 1); + $this->smarty->assign('y', 10); + $this->smarty->assign('z', 100); + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache'); + $this->assertEquals('1 10 100', $this->smarty->fetch('test_register_block.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterBlockCaching2() + { + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('x', 2); + $this->smarty->assign('y', 20); + $this->smarty->assign('z', 200); + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache'); + $this->assertEquals('1 10 100', $this->smarty->fetch('test_register_block.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterBlockCaching3() + { + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setForceCompile(true); + $this->smarty->assign('x', 3); + $this->smarty->assign('y', 30); + $this->smarty->assign('z', 300); + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache', false); + $this->assertEquals('3 30 300', $this->smarty->fetch('test_register_block.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterBlockCaching4() + { + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('x', 4); + $this->smarty->assign('y', 40); + $this->smarty->assign('z', 400); + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache', false); + $this->assertEquals('3 40 300', $this->smarty->fetch('test_register_block.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterBlockCaching1Wrapper() + { + $this->smartyBC->caching = 1; + $this->smartyBC->cache_lifetime = 1000; + $this->smartyBC->setForceCompile(true); + $this->smartyBC->assign('x', 1); + $this->smartyBC->assign('y', 10); + $this->smartyBC->assign('z', 100); + $this->smartyBC->register_block('testblock', 'myblockcache'); + $this->assertEquals('1 10 100', $this->smartyBC->fetch('test_register_block.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterBlockCaching2Wrapper() + { + $this->smartyBC->caching = 1; + $this->smartyBC->cache_lifetime = 1000; + $this->smartyBC->assign('x', 2); + $this->smartyBC->assign('y', 20); + $this->smartyBC->assign('z', 200); + $this->smartyBC->register_block('testblock', 'myblockcache'); + $this->assertEquals('1 10 100', $this->smartyBC->fetch('test_register_block.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterBlockCaching3Wrapper() + { + $this->smartyBC->caching = 1; + $this->smartyBC->cache_lifetime = 1000; + $this->smartyBC->setForceCompile(true); + $this->smartyBC->assign('x', 3); + $this->smartyBC->assign('y', 30); + $this->smartyBC->assign('z', 300); + $this->smartyBC->register_block('testblock', 'myblockcache', false); + $this->assertEquals('3 30 300', $this->smartyBC->fetch('test_register_block.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterBlockCaching4Wrapper() + { + $this->smartyBC->caching = 1; + $this->smartyBC->cache_lifetime = 1000; + $this->smartyBC->assign('x', 4); + $this->smartyBC->assign('y', 40); + $this->smartyBC->assign('z', 400); + $this->smartyBC->register_block('testblock', 'myblockcache', false); + $this->assertEquals('3 40 300', $this->smartyBC->fetch('test_register_block.tpl')); + } + + /** + * test unregister->block method + */ + public function testUnregisterBlock() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); + $this->smarty->unregisterPlugin(Smarty::PLUGIN_BLOCK, 'testblock'); + $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK]['testblock'])); + } + + public function testUnregisterBlockWrapper() + { + $this->smartyBC->register_block('testblock', 'myblock'); + $this->smartyBC->unregister_block('testblock'); + $this->assertFalse(isset($this->smartyBC->registered_plugins[Smarty::PLUGIN_BLOCK]['testblock'])); + } + + /** + * test unregister->block method not registered + */ + public function testUnregisterBlockNotRegistered() + { + $this->smarty->unregisterPlugin(Smarty::PLUGIN_BLOCK, 'testblock'); + $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK]['testblock'])); + } +} + +function myblock($params, $content, &$smarty_tpl, &$repeat) +{ + static $loop = 0; + + if ($content == null) { + $loop = 0; + + return; + } + $loop ++; + if ($loop < 3) { + $repeat = true; + } + + return "function $content $loop "; +} + +function myblockcache($params, $content, &$smarty_tpl, &$repeat) +{ + return $content; +} + +class myblockclass +{ + static function static_method($params, $content, &$smarty_tpl, &$repeat) + { + static $loop = 0; + + if ($content == null) { + $loop = 0; + + return; + } + $loop ++; + if ($loop < 3) { + $repeat = true; + } + + return "static $content $loop "; + } + + public function object_method($params, $content, &$smarty_tpl, &$repeat) + { + static $loop = 0; + + if ($content == null) { + $loop = 0; + + return; + } + $loop ++; + if ($loop < 3) { + $repeat = true; + } + + return "object $content $loop "; + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/templates/test_register_block.tpl b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/templates/test_register_block.tpl new file mode 100644 index 00000000..858eab15 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/templates/test_register_block.tpl @@ -0,0 +1 @@ +{$x} {testblock}{$y}{/testblock} {$z} \ No newline at end of file diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionBCTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionBCTest.php new file mode 100644 index 00000000..3dee8b1e --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionBCTest.php @@ -0,0 +1,127 @@ +compilerFunction / unregister->compilerFunction methods + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for register->compilerFunction / unregister->compilerFunction methods tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class RegisterCompilerFunctionBCTest extends PHPUnit_Smarty +{ + public $loadSmartyBC = true; + public $loadSmarty = false; + + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test register->compilerFunction method for function + */ + public function testRegisterCompilerFunction() + { + $this->smartyBC->register_compiler_function('testcompilerfunction', 'mycompilerfunctionBC'); + $this->assertEquals('mycompilerfunctionBC', $this->smartyBC->registered_plugins['compiler']['testcompilerfunction'][0]); + $this->assertEquals('hello world 1', $this->smartyBC->fetch('eval:{testcompilerfunction var=1}')); + } + + /** + * test register->compilerFunction method for blocks + */ + public function testRegisterCompilerFunctionBlock() + { + $this->smartyBC->register_compiler_function('foo', 'mycompilerfunctionBCopen'); + $this->smartyBC->register_compiler_function('fooclose', 'mycompilerfunctionBCclose'); + $result = $this->smartyBC->fetch('eval:{foo} hallo {/foo}'); + $this->assertEquals('open tag hallo close tag', $result); + } + + /** + * test register->compilerFunction method for static class + */ + public function testRegisterCompilerFunctionClass() + { + $this->smartyBC->register_compiler_function('testcompilerfunction', array('mycompilerfunctionBCclass', 'execute')); + $this->assertEquals('hello world 2', $this->smartyBC->fetch('eval:{testcompilerfunction var1=2}')); + } + + /** + * test register->compilerFunction method for objects + */ + public function testRegisterCompilerFunctionObject() + { + $obj = new mycompilerfunctionBCclass; + $this->smartyBC->register_compiler_function('testcompilerfunction', array($obj, 'compile')); + $this->assertEquals('hello world 3', $this->smartyBC->fetch('eval:{testcompilerfunction var2=3}')); + } + + /** + * test unregister->compilerFunction method + */ + public function testUnregisterCompilerFunction() + { + $this->smartyBC->register_compiler_function('testcompilerfunction', 'mycompilerfunctionBC'); + $this->smartyBC->unregister_compiler_function('testcompilerfunction'); + $this->assertFalse(isset($this->smartyBC->registered_plugins[Smarty::PLUGIN_COMPILER]['testcompilerfunction'])); + } + + /** + * test unregister->compilerFunction method not registered + */ + public function testUnregisterCompilerFunctionNotRegistered() + { + $this->smartyBC->unregister_compiler_function('testcompilerfunction'); + $this->assertFalse(isset($this->smartyBC->registered_plugins[Smarty::PLUGIN_COMPILER]['testcompilerfunction'])); + } + + /** + * test unregister->compilerFunction method other registered + */ + public function testUnregisterCompilerFunctionOtherRegistered() + { + $this->smartyBC->register_block('testcompilerfunction', 'mycompilerfunctionBC'); + $this->smartyBC->unregister_compiler_function('testcompilerfunction'); + $this->assertTrue(isset($this->smartyBC->registered_plugins[Smarty::PLUGIN_BLOCK]['testcompilerfunction'])); + } +} + +function mycompilerfunctionBC($params, $smarty) +{ + return ""; +} + +function mycompilerfunctionBCopen($params, $smarty) +{ + return ""; +} + +function mycompilerfunctionBCclose($params, $smarty) +{ + return ""; +} + +class mycompilerfunctionBCclass +{ + static function execute($params, $smarty) + { + return ""; + } + + public function compile($params, $smarty) + { + return ""; + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php new file mode 100644 index 00000000..54db28a6 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php @@ -0,0 +1,124 @@ +compilerFunction / unregister->compilerFunction methods + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for register->compilerFunction / unregister->compilerFunction methods tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class RegisterCompilerFunctionTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test register->compilerFunction method for function + */ + public function testRegisterCompilerFunction() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction', 'mycompilerfunction'); + $this->assertEquals('mycompilerfunction', $this->smarty->registered_plugins['compiler']['testcompilerfunction'][0]); + $this->assertEquals('hello world 1', $this->smarty->fetch('eval:{testcompilerfunction var=1}')); + } + + /** + * test register->compilerFunction method for blocks + */ + public function testRegisterCompilerFunctionBlock() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'foo', 'mycompilerfunctionopen'); + $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'fooclose', 'mycompilerfunctionclose'); + $result = $this->smarty->fetch('eval:{foo} hallo {/foo}'); + $this->assertEquals('open tag hallo close tag', $result); + } + + /** + * test register->compilerFunction method for static class + */ + public function testRegisterCompilerFunctionClass() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction', array('mycompilerfunctionclass', 'execute')); + $this->assertEquals('hello world 2', $this->smarty->fetch('eval:{testcompilerfunction var1=2}')); + } + + /** + * test register->compilerFunction method for objects + */ + public function testRegisterCompilerFunctionObject() + { + $obj = new mycompilerfunctionclass; + $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction', array($obj, 'compile')); + $this->assertEquals('hello world 3', $this->smarty->fetch('eval:{testcompilerfunction var2=3}')); + } + + /** + * test unregister->compilerFunction method + */ + public function testUnregisterCompilerFunction() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction', 'mycompilerfunction'); + $this->smarty->unregisterPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction'); + $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER]['testcompilerfunction'])); + } + + /** + * test unregister->compilerFunction method not registered + */ + public function testUnregisterCompilerFunctionNotRegistered() + { + $this->smarty->unregisterPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction'); + $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER]['testcompilerfunction'])); + } + + /** + * test unregister->compilerFunction method other registered + */ + public function testUnregisterCompilerFunctionOtherRegistered() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testcompilerfunction', 'mycompilerfunction'); + $this->smarty->unregisterPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction'); + $this->assertTrue(isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK]['testcompilerfunction'])); + } +} + +function mycompilerfunction($params, $smarty) +{ + return ""; +} + +function mycompilerfunctionopen($params, $smarty) +{ + return ""; +} + +function mycompilerfunctionclose($params, $smarty) +{ + return ""; +} + +class mycompilerfunctionclass +{ + static function execute($params, $smarty) + { + return ""; + } + + public function compile($params, $smarty) + { + return ""; + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionBCTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionBCTest.php new file mode 100644 index 00000000..b9082c26 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionBCTest.php @@ -0,0 +1,173 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test registerPlugin method for function + */ + public function testRegisterFunction() + { + $this->smartyBC->register_function('testfunction', 'myfunctionBC'); + $this->assertEquals('myfunctionBC', + $this->smartyBC->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ 'testfunction' ][ 0 ]); + $this->assertEquals('hello world 1', $this->smartyBC->fetch('eval:{testfunction value=1}')); + } + + /** + * test registerPlugin method for function class + */ + public function testRegisterFunctionClass() + { + $this->smartyBC->register_function('testfunction', array('myfunctionBCclass', 'execute')); + $this->assertEquals('hello world 2', $this->smartyBC->fetch('eval:{testfunction value=2}')); + } + + /** + * test registerPlugin method for function object + */ + public function testRegisterFunctionObject() + { + $myfunctionBC_object = new myfunctionBCclass; + $this->smartyBC->register_function('testfunction', array($myfunctionBC_object, 'execute')); + $this->assertEquals('hello world 3', $this->smartyBC->fetch('eval:{testfunction value=3}')); + } + + /** + * test registerPlugin method for function cached + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testRegisterFunctionCaching1() + { + $this->smartyBC->caching = 1; + $this->smartyBC->cache_lifetime = 1000; + $this->smartyBC->setForceCompile(true); + $this->smartyBC->assign('x', 0); + $this->smartyBC->assign('y', 10); + $this->smartyBC->register_function('testfunction', 'myfunctionBC'); + $this->assertEquals('hello world 0 10', $this->smartyBC->fetch('test_register_function.tpl')); + } + + /** + * test registerPlugin method for function cached + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterFunctionCaching2() + { + $this->smartyBC->caching = 1; + $this->smartyBC->cache_lifetime = 1000; + $this->smartyBC->assign('x', 1); + $this->smartyBC->assign('y', 20); + $this->smartyBC->register_function('testfunction', 'myfunctionBC'); + $this->assertEquals('hello world 0 10', $this->smartyBC->fetch('test_register_function.tpl')); + } + + /** + * test registerPlugin method for function not cached + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterFunctionCaching3() + { + $this->smartyBC->caching = 1; + $this->smartyBC->cache_lifetime = 1000; + $this->smartyBC->setForceCompile(true); + $this->smartyBC->assign('x', 2); + $this->smartyBC->assign('y', 30); + $this->smartyBC->register_function('testfunction', 'myfunctionBC', false); + $this->assertEquals('hello world 2 30', $this->smartyBC->fetch('test_register_function.tpl')); + } + + /** + * test registerPlugin method for function not cached + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterFunctionCaching4() + { + $this->smartyBC->caching = 1; + $this->smartyBC->cache_lifetime = 1000; + $this->smartyBC->assign('x', 3); + $this->smartyBC->assign('y', 40); + $this->smartyBC->register_function('testfunction', 'myfunctionBC', false); + $this->assertEquals('hello world 3 30', $this->smartyBC->fetch('test_register_function.tpl')); + } + + /** + * test unregisterPlugin method for function + */ + public function testUnregisterFunction() + { + $this->smartyBC->register_function('testfunction', 'myfunctionBC'); + $this->smartyBC->unregister_function('testfunction'); + $this->assertFalse(isset($this->smartyBC->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ 'testfunction' ])); + } + + /** + * test test unregisterPlugin method for function not registered + */ + public function testUnregisterfunctionotRegistered() + { + $this->smartyBC->unregister_function('testfunction'); + $this->assertFalse(isset($this->smartyBC->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ 'testfunction' ])); + } + + /** + * test test unregisterPlugin method for function other registered + */ + public function testUnregisterFunctionOtherRegistered() + { + $this->smartyBC->register_block('testfunction', 'myfunctionBC'); + $this->smartyBC->unregister_function('testfunction'); + $this->assertTrue(isset($this->smartyBC->registered_plugins[ Smarty::PLUGIN_BLOCK ][ 'testfunction' ])); + } +} + +function myfunctionBC($params, $smarty) +{ + return "hello world $params[value]"; +} + +class myfunctionBCclass +{ + static function execute($params, $smarty) + { + return "hello world $params[value]"; + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php new file mode 100644 index 00000000..8cc828cc --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php @@ -0,0 +1,169 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test registerPlugin method for function + */ + public function testRegisterFunction() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); + $this->assertEquals('myfunction', + $this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ 'testfunction' ][ 0 ]); + $this->assertEquals('hello world 1', $this->smarty->fetch('eval:{testfunction value=1}')); + } + + /** + * test registerPlugin method for function class + */ + public function testRegisterFunctionClass() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', array('myfunctionclass', 'execute')); + $this->assertEquals('hello world 2', $this->smarty->fetch('eval:{testfunction value=2}')); + } + + /** + * test registerPlugin method for function object + */ + public function testRegisterFunctionObject() + { + $myfunction_object = new myfunctionclass; + $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', array($myfunction_object, 'execute')); + $this->assertEquals('hello world 3', $this->smarty->fetch('eval:{testfunction value=3}')); + } + + /** + * test registerPlugin method for function cached + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testRegisterFunctionCaching1() + { + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setForceCompile(true); + $this->smarty->assign('x', 0); + $this->smarty->assign('y', 10); + $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); + $this->assertEquals('hello world 0 10', $this->smarty->fetch('test_register_function.tpl')); + } + + /** + * test registerPlugin method for function cached + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterFunctionCaching2() + { + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('x', 1); + $this->smarty->assign('y', 20); + $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); + $this->assertEquals('hello world 0 10', $this->smarty->fetch('test_register_function.tpl')); + } + + /** + * test registerPlugin method for function not cached + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterFunctionCaching3() + { + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $this->smarty->setForceCompile(true); + $this->smarty->assign('x', 2); + $this->smarty->assign('y', 30); + $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction', false); + $this->assertEquals('hello world 2 30', $this->smarty->fetch('test_register_function.tpl')); + } + + /** + * test registerPlugin method for function not cached + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testRegisterFunctionCaching4() + { + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('x', 3); + $this->smarty->assign('y', 40); + $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction', false); + $this->assertEquals('hello world 3 30', $this->smarty->fetch('test_register_function.tpl')); + } + + /** + * test unregisterPlugin method for function + */ + public function testUnregisterFunction() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); + $this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction'); + $this->assertFalse(isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ 'testfunction' ])); + } + + /** + * test test unregisterPlugin method for function not registered + */ + public function testUnregisterFunctionNotRegistered() + { + $this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction'); + $this->assertFalse(isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ 'testfunction' ])); + } + + /** + * test test unregisterPlugin method for function other registered + */ + public function testUnregisterFunctionOtherRegistered() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testfunction', 'myfunction'); + $this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction'); + $this->assertTrue(isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ 'testfunction' ])); + } +} + +function myfunction($params, $smarty) +{ + return "hello world $params[value]"; +} + +class myfunctionclass +{ + static function execute($params, $smarty) + { + return "hello world $params[value]"; + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterFunction/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterFunction/templates/test_register_function.tpl b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/templates/test_register_function.tpl new file mode 100644 index 00000000..58453b77 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/templates/test_register_function.tpl @@ -0,0 +1 @@ +{testfunction value=$x} {$y} \ No newline at end of file diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterFunction/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php new file mode 100644 index 00000000..6b768984 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php @@ -0,0 +1,109 @@ +modifier / unregister->modifier methods + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for register->modifier / unregister->modifier methods tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class RegisterModifierTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test register->modifier method for function + */ + public function testRegisterModifier() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', 'mymodifier'); + $this->assertEquals('mymodifier', $this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['testmodifier'][0]); + $this->smarty->assign('foo', 'foo'); + $this->smarty->assign('bar', 'bar'); + $this->assertEquals('foo function blar bar', $this->smarty->fetch('eval:{$foo|testmodifier:blar:$bar}')); + } + + /** + * test register->modifier method for classes + */ + public function testRegisterModifierClass() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', array('mymodifierclass', 'static_method')); + $this->smarty->assign('foo', 'foo'); + $this->smarty->assign('bar', 'bar'); + $this->assertEquals('foo static blar bar', $this->smarty->fetch('eval:{$foo|testmodifier:blar:$bar}')); + } + + /** + * test register->modifier method for objects + */ + public function testRegisterModifierObject() + { + $obj = new mymodifierclass; + $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', array($obj, 'object_method')); + $this->smarty->assign('foo', 'foo'); + $this->smarty->assign('bar', 'bar'); + $this->assertEquals('foo object blar bar', $this->smarty->fetch('eval:{$foo|testmodifier:blar:$bar}')); + } + + /** + * test unregister->modifier method + */ + public function testUnregisterModifier() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', 'mymodifier'); + $this->smarty->unregisterPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier'); + $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['testmodifier'])); + } + + /** + * test unregister->modifier method not registered + */ + public function testUnregisterModifierNotRegistered() + { + $this->smarty->unregisterPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier'); + $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['testmodifier'])); + } + + /** + * test unregister->modifier method other registered + */ + public function testUnregisterModifierOtherRegistered() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testmodifier', 'mymodifier'); + $this->smarty->unregisterPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier'); + $this->assertTrue(isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK]['testmodifier'])); + } +} + +function mymodifier($a, $b, $c) +{ + return "$a function $b $c"; +} + +class mymodifierclass +{ + static function static_method($a, $b, $c) + { + return "$a static $b $c"; + } + + public function object_method($a, $b, $c) + { + return "$a object $b $c"; + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterModifier/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/RegisterModifier/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterModifier/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterModifier/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/RegisterModifier/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterModifier/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php new file mode 100644 index 00000000..be57c06f --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php @@ -0,0 +1,106 @@ +setUpSmarty(dirname(__FILE__)); + + $this->smarty->setForceCompile(true); + $this->smarty->disableSecurity(); + $this->object = new RegObject; + $this->smarty->registerObject('objecttest', $this->object, 'myhello', true, 'myblock'); + $this->smarty->registerObject('objectprop', $this->object); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test resgistered object as function + */ + public function testRegisteredObjectFunction() + { + $tpl = $this->smarty->createTemplate('eval:{objecttest->myhello}'); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + + /** + * test resgistered object as function with modifier + */ + public function testRegisteredObjectFunctionModifier() + { + $tpl = $this->smarty->createTemplate('eval:{objecttest->myhello|truncate:6}'); + $this->assertEquals('hel...', $this->smarty->fetch($tpl)); + } + + /** + * test resgistered object as block function + */ + public function testRegisteredObjectBlockFunction() + { + $tpl = $this->smarty->createTemplate('eval:{objecttest->myblock}hello world{/objecttest->myblock}'); + $this->assertEquals('block test', $this->smarty->fetch($tpl)); + } + + public function testRegisteredObjectBlockFunctionModifier1() + { + $tpl = $this->smarty->createTemplate('eval:{objecttest->myblock}hello world{/objecttest->myblock|strtoupper}'); + $this->assertEquals(strtoupper('block test'), $this->smarty->fetch($tpl)); + } + + public function testRegisteredObjectBlockFunctionModifier2() + { + $tpl = $this->smarty->createTemplate('eval:{objecttest->myblock}hello world{/objecttest->myblock|default:""|strtoupper}'); + $this->assertEquals(strtoupper('block test'), $this->smarty->fetch($tpl)); + } + // TODO + + /** + public function testRegisteredObjectProperty() + { + $tpl = $this->smarty->createTemplate('eval:{objectprop->prop}'); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + + public function testRegisteredObjectPropertyAssign() + { + $tpl = $this->smarty->createTemplate('eval:{objectprop->prop assign="foo"}{$foo}'); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + */ +} + +Class RegObject +{ + public $prop = 'hello world'; + + public function myhello($params) + { + return 'hello world'; + } + + public function myblock($params, $content, &$smarty_tpl, &$repeat) + { + if (isset($content)) { + $output = str_replace('hello world', 'block test', $content); + + return $output; + } + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterObject/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/RegisterObject/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterObject/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterObject/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/RegisterObject/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/RegisterObject/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/TemplateExist/TemplateExistsTest.php b/tests/UnitTests/SmartyMethodsTests/TemplateExist/TemplateExistsTest.php new file mode 100644 index 00000000..f387d8f7 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/TemplateExist/TemplateExistsTest.php @@ -0,0 +1,43 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test $smarty->templateExists true + */ + public function testSmartyTemplateExists() + { + $this->assertTrue($this->smarty->templateExists('helloworld.tpl')); + } + + /** + * test $smarty->templateExists false + */ + public function testSmartyTemplateNotExists() + { + $this->assertFalse($this->smarty->templateExists('notthere.tpl')); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/TemplateExist/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/TemplateExist/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/TemplateExist/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/TemplateExist/templates/helloworld.tpl b/tests/UnitTests/SmartyMethodsTests/TemplateExist/templates/helloworld.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/TemplateExist/templates/helloworld.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/SmartyMethodsTests/TemplateExist/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/TemplateExist/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/TemplateExist/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Comments/CommentsTest.php b/tests/UnitTests/TemplateSource/Comments/CommentsTest.php new file mode 100644 index 00000000..281b5aec --- /dev/null +++ b/tests/UnitTests/TemplateSource/Comments/CommentsTest.php @@ -0,0 +1,79 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test comments + * + * @preserveGlobalState disabled + * @dataProvider dataTestComments + */ + public function testComments($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testComments_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->template_dir = './templates_tmp'; + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testComments + */ + public function dataTestComments() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array('{* this is a comment *}', '', 'T1', $i++), + array('{* another $foo comment *}', '', 'T2', $i++), + array('{* another comment *}some in between{* another comment *}', 'some in between', + 'T3', $i++), + array("{* multi line \n comment *}", '', 'T4', $i++), + array('{* /* foo * / *}', '', 'T5', $i++), + array("A{* comment *}B\nC", "AB\nC", 'T6', $i++), + array("D{* comment *}\n{* comment *}E\nF", "DE\nF", 'T7', $i++), + array("G{* multi \nline *}H", "GH", 'T8', $i++), + array("I{* multi \nline *}\nJ", "IJ", 'T9', $i++), + array("=\n{* comment *}\n{* comment *}\n b\n{* comment *}\n{* comment *}\n=", "=\n b\n=", 'T10', $i++), + array("=\na\n{* comment 1 *}\n{* comment 2 *}\n{* comment 3 *}\nb\n=", "=\na\nb\n=", 'T11', $i++), + array("=\na\n{* comment 1 *}\n {* comment 2 *}\n{* comment 3 *}\nb\n=", "=\na\n b\n=", 'T12', $i++), + array("=\na\n{* comment 1 *}\n{* comment 2 *} \n{* comment 3 *}\nb\n=", "=\na\n \nb\n=", 'T13', $i++), + array("=\na\n{* comment 1 *}\n {* comment 2 *} \n{* comment 3 *}\nb\n=", "=\na\n \nb\n=", 'T14', $i++), + ); + } + + public function testTextComment5() + { + $this->assertEquals("IJ", $this->smarty->fetch("longcomment.tpl"), 'Comments longcomment.tpl'); + } +} diff --git a/tests/UnitTests/TemplateSource/Comments/cache/.gitignore b/tests/UnitTests/TemplateSource/Comments/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Comments/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Comments/templates/longcomment.tpl b/tests/UnitTests/TemplateSource/Comments/templates/longcomment.tpl new file mode 100644 index 00000000..8fa2edfc --- /dev/null +++ b/tests/UnitTests/TemplateSource/Comments/templates/longcomment.tpl @@ -0,0 +1,225 @@ +I{* + +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.

+ +*} +J \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/Comments/templates_c/.gitignore b/tests/UnitTests/TemplateSource/Comments/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Comments/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Spacing/SpacingTest.php b/tests/UnitTests/TemplateSource/Spacing/SpacingTest.php new file mode 100644 index 00000000..bfcb7495 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Spacing/SpacingTest.php @@ -0,0 +1,77 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->template_dir = './templates_tmp'; + $this->smarty->assign('file', $file); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array('{$foo}', 'bar', 'T1', $i++), + array('{$foo}{$foo}', 'barbar', 'T2', $i++), + array('A{$foo}{$foo}B', 'AbarbarB', 'T3', $i++), + array('{$foo} {$foo}', 'bar bar', 'T4', $i++), + array('A{$foo}B', 'AbarB', 'T5', $i++), + array('A{counter}B', 'A1B', 'T6', $i++), + array('A {$foo}B', 'A barB', 'T7', $i++), + array('A{$foo} B', 'Abar B', 'T8', $i++), + array("A{\$foo}\nB", "Abar\nB", 'T9', $i++), + array("A{counter start=1}\nB", "A1\nB", 'T10', $i++), + array("A{\$foo}B\nC", "AbarB\nC", 'T11', $i++), + array("A{assign var=zoo value='blah'}B", "AB", 'T12', $i++), + array("A\n{assign var=zoo value='blah'}\nB", "A\nB", 'T13', $i++), + array("E{assign var=zoo value='blah'}\nF", "EF", 'T14', $i++), + array("G\n{assign var=zoo value='blah'}H", "G\nH", 'T15', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/Spacing/cache/.gitignore b/tests/UnitTests/TemplateSource/Spacing/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Spacing/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Spacing/templates_c/.gitignore b/tests/UnitTests/TemplateSource/Spacing/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Spacing/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Spacing/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/Spacing/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Spacing/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/StaticClass/StaticClassAccessTest.php b/tests/UnitTests/TemplateSource/StaticClass/StaticClassAccessTest.php new file mode 100644 index 00000000..42d9f0ce --- /dev/null +++ b/tests/UnitTests/TemplateSource/StaticClass/StaticClassAccessTest.php @@ -0,0 +1,136 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->disableSecurity(); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test static class variable + */ + public function testStaticClassVariable() + { + $tpl = $this->smarty->createTemplate('eval:{mystaticclass::$static_var}'); + $this->assertEquals('5', $this->smarty->fetch($tpl)); + } + + /** + * test registered static class variable + */ + public function testStaticRegisteredClassVariable() + { + $this->smarty->registerClass('registeredclass', 'mystaticclass'); + $tpl = $this->smarty->createTemplate('eval:{registeredclass::$static_var}'); + $this->assertEquals('5', $this->smarty->fetch($tpl)); + } + + /** + * test static class constant + */ + public function testStaticClassConstant() + { + $tpl = $this->smarty->createTemplate('eval:{mystaticclass::STATIC_CONSTANT_VALUE}'); + $this->assertEquals('3', $this->smarty->fetch($tpl)); + } + + /** + * test static class constant + */ + public function testRegisteredStaticClassConstant() + { + $this->smarty->registerClass('registeredclass', 'mystaticclass'); + $tpl = $this->smarty->createTemplate('eval:{registeredclass::STATIC_CONSTANT_VALUE}'); + $this->assertEquals('3', $this->smarty->fetch($tpl)); + } + + /** + * test static class method + */ + public function testStaticClassmethod() + { + $tpl = $this->smarty->createTemplate('eval:{mystaticclass::square(5)}'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } + + /** + * test static class method + */ + public function testRegisteredStaticClassmethod() + { + $this->smarty->registerClass('registeredclass', 'mystaticclass'); + $tpl = $this->smarty->createTemplate('eval:{registeredclass::square(5)}'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } + + /** + * test static class variable method + */ + public function testStaticClassVariablemethod() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'square\'}{mystaticclass::$foo(5)}'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } + + /** + * test registered static class variable method + */ + public function testRegisteredStaticClassVariablemethod() + { + $this->smarty->registerClass('registeredclass', 'mystaticclass'); + $tpl = $this->smarty->createTemplate('eval:{$foo=\'square\'}{registeredclass::$foo(5)}'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } + + /** + * test static class variable method + */ + public function testStaticClassVariablemethod2() + { + $tpl = $this->smarty->createTemplate('eval:{mystaticclass::$foo(5)}'); + $tpl->assign('foo', 'square'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } + + /** + * test registered static class variable method + */ + public function testRegisteredStaticClassVariablemethod2() + { + $this->smarty->registerClass('registeredclass', 'mystaticclass'); + $tpl = $this->smarty->createTemplate('eval:{registeredclass::$foo(5)}'); + $tpl->assign('foo', 'square'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } +} + +class mystaticclass +{ + const STATIC_CONSTANT_VALUE = 3; + static $static_var = 5; + + static function square($i) + { + return $i * $i; + } +} diff --git a/tests/UnitTests/TemplateSource/StaticClass/cache/.gitignore b/tests/UnitTests/TemplateSource/StaticClass/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/StaticClass/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/StaticClass/templates_c/.gitignore b/tests/UnitTests/TemplateSource/StaticClass/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/StaticClass/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php new file mode 100644 index 00000000..1c671f15 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php @@ -0,0 +1,149 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test {append} tags + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestAppend + */ + public function testAppend($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Append_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->assertEquals($result, $this->smarty->fetch($file), "testAppend - {$code} - {$testName}"); + } + + /* + * Data provider für testAppend + */ + public function dataTestAppend() + { + $i = 0; + /* + * Code + * result + * test name + */ + return array(// old format + array('{$foo=1}{append var=foo value=2}{$foo|var_export:true}', var_export(array(0=>1,1=>2,),true), '', $i ++), + array('{$foo[\'i\']=1}{append var=foo value=2 index=\'j\'}{$foo|var_export:true}', var_export(array('i'=>1,'j'=>2,),true), '', $i ++), + array('{$bar=\'j\'}{$foo[\'i\']=1}{append var=foo value=2 index=$bar}{$foo|var_export:true}', var_export(array('i'=>1,'j'=>2,),true), '', $i ++), + array('{append var=foo value=2}{$foo|var_export:true}', var_export(array(0=>2,),true), '', $i ++), + array('{append foo value=3}{$foo|var_export:true}', var_export(array(0=>3,),true), '', $i ++), + array('{append foo 5}{$foo|var_export:true}', var_export(array(0=>5,),true), '', $i ++), // new format + array('{$foo[]=2}{$foo|var_export:true}', var_export(array(0=>2,),true), '', $i ++), + ); + } + + /** + * Test Assign spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAppendSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Append nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAppendSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Append nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAppendSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array("A{append var=buh value=\$foo}B{\$buh[0]}", "ABbar", 'Text', $i++), + array("A\n{append var=buh value=\$foo}\nB{\$buh[0]}", "A\nBbar", 'Newline1', $i++), + array("E{append var=buh value=\$foo}\nF{\$buh[0]}", "EFbar", 'Newline2', $i++), + array("G\n{append var=buh value=\$foo}H{\$buh[0]}", "G\nHbar", 'Newline3', $i++), + array("A{\$buh[]=\$foo}B{\$buh[0]}", "ABbar", '2_Text', $i++), + array("A\n{\$buh[]=\$foo}\nB{\$buh[0]}", "A\nBbar", '2_Newline1', $i++), + array("E{\$buh[]=\$foo}\nF{\$buh[0]}", "EFbar", '2_Newline2', $i++), + array("G\n{\$buh[]=\$foo}H{\$buh[0]}", "G\nHbar", '2_Newline3', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Append/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Append/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Append/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Append/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Append/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Append/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php new file mode 100644 index 00000000..b4301d59 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php @@ -0,0 +1,168 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test assign tags + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestAssign + */ + public function testAssign($code, $result, $testName, $testNumber) + { + $file = "Assign_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('bar', 'buh'); + $this->assertEquals($result, $this->smarty->fetch($file), "testAssign - {$code} - {$testName}"); + } + + /* + * Data provider für testAssign + */ + public function dataTestAssign() + { + $i = 1; + /* + * Code + * result + * test name + */ + return array(// old format + array('{assign var=foo value=1}{$foo}', '1', '', $i++), + array('{assign var=\'foo\' value=2}{$foo}', '2', '', $i++), + array('{assign var="foo" value=3}{$foo}', '3', '', $i++), + array('{assign var=foo value=$bar}{$foo}', 'buh', '', $i++), + array('{assign var=$bar value=11}{$buh}', '11', '', $i++), + array('{assign var=foo value=bar}{$foo}', 'bar', '', $i++), + array('{assign var=foo value=1+2}{$foo}', '3', '', $i++), + array('{assign var=foo value=strlen(\'barbuh\')}{$foo}', '6', '', $i++), + array('{assign var=foo value=\'barr\'|strlen}{$foo}', '4', '', $i++), + array('{assign var=foo value=[9,8,7,6]}{$foo|var_export:true}', + var_export(array(9, 8, 7, 6), true), '', $i++), + array( + '{assign var=foo value=[\'a\'=>9,\'b\'=>8,\'c\'=>7,\'d\'=>6]}{$foo|var_export:true}', + var_export(array('a' => 9, 'b' => 8, 'c' => 7, 'd' => 6,), true), '', $i++,), + array('{assign foo value=1}{$foo}', '1', '', $i++), + array('{assign foo 1}{$foo}', '1', '', $i++), + // new format + array('{$foo=1}{$foo}', '1', '', $i++), + array('{$foo =2}{$foo}', '2', '', $i++), + array('{$foo=bar}{$foo}', 'bar', '', $i++), + array('{$foo=1+2}{$foo}', '3', '', $i++), + array('{$foo = 1+3}{$foo}', '4', '', $i++), + array('{$foo = 1 + 4}{$foo}', '5', '', $i++), + array('{$foo=strlen(\'bar\')}{$foo}', '3', '', $i++), + array('{$foo=\'bar\'|strlen}{$foo}', '3', '', $i++), + array('{$foo[\'a\'][4]=1}{$foo[\'a\'][4]}', '1', '', $i++), + array('{$foo=[9,8,7,6]}{$foo|var_export:true}', var_export(array(9, 8, 7, 6), true), '', $i++), + array( + '{$foo=[\'a\'=>9,\'b\'=>8,\'c\'=>7,\'d\'=>6]}{$foo|var_export:true}', + var_export(array('a' => 9, 'b' => 8, 'c' => 7, 'd' => 6,), true), '', $i++), + ); + } + + /** + * Test Assign spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAssignSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAssignSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAssignSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array("A{assign var=buh value=\$foo}B{\$buh}", "ABbar", 'Text1', $i++), + array("A\n{assign var=buh value=\$foo}\nB{\$buh}", "A\nBbar", 'Newline1', $i++), + array("E{assign var=buh value=\$foo}\nF{\$buh}", "EFbar", 'Newline2', $i++), + array("G\n{assign var=buh value=\$foo}H{\$buh}", "G\nHbar", 'Newline3', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Assign/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignbar.tpl b/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignbar.tpl new file mode 100644 index 00000000..c0be3a40 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignbar.tpl @@ -0,0 +1 @@ +{$foo = $bar scope=global}{checkvar var=foo nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignnocache.tpl b/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignnocache.tpl new file mode 100644 index 00000000..4bde90af --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignnocache.tpl @@ -0,0 +1 @@ +{$foo = $buh scope=global nocache}{checkvar var=foo nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Assign/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Assign/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php new file mode 100644 index 00000000..c6a2eee4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php @@ -0,0 +1,531 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("./PHPunitplugins/"); + $this->smarty->disableSecurity(); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test block plugin tag + * + */ + public function testBlockPluginNoAssign() + { + $this->assertEquals("hello world", $this->smarty->fetch('no_assign.tpl')); + } + + /** + * test block plugin tag with assign attribute + * + */ + public function testBlockPluginAssign() + { + $this->assertEquals("hello world", $this->smarty->fetch('assign.tpl')); + } + + /** + * test unknown block plugin tag + * + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unknown tag 'bar' + * + */ + public function testBlockPluginUnknown() + { + $this->assertEquals("hello world", $this->smarty->fetch('unknown.tpl')); + } + + /** + * test block plugin function definition in script + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRegisteredFunction() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'blockplugintest', 'myblockplugintest'); + $this->assertEquals('block test', $this->smarty->fetch('registered.tpl')); + } + + /** + * test block plugin function definition in script + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @expectedException SmartyException + * @expectedExceptionMessage block tag 'blockplugintest' not callable + * + */ + public function testBlockPluginRegisteredFunction2() + { + $this->assertEquals('block test', $this->smarty->fetch('registered.tpl')); + } + + /** + * test block plugin static method + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRegisteredStatic() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'blockpluginstatic', array('myblockclass1', 'staticfunc')); + $this->assertEquals('static block test', $this->smarty->fetch('registered_static.tpl')); + } + + /** + * test block plugin static method failure + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @expectedException SmartyException + * @expectedExceptionMessage block tag 'blockpluginstatic' not callable + * + */ + public function testBlockPluginRegisteredStatic2() + { + $this->assertEquals('static block test', $this->smarty->fetch('registered_static.tpl')); + } + + /** + * test block plugin object method + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRegisteredMethod() + { + $object = new myblockclass1(); + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'blockpluginmethod', array($object, 'methodfunc')); + $this->assertEquals('method block test', $this->smarty->fetch('registered_method.tpl')); + } + + /** + * test block plugin object method failure + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @expectedException SmartyException + * @expectedExceptionMessage block tag 'blockpluginmethod' not callable + * + */ + public function testBlockPluginRegisteredMethod2() + { + $this->assertEquals('method block test', $this->smarty->fetch('registered_method.tpl')); + } + + /** + * test block plugin registered object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRegisteredObject() + { + $object = new myblockclass1(); + $this->smarty->registerObject('myobject', $object, array(), true, array('objectfunc')); + $this->assertEquals('object block test', $this->smarty->fetch('registered_object.tpl')); + } + + /** + * test block plugin registered object failure + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @expectedException SmartyException + * @expectedExceptionMessage block tag 'myobject' not callable + * + */ + public function testBlockPluginRegisteredObject2() + { + $this->assertEquals('object block test', $this->smarty->fetch('registered_object.tpl')); + } + + /** + * test block plugin repeat function + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRepeat() + { + $this->assertEquals('12345', $this->smarty->fetch('repeat.tpl')); + } + + /** + * test block plugin repeat function with modifier + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRepeatModidier1() + { + $this->assertEquals('11111', $this->smarty->fetch('repeat_modifier.tpl')); + } + + /** + * test block plugin repeat function with modifier list + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRepeatModidier2() + { + $this->assertEquals('11111', $this->smarty->fetch('repeat_modifier_2.tpl')); + } + + /** + * test block plugin with no output + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginNoOutput() + { + $this->assertEquals('default', $this->smarty->fetch('nooutput.tpl')); + } + + /** + * test nested block plugin + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginNested() + { + $this->assertEquals('hello world12345', $this->smarty->fetch('nested.tpl')); + } + + /** + * test default block plugin + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginDefault1() + { + $this->smarty->registerDefaultPluginHandler('my_block_plugin_handler'); + $this->assertEquals('scriptblock hello world', $this->smarty->fetch('default1.tpl')); + } + + /** + * test default block plugin + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginDefault2() + { + $this->smarty->registerDefaultPluginHandler('my_block_plugin_handler'); + $this->assertEquals('defaultblock hello world', $this->smarty->fetch('default2.tpl')); + } + + /** + * test tag stack + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginTagStack() + { + $this->assertEquals('noop-teststack', $this->smarty->fetch('tag_stack.tpl')); + $this->assertEmpty($this->smarty->_cache[ '_tag_stack' ]); + } + + /** + * Test caching + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + * + */ + public function testCache($isCached, + $caching, + $cachable, + $testNumber, + $compileTestNumber, + $renderTestNumber, + $resultNumber, + $nocache, + $compileid, + $testName) + { + $this->smarty->registerFilter('pre', array($this, 'prefilterTest')); + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'cachetest', 'myblockplugintest2', $cachable); + $this->smarty->compile_id = $compileid; + $this->smarty->caching = $caching; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('var', $testNumber, $nocache); + $tpl = $this->smarty->createTemplate('caching.tpl', null, null, $this->smarty); + if (isset($isCached)) { + $this->assertEquals($isCached, $tpl->isCached(), $testName . ' - isCached()'); + } + $result = $this->smarty->fetch($tpl); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", + $result, + $testName . ' - fetch() failure test number'); + $this->assertContains("block test{$resultNumber}", $result, $testName . ' - fetch() failure result'); + } + + public function data() + { + return array(array(false, false, false, 1, 1, 1, 1, false, 0, 'no cacheing'), + array(false, false, false, 2, 1, 2, 2, false, 0, 'no cacheing'), + array(false, false, true, 3, 3, 3, 3, false, 1, 'cacheable'), + array(false, true, true, 4, 4, 4, 4, false, 1, 'cachable Caching'), + array(true, true, true, 5, 4, 4, 4, false, 1, 'cachable isCached'), + array(true, true, true, 6, 4, 4, 4, false, 1, 'cachable isCached'), + array(false, true, false, 7, 7, 7, 7, false, 2, 'not cachable'), + array(true, true, false, 8, 7, 7, 8, false, 2, 'not cachable isCached'), + array(true, true, false, 9, 7, 7, 9, false, 2, 'not cachable isCached'), + array(false, true, true, 10, 10, 10, 10, true, 3, 'not cachable nocache var'), + array(true, true, true, 11, 10, 10, 11, true, 3, 'not cachable isCached'), + array(true, true, true, 12, 10, 10, 12, true, 3, 'not cachable isCached'),); + } + + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testSpacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{noop}\nB{/noop}C", "ABC", 'Newline1', $i++), + array("A{noop}\nB\n{/noop}C", "AB\nC", 'Newline2', $i++), + array("A{noop}\nB{/noop}\nC", "ABC", 'Newline3', $i++), + array("A\n{noop}\nB\n{/noop}\nC", "A\nB\nC", 'Newline4', $i++), + array("A{noop}\n{\$foo}{/noop}C", "AbarC", 'Var1', $i++), + array("A{noop}\n{\$foo}\n{/noop}C", "Abar\nC", 'Var2', $i++), + array("A{noop}\n{\$foo}{/noop}\nC", "AbarC", 'Var3', $i++), + array("A\n{noop}\n{\$foo}\n{/noop}\nC", "A\nbar\nC", 'Var4', $i++), + ); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestDefaultSpacing + * @runInSeparateProcess + */ + public function testSpacingDefault($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testSpacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->registerDefaultPluginHandler('my_block_plugin_handler'); + $this->smarty->compile_id='default'; + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestDefaultSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{scriptblock}\nB{/scriptblock}C", "Ascriptblock BC", 'Newline1', $i++), + array("A{scriptblock}\nB\n{/scriptblock}C", "Ascriptblock B\nC", 'Newline2', $i++), + array("A{scriptblock}\nB{/scriptblock}\nC", "Ascriptblock BC", 'Newline3', $i++), + array("A\n{scriptblock}\nB\n{/scriptblock}\nC", "A\nscriptblock B\nC", 'Newline4', $i++), + array("A{scriptblock}\n{\$foo}{/scriptblock}C", "Ascriptblock barC", 'Var1', $i++), + array("A{scriptblock}\n{\$foo}\n{/scriptblock}C", "Ascriptblock bar\nC", 'Var2', $i++), + array("A{scriptblock}\n{\$foo}{/scriptblock}\nC", "Ascriptblock barC", 'Var3', $i++), + array("A\n{scriptblock}\n{\$foo}\n{/scriptblock}\nC", "A\nscriptblock bar\nC", 'Var4', $i++), + ); + } + + /** + * Test nocache block spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestNocacheSpacing + * @runInSeparateProcess + */ + public function testBlockNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Nocache_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setCompileId('nocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('bar', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testNocache - {$file}"); + } + /** + * Test nocache block spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestNocacheSpacing + * @runInSeparateProcess + */ + public function testBlockNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Nocache_{$name}.tpl"; + $this->smarty->setCompileId('nocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('bar', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testNocache2 - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestNocacheSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{testparameter value=\$bar}\n{\$foo}{/testparameter}C", "AbarC", 'Var1', $i++), + array("A{testparameter value=\$bar}\n{\$foo}\n{/testparameter}C", "Abar\nC", 'Var2', $i++), + array("A{testparameter value=\$bar}\n{\$foo}{/testparameter}\nC", "AbarC", 'Var3', $i++), + array("A\n{testparameter value=\$bar}\n{\$foo}\n{/testparameter}\nC", "A\nbar\nC", 'Var4', $i++), + ); + } + +} +function myblockplugintest($params, $content, &$smarty_tpl, &$repeat) +{ + if (!$repeat) { + $output = str_replace('hello world', 'block test', $content); + + return $output; + } +} + +function myblockplugintest2($params, $content, &$smarty_tpl, &$repeat) +{ + if (!$repeat) { + $output = str_replace('hello world', "block test{$params['var']}", $content); + + return $output; + } +} + +class myblockclass1 +{ + static function staticfunc($params, $content, &$smarty_tpl, &$repeat) + { + if (!$repeat) { + $output = str_replace('hello world', 'static block test', $content); + return $output; + } + } + + public function methodfunc($params, $content, &$smarty_tpl, &$repeat) + { + if (!$repeat) { + $output = str_replace('hello world', 'method block test', $content); + return $output; + } + } + + public function objectfunc($params, $content, &$smarty_tpl, &$repeat) + { + if (!$repeat) { + $output = str_replace('hello world', 'object block test', $content); + return $output; + } + } +} + +function my_block_plugin_handler($tag, $type, $template, &$callback, &$script, &$cachable) +{ + switch ($type) { + case Smarty::PLUGIN_BLOCK: + switch ($tag) { + case 'scriptblock': + $script = './scripts/script_block_tag.php'; + $callback = 'default_script_block_tag'; + + return true; + default: + $script = './scripts/other_block_tag.php'; + $callback = 'default_block_tag'; + return true; + } + default: + return false; + } +} + diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.noop.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.noop.php new file mode 100644 index 00000000..0e163e59 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.noop.php @@ -0,0 +1,24 @@ +assign('foo', $params[ 'value' ]); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.teststack.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.teststack.php new file mode 100644 index 00000000..f1eef38d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.teststack.php @@ -0,0 +1,25 @@ +smarty->_cache['_tag_stack']; + return $stack[0][0] . '-' . $stack[1][0]; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/scripts/other_block_tag.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/scripts/other_block_tag.php new file mode 100644 index 00000000..29cf94b4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/scripts/other_block_tag.php @@ -0,0 +1,7 @@ +objectfunc}hello world{/myobject->objectfunc} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_static.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_static.tpl new file mode 100644 index 00000000..b9d83c83 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_static.tpl @@ -0,0 +1 @@ +{blockpluginstatic}hello world{/blockpluginstatic} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat.tpl new file mode 100644 index 00000000..32c39c0c --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat.tpl @@ -0,0 +1 @@ +{testblock}{/testblock} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier.tpl new file mode 100644 index 00000000..831c95a5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier.tpl @@ -0,0 +1 @@ +{testblock}{/testblock|strlen} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier_2.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier_2.tpl new file mode 100644 index 00000000..33031924 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier_2.tpl @@ -0,0 +1 @@ +{testblock}{/testblock|strlen|default:''} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/tag_stack.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/tag_stack.tpl new file mode 100644 index 00000000..6cbc1404 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/tag_stack.tpl @@ -0,0 +1 @@ +{noop}{teststack}{/teststack}{/noop} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/unknown.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/unknown.tpl new file mode 100644 index 00000000..d6820019 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/unknown.tpl @@ -0,0 +1 @@ +{bar}hello world{/bar} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php new file mode 100644 index 00000000..0f3eb406 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php @@ -0,0 +1,1382 @@ +setUpSmarty(dirname(__FILE__)); + //$this->smarty->setMergeCompiledIncludes(true); + } + + public function compiledPrefilter($text, Smarty_Internal_Template $tpl) + { + return str_replace('#', $tpl->getTemplateVars('test'), $text); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test block default outout + */ + public function testBlockDefault_000_1() + { + $result = $this->smarty->fetch('string:{block name=test}-- block default --{/block}'); + $this->assertEquals('-- block default --', $result); + } + + public function testBlockDefault_000_2() + { + $this->smarty->assign('foo', 'another'); + $result = $this->smarty->fetch('string:{block name=test}-- {$foo} block default --{/block}'); + $this->assertEquals('-- another block default --', $result); + } + + /** + * test just call of parent template, no blocks predefined + */ + public function testCompileBlockParent_001() + { + $this->smarty->assign('parent', 'parent'); + $result = $this->smarty->fetch('001_parent.tpl'); + $this->assertContains('(parent|b)content parent b(parent|/b)', $result); + } + + /** + * test child/parent template chain + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChild_002($caching, $merge, $testNumber, $compileTestNumber, $renderTestNumber, + $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('002_child.tpl'); + $this->assertContains('(child|b)content child b(child|/b)', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with prepend + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildPrepend_003($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('003_child.tpl'); + $this->assertContains('(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with prepend + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockGrandPrepend_003($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('003_grand.tpl'); + $this->assertContains('(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with apppend + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildAppend_004($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('004_child.tpl'); + $this->assertContains('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test grandchild/parent template chain with apppend + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockGrandAppend_004($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('004_grand.tpl'); + $this->assertContains('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)(grand|b)content grand b(grand|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test grandchild/parent template chain with apppend + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockGrandAppendPrepend_004($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('004_grand2.tpl'); + $this->assertContains('(parent|b)content parent b(parent|/b)(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(grand|b)content grand b(grand|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with apppend and shorttags + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildAppendShortag_005($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('005_child.tpl'); + $this->assertContains('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with {$this->smarty.block.child) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildSmartyChild_006($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('006_child.tpl'); + $this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with {$this->smarty.block.parent) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildSmartyParent_007($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('007_child.tpl'); + $this->assertContains('(child|b)content (parent|b)content parent b(parent|/b) b(child|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test grandchild/child/parent template chain with {$this->smarty.block.parent) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildSmartyParent_007_2($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('007_grand.tpl'); + $this->assertContains('(grand|b)content (child|b)content (parent|b)content parent b(parent|/b) b(child|/b) b(grand|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain loading plugin + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildPlugin_008($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('008_child.tpl'); + $this->assertContains('(child|b)content escaped <text> child 1 b(child|/b', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test parent template with nested blocks + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockParentNested_009($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('009_parent.tpl'); + $this->assertContains('(parent|b)content (parent|c)content parent c(parent|/c) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with nested block + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNested_010($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('010_child.tpl'); + $this->assertContains('(parent|b)content (parent|c)content child c(parent|/c) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with nested block and include + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNestedInclude_011($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('011_grand.tpl'); + $this->assertContains('(child|b)content(child|c)content(child|n)content(include)content child i(/include)n(child|/n)c(child|/c)(grand|c)content grand c(grand|\c)b(child|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test template chain with nested block level test + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNestedInclude_012($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('012_grandgrand.tpl'); + $this->assertContains('(grand|b)content (grandgrand|c)content c(grandgrand|\c)(grand|c)content c(grand|\c) b(grand|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test nested child block with hide + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNestedHide_018($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('018_child.tpl'); + $this->assertContains('(child|b)content(child|c)content child c(child|/c)b(child|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test nested grand/child block with hide + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNestedHide_018_2($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('018_grand.tpl'); + $this->assertContains('(child|b)content(child|c)content child c(child|/c)(child|d)content (grand|d)content grand d(grand|/d) d(child|/d)b(child|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test nested grandgrand/grand/child block with hide + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNestedHide_018_3($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('018_grandgrand.tpl'); + $this->assertContains('(child|b)content(grand|c)content (grandgrand|c)content grandgrand c(grandgrand|/c) c(grand|/c)(child|d)content (grandgrand|d)content grandgrand d(grandgrand|/d) d(child|/d)b(child|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain starting in subtempates + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockStartSubTemplates_020($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('020_include_root.tpl'); + $this->assertContains('(include1)(include1|p)content 1 p(include1|\p)(include1|b)content 1 b(include1|\b)(\include1)', + $result, $testName . ' - include 1'); + $this->assertContains('(include2)(include2|p)content 2 p(include2|\p)(include2|b)content 2 b(include2|\b)(\include2)', + $result, $testName . ' - include 1'); + $this->assertContains('(include3)(include3|p)content 3 p(include3|\p)(include3|b)content 3 b(include3|\b)(\include3)', + $result, $testName . ' - include 1'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test grandchild/child/parent dependency test1 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testCompileBlockGrandChildMustCompile_021_1() + { + $this->smarty->assign('parent', 'parent'); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)', + $result); + $this->smarty->_clearTemplateCache(); + $this->smarty->assign('parent', 'parent2'); + $this->smarty->assign('child', 'child2', true); + $this->smarty->assign('grand', 'grand2', true); + $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('(grand|b)content grand2 b(grand|/b)(child|b)content child2 b(child|/b)(parent|b)content parent b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test1 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testCompileBlockGrandChildMustCompile_021_12() + { + $this->smarty->setCompileDir('./templates_c/mustcompile'); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('parent', 'parent3'); + $this->smarty->assign('child', 'child3', true); + $this->smarty->assign('grand', 'grand3', true); + $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('(grand|b)content grand3 b(grand|/b)(child|b)content child3 b(child|/b)(parent|b)content parent b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test2 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_2() + { + $this->smarty->assign('parent', 'parent4'); + $this->smarty->assign('child', 'child4', true); + $this->smarty->assign('grand', 'grand4', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + sleep(2); + touch($this->smarty->getTemplateDir(0) . '021_grand.tpl'); + clearstatcache(); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('(grand|b)content grand4 b(grand|/b)(child|b)content child4 b(child|/b)(parent|b)content parent4 b(parent|/b)', + $result); + $this->smarty->_clearTemplateCache(); + $this->smarty->assign('parent', 'parent5'); + $this->smarty->assign('child', 'child5', true); + $this->smarty->assign('grand', 'grand5', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('(grand|b)content grand5 b(grand|/b)(child|b)content child5 b(child|/b)(parent|b)content parent4 b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test3 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_3() + { + $this->smarty->assign('parent', 'parent6'); + $this->smarty->assign('child', 'child6', true); + $this->smarty->assign('grand', 'grand6', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + sleep(2); + touch($this->smarty->getTemplateDir(0) . '021_child.tpl'); + clearstatcache(); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('(grand|b)content grand6 b(grand|/b)(child|b)content child6 b(child|/b)(parent|b)content parent6 b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test3 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_32() + { + $this->smarty->assign('parent', 'parent7'); + $this->smarty->assign('child', 'child7', true); + $this->smarty->assign('grand', 'grand7', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('(grand|b)content grand7 b(grand|/b)(child|b)content child7 b(child|/b)(parent|b)content parent6 b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test4 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testCompileBlockGrandChildMustCompile_021_4() + { + $this->smarty->assign('parent', 'parent8'); + $this->smarty->assign('child', 'child8', true); + $this->smarty->assign('grand', 'grand8', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + sleep(2); + touch($this->smarty->getTemplateDir(0) . '021_parent.tpl'); + clearstatcache(); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('(grand|b)content grand8 b(grand|/b)(child|b)content child8 b(child|/b)(parent|b)content parent8 b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test4 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testCompileBlockGrandChildMustCompile_021_42() + { + $this->smarty->assign('parent', 'parent9'); + $this->smarty->assign('child', 'child9', true); + $this->smarty->assign('grand', 'grand9', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('(grand|b)content grand9 b(grand|/b)(child|b)content child9 b(child|/b)(parent|b)content parent8 b(parent|/b)', + $result); + } + + /** + * test dirt in child templates + */ + public function testDirt_022() + { + $result = $this->smarty->fetch('022_child.tpl'); + $this->assertEquals('Page Title', $result); + } + + /** + * test {$this->smarty.block.child} for not existing child {block] + */ + public function testNotExistingChildBlock_024() + { + $result = $this->smarty->fetch('024_parent.tpl'); + $this->assertContains('no >< child', $result); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage '{$smarty.block.child}' used outside {block} tags + * test {$this->smarty.block.child} outside {block] + */ + public function testSmartyBlockChildOutsideBlock_025() + { + $this->smarty->fetch('025_parent.tpl'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage '{$smarty.block.parent}' used outside {block} tags + * test {$this->smarty.block.parent} outside {block] + */ + public function testSmartyBlockParentOutsideBlock_026() + { + $this->smarty->fetch('026_child.tpl'); + } + + /** + * @expectedException SmartyException + * @expectedExceptionMessage illegal '{$smarty.block.parent}' + * test {$this->smarty.block.parent} in parent template + */ + public function testSmartyBlockParentInParent_027() + { + $result = $this->smarty->fetch('027_parent.tpl'); + } + + /** + * test child/parent template chain + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testSmartyBlockVariablePartentInclude_28($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); + $this->smarty->setCompileId(10); + if ($merge) { + $this->smarty->setCompileId(11); + } + $this->smarty->assign('foo', '028_parent_include1.tpl'); + $result = $this->smarty->fetch('028_child.tpl'); + $this->assertContains('b1-include-1--b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain + * + * @dataProvider data + */ + public function testSmartyBlockVariablePartentInclude_282($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); + } + $this->smarty->assign('foo', '028_parent_include2.tpl'); + $result = $this->smarty->fetch('028_child.tpl'); + $this->assertContains('b1-child-i2-include-2--b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockGrandChildNested_030($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('030_grandchild_nested.tpl'); + $this->assertContains('child pre -grandchild content- child post', $result, $testName . ' - content'); + $this->assertContains('include:' . $testNumber, $result, $testName . ' - content 2'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockGrandChildNestedRelative_030($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('sub/030_grandchild_nested_rel.tpl'); + $this->assertContains('child pre -grandchild content- child post', $result, $testName . ' - content'); + $this->assertContains('include:' . $testNumber, $result, $testName . ' - content 2'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockParent_034_1($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('034_1child.tpl'); + $this->assertContains('parent b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockParent_034_2($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('034_2child.tpl'); + $this->assertContains('parent b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockParent_034_3($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('034_3child.tpl'); + $this->assertContains('parent b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockParent_034_4($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('034_4child.tpl'); + $this->assertContains('parent b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test child/parent template chain with {$this->smarty.block.child) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockChild_035_1($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parenttpl', '035_1parent.tpl'); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('035_child.tpl'); + $this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with {$this->smarty.block.child) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockChild_035_2($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parenttpl', '035_2parent.tpl'); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('035_child.tpl'); + $this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test child/parent template chain with {$this->smarty.block.child) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockChild_035_3($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parenttpl', '035_3parent.tpl'); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('035_child.tpl'); + $this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test child/parent template chain with {$this->smarty.block.child) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockChild_035_4($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parenttpl', '035_4parent.tpl'); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('035_child.tpl'); + $this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + + + public function data() + { + return array(/* + * caching + * merging + * test nr + * result compile nr + * result render nr + * text + */ + array(false, false, 1, 1, 1, 'no caching, no merge - new'), + array(false, false, 2, 1, 2, 'no caching, no merge - exits'), + array(true, false, 3, 3, 3, 'caching, no merge - new'), + array(true, false, 4, 3, 3, 'caching, no merge - exits'), + array(false, true, 5, 5, 5, 'no caching, merge - new'), + array(false, true, 6, 5, 6, 'no caching, merge - exits'), + array(true, true, 7, 7, 7, 'caching, merge - new'), + array(true, true, 8, 7, 7, 'caching, merge - exits'),); + } + + /* + * Test post filter on {block} + */ + public function testPostFilter_031() + { + function smarty_postfilter_test031($compiled, Smarty_Internal_Template $template) + { + return str_replace("'foo'", "'bar'", $compiled); + } + + $this->smarty->loadFilter('post', 'test031'); + $this->smarty->assign('foo', 'foo'); + $this->smarty->assign('bar', 'bar'); + $this->assertContains('bar', $this->smarty->fetch('031_post_filter.tpl')); + } + /* + * Test new inheritance root in outermost include + */ + public function testInclude_032() + { + $result = $this->smarty->fetch('032_child.tpl'); + $this->assertContains('foo in 032_child.tpl', $result); + $this->assertContains('bar in 032_included_child.tpl', $result); + $this->assertContains('foo in 032_included_parent.tpl', $result); + $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'); + } + /** + * + * test smarty.block.foo + * + * @expectedException SmartyCompilerException + * @expectedExceptionMessage $smarty.block is not defined + */ + public function testSmartyBlockWrongBlockName_036() + { + $this->smarty->fetch('036_parent.tpl'); + } + /** + * + * test '{$smarty.block.parent}' + * + * @expectedException SmartyException + * @expectedExceptionMessage inheritance: illegal '{$smarty.block.parent}' used in child template + */ + public function testSmartyParentBlockCalledInParent_036_1() + { + $this->smarty->fetch('036_1_parent.tpl'); + } + /** + * + * test {block_parent} + * + * @expectedException SmartyException + * @expectedExceptionMessage inheritance: illegal '{block_parent}' used in child template + */ + public function testSmartyParentBlockCalledInParent_036_2() + { + $this->smarty->fetch('036_2_parent.tpl'); + } + /** + * + * test {block_parent} + * + * @expectedException SmartyException + * @expectedExceptionMessage inheritance: illegal '{parent}' used in child template + */ + public function testSmartyParentBlockCalledInParent_036_3() + { + $this->smarty->fetch('036_3_parent.tpl'); + } + + /** + * + * test smarty.block + * + * @expectedException SmartyCompilerException + * @expectedExceptionMessage $smarty.block is not defined + */ + public function testSmartyBlockMissigBlockName_037() + { + $this->smarty->fetch('037_parent.tpl'); + } + + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testBlockSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('VarNocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testVarNocache - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testBlockSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('VarNocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testVarNocache1 - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{block name='a'}{\$foo}{/block}C", "AbarC", 'Var0', $i++), + array("A{block name='a'}\n{\$foo}{/block}C", "A\nbarC", 'Var1', $i++), + array("A{block name='a'}\n{\$foo}\n{/block}C", "A\nbar\nC", 'Var2', $i++), + array("A{block name='a'}\n{\$foo}{/block}\nC", "A\nbar\nC", 'Var3', $i++), + array("A\n{block name='a'}\n{\$foo}\n{/block}\nC", "A\n\nbar\n\nC", 'Var4', $i++), + ); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestChildSpacing + * @runInSeparateProcess + */ + public function testChildSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_Parent{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $child = "{extends file='$file'}\n"; + $child .= preg_replace(array('/A/','/C/','/[$]foo/','/\s*[{][$]smarty[.]block[.]child[}]\s*/'),array('G','H','$bar','{$bar}'),$code); + $file = "Spacing_Child{$name}.tpl"; + $this->makeTemplateFile($file, $child); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo'); + $this->smarty->assign('bar', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testChildSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestChildSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{block name='a'}{\$foo}{/block}C", "AbarC", 'Var0', $i++), + array("A{block name='a'}\n{\$foo}{/block}C", "A\nbarC", 'Var1', $i++), + array("A{block name='a'}\n{\$foo}\n{/block}C", "A\nbar\nC", 'Var2', $i++), + array("A{block name='a'}\n{\$foo}{/block}\nC", "A\nbar\nC", 'Var3', $i++), + array("A\n{block name='a'}\n{\$foo}\n{/block}\nC", "A\n\nbar\n\nC", 'Var4', $i++), + array("A{block name='a'}{\$smarty.block.child}{/block}C", "AbarC", 'BlockChild0', $i++), + array("A{block name='a'}\n{\$smarty.block.child}{/block}C", "A\nbarC", 'BlockChild1', $i++), + array("A{block name='a'}\n{\$smarty.block.child}\n{/block}C", "A\nbar\nC", 'BlockChild2', $i++), + array("A{block name='a'}\n{\$smarty.block.child}{/block}\nC", "A\nbar\nC", 'BlockChild3', $i++), + array("A\n{block name='a'}\n{\$smarty.block.child}\n{/block}\nC", "A\n\nbar\n\nC", 'BlockChild4', $i++), + ); + } + + /** + * Test Block nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestBlockNocache + * @runInSeparateProcess + */ + public function testBlockNocacheSpacing($code, $result, $name, $testNumber) + { + $file = "blockNocache_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setCompileId('BlockNocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "blockNocache - {$file}"); + } + /** + * Test Block nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestBlockNocache + * @runInSeparateProcess + */ + public function testBlockNocacheSpacing2($code, $result, $name, $testNumber) + { + $file = "blockNocache_{$name}.tpl"; + $this->smarty->setCompileId('BlockNocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo'); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "blockNocache - {$file}"); + } + /* + * Data provider für TestBlockNocache + */ + public function dataTestBlockNocache() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{nocache}{block name='a'}{\$foo}{/block}{/nocache}C", "AbarC", 'Var0', $i++), + array("A{nocache}{block name='a'}\n{\$foo}{/block}{/nocache}C", "A\nbarC", 'Var1', $i++), + array("A{nocache}{block name='a'}\n{\$foo}\n{/block}{/nocache}C", "A\nbar\nC", 'Var2', $i++), + array("A{nocache}{block name='a'}\n{\$foo}{/block}\n{/nocache}C", "A\nbar\nC", 'Var3', $i++), + array("A{nocache}\n{block name='a'}\n{\$foo}\n{/block}\n{/nocache}C", "A\n\nbar\n\nC", 'Var4', $i++), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BockExtend/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/001_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/001_parent.tpl new file mode 100644 index 00000000..9905f864 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/001_parent.tpl @@ -0,0 +1 @@ +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_child.tpl new file mode 100644 index 00000000..b17c2973 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_child.tpl @@ -0,0 +1,2 @@ +{extends file='002_parent.tpl'} +{block name='b'}(child|b)content {$child} b(child|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_parent.tpl new file mode 100644 index 00000000..07bb4259 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_child.tpl new file mode 100644 index 00000000..db178929 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_child.tpl @@ -0,0 +1,2 @@ +{extends file='003_parent.tpl'} +{block name='b' prepend}(child|b)content {$child} b(child|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_grand.tpl new file mode 100644 index 00000000..2a4cfa83 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_grand.tpl @@ -0,0 +1,2 @@ +{extends file='003_child.tpl'} +{block name='b' prepend}(grand|b)content {$grand} b(grand|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_parent.tpl new file mode 100644 index 00000000..36ae8965 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_parent.tpl @@ -0,0 +1,3 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} + diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_child.tpl new file mode 100644 index 00000000..f887fb2a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_child.tpl @@ -0,0 +1,2 @@ +{extends file='004_parent.tpl'} +{block name='b' append}(child|b)content {$child} b(child|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand.tpl new file mode 100644 index 00000000..5a15ef4c --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand.tpl @@ -0,0 +1,2 @@ +{extends file='004_child.tpl'} +{block name='b' append}(grand|b)content {$grand} b(grand|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand2.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand2.tpl new file mode 100644 index 00000000..adfa4c27 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand2.tpl @@ -0,0 +1,2 @@ +{extends file='004_child.tpl'} +{block name='b' append prepend}(grand|b)content {$grand} b(grand|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_parent.tpl new file mode 100644 index 00000000..07bb4259 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_child.tpl new file mode 100644 index 00000000..3d822c28 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_child.tpl @@ -0,0 +1,2 @@ +{extends '005_parent.tpl'} +{block 'b' append}(child|b)content {$child} b(child|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_parent.tpl new file mode 100644 index 00000000..093ed256 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block 'b'}(parent|b)content {$parent} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_child.tpl new file mode 100644 index 00000000..43a47504 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_child.tpl @@ -0,0 +1,2 @@ +{extends file='006_parent.tpl'} +{block name='b'}(child|b)content {$child} b(child|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_parent.tpl new file mode 100644 index 00000000..9774ebb4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$smarty.block.child} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_child.tpl new file mode 100644 index 00000000..4ac41f82 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_child.tpl @@ -0,0 +1,2 @@ +{extends file='007_parent.tpl'} +{block name='b'}(child|b)content {$smarty.block.parent} b(child|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_grand.tpl new file mode 100644 index 00000000..83dba9fe --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_grand.tpl @@ -0,0 +1,2 @@ +{extends file='007_child.tpl'} +{block name='b'}(grand|b)content {$smarty.block.parent} b(grand|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_parent.tpl new file mode 100644 index 00000000..602e45fe --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_child.tpl new file mode 100644 index 00000000..8f7312bd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_child.tpl @@ -0,0 +1,2 @@ +{extends file='008_parent.tpl'} +{block name='b'}(child|b)content {'escaped '|escape} {$child} {counter start=1} b(child|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_parent.tpl new file mode 100644 index 00000000..07bb4259 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/009_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/009_parent.tpl new file mode 100644 index 00000000..0323dde5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/009_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {block name='c'}(parent|c)content {$parent} c(parent|/c){/block} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_child.tpl new file mode 100644 index 00000000..9db0214e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_child.tpl @@ -0,0 +1,2 @@ +{extends file='010_parent.tpl'} +{block name='c'}(parent|c)content {$child} c(parent|/c){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_parent.tpl new file mode 100644 index 00000000..0323dde5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {block name='c'}(parent|c)content {$parent} c(parent|/c){/block} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_child.tpl new file mode 100644 index 00000000..98f3eb3d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_child.tpl @@ -0,0 +1,12 @@ +{extends file='011_parent.tpl'} +{strip} +{block name='b'}(child|b)content + {block name='c'}(child|c)content + {block name='n'}(child|n)content + {include file='011_include.tpl'} + n(child|/n) + {/block} + c(child|/c) + {/block} + b(child|/b) +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_grand.tpl new file mode 100644 index 00000000..a93a4143 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_grand.tpl @@ -0,0 +1,5 @@ +{extends file='011_child.tpl'} +{strip} +{block name='c' append} + (grand|c)content {$grand} c(grand|\c) +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_include.tpl new file mode 100644 index 00000000..704ca492 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_include.tpl @@ -0,0 +1 @@ +(include)content {$child} i(/include) \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_parent.tpl new file mode 100644 index 00000000..07bb4259 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_child.tpl new file mode 100644 index 00000000..6f95ae50 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_child.tpl @@ -0,0 +1,2 @@ +{extends file='012_parent.tpl'} +{block name='c' prepend}(child|c)content {$child} c(child|/c){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grand.tpl new file mode 100644 index 00000000..00b98f3a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grand.tpl @@ -0,0 +1,2 @@ +{extends file='012_child.tpl'} +{block name='b'}(grand|b)content {block name='c'}(grand|c)content c(grand|\c){/block} b(grand|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grandgrand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grandgrand.tpl new file mode 100644 index 00000000..1312dfc9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grandgrand.tpl @@ -0,0 +1,2 @@ +{extends file='012_grand.tpl'} +{block name='c' prepend}(grandgrand|c)content c(grandgrand|\c){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_parent.tpl new file mode 100644 index 00000000..602e45fe --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_child.tpl new file mode 100644 index 00000000..b0def3a7 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_child.tpl @@ -0,0 +1,9 @@ +{extends file="018_parent.tpl"} +{strip} +{block name='b'}(child|b)content + {block name='c'}(child|c)content child c(child|/c) + {/block} + {block name='d' hide}(child|d)content {$smarty.block.child} d(child|/d) + {/block} + b(child|/b) +{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grand.tpl new file mode 100644 index 00000000..867e317c --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grand.tpl @@ -0,0 +1,6 @@ +{extends file="018_child.tpl"} +{strip} +{block name='c' hide}(grand|c)content {$smarty.block.child} c(grand|/c) +{/block} +{block name='d'}(grand|d)content grand d(grand|/d) +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grandgrand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grandgrand.tpl new file mode 100644 index 00000000..fa7035fa --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grandgrand.tpl @@ -0,0 +1,6 @@ +{extends file="018_grand.tpl"} +{strip} +{block name='c'}(grandgrand|c)content grandgrand c(grandgrand|/c) +{/block} +{block name='d'}(grandgrand|d)content grandgrand d(grandgrand|/d) +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_parent.tpl new file mode 100644 index 00000000..4fa37768 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content parent b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_1.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_1.tpl new file mode 100644 index 00000000..be9a8b68 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_1.tpl @@ -0,0 +1,5 @@ +{extends file='020_include_parent.tpl'} + +{block name="p"}(include1|p)content 1 p(include1|\p){/block} + +{block name="b"}(include1|b)content 1 b(include1|\b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_2.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_2.tpl new file mode 100644 index 00000000..ffa41c6c --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_2.tpl @@ -0,0 +1,5 @@ +{extends file='020_include_parent.tpl'} + +{block name="p"}(include2|p)content 2 p(include2|\p){/block} + +{block name="b"}(include2|b)content 2 b(include2|\b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_3.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_3.tpl new file mode 100644 index 00000000..629e2cac --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_3.tpl @@ -0,0 +1,5 @@ +{extends file='020_include_parent.tpl'} + +{block name="p"}(include3|p)content 3 p(include3|\p){/block} + +{block name="b"}(include3|b)content 3 b(include3|\b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_parent.tpl new file mode 100644 index 00000000..c9a605b9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_parent.tpl @@ -0,0 +1,5 @@ +{strip} +{block name="p"} {/block} +{block name='dummy'} + {include file='020_include_subtemplate.tpl'} +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_root.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_root.tpl new file mode 100644 index 00000000..2090d4b1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_root.tpl @@ -0,0 +1,5 @@ +test:{$test nocache} compiled:# rendered:{$test} +(include1){include file='020_include_1.tpl'}(\include1) +(include2){include file='020_include_2.tpl'}(\include2) +(include3){include file='020_include_3.tpl'}(\include3) + diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_subtemplate.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_subtemplate.tpl new file mode 100644 index 00000000..21a4d317 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_subtemplate.tpl @@ -0,0 +1 @@ +{block name="b"}-dummy-{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_child.tpl new file mode 100644 index 00000000..9c1dcc09 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_child.tpl @@ -0,0 +1,2 @@ +{extends file='021_parent.tpl'} +{block name='b' prepend}(child|b)content {$child} b(child|/b){/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_grand.tpl new file mode 100644 index 00000000..7182c6df --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_grand.tpl @@ -0,0 +1,2 @@ +{extends file='021_child.tpl'} +{block name='b' prepend}(grand|b)content {$grand} b(grand|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_parent.tpl new file mode 100644 index 00000000..70ed9c0a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_parent.tpl @@ -0,0 +1 @@ +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_child.tpl new file mode 100644 index 00000000..305d805b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_child.tpl @@ -0,0 +1,4 @@ +{extends file='022_parent.tpl'} +{block name='title'}Page Title{/block} + + diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_parent.tpl new file mode 100644 index 00000000..b5ba7602 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_parent.tpl @@ -0,0 +1 @@ +{block name='title'}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_child.tpl new file mode 100644 index 00000000..69f554f9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_child.tpl @@ -0,0 +1,8 @@ +{extends file="023_parent.tpl"} +{strip} + {block name="strip"} +
+ Demo +
+ {/block} +{/strip} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_parent.tpl new file mode 100644 index 00000000..028e456f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_parent.tpl @@ -0,0 +1,9 @@ +{strip} + +{/strip} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/024_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/024_parent.tpl new file mode 100644 index 00000000..ba6d010b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/024_parent.tpl @@ -0,0 +1 @@ +{block 'b1'}no >{$smarty.block.child}< child{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/025_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/025_parent.tpl new file mode 100644 index 00000000..345cff01 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/025_parent.tpl @@ -0,0 +1 @@ +{$smarty.block.child}{block 'b1'}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_child.tpl new file mode 100644 index 00000000..88cbbe41 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_child.tpl @@ -0,0 +1,2 @@ +{extends '026_parent.tpl'} +{$smarty.block.parent}{block 'b1'}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_parent.tpl new file mode 100644 index 00000000..d046a177 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_parent.tpl @@ -0,0 +1 @@ +{$smarty.block.parent}{block 'b1'}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/027_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/027_parent.tpl new file mode 100644 index 00000000..580bc737 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/027_parent.tpl @@ -0,0 +1 @@ +{block 'b1'}this {$smarty.block.parent} is illegal{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_child.tpl new file mode 100644 index 00000000..ccfca614 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_child.tpl @@ -0,0 +1,4 @@ +{extends '028_parent.tpl'} +{block 'i2'}-i2-{/block} +{block 'n1'}-1-{/block} +{block 'n2'}-2-{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent.tpl new file mode 100644 index 00000000..1d8cee2f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block 'b1'}b1-{include $foo}-b1{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include1.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include1.tpl new file mode 100644 index 00000000..0e21a57d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include1.tpl @@ -0,0 +1 @@ +{block 'i1'}include{block 'n1'}{/block}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include2.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include2.tpl new file mode 100644 index 00000000..27ce8563 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include2.tpl @@ -0,0 +1 @@ +{block 'i2'}child{$smarty.block.child}include{block 'n2'}{/block}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_child.tpl new file mode 100644 index 00000000..671c92cc --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_child.tpl @@ -0,0 +1,4 @@ +{extends $foo} + +{block 'p2'}2{/block} +{block 'p1'}1{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent.tpl new file mode 100644 index 00000000..cd6579dc --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent.tpl @@ -0,0 +1 @@ +{block 'b1'}parent{block 'p1'}{/block}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent2.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent2.tpl new file mode 100644 index 00000000..4ec5d97f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent2.tpl @@ -0,0 +1 @@ +{block 'b1'}parent{block 'p2'}{/block}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child.tpl new file mode 100644 index 00000000..9f9a8c35 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child.tpl @@ -0,0 +1,23 @@ +{extends '030_parent.tpl'} +{strip} +{block 'b3'} + [b3 child b3={$b3} b3] +{/block} +{block 'b4'} + [b4 child b4={$b4} block.child={$smarty.block.child} b4] +{/block} +{block 'b5' nocache} + [b5-nocache child b5={$b5} block.child={$smarty.block.child} b5-nocache] +{/block} +{block 'b61'} + [b61 child b6={$b6} include={include '030_include.tpl'} b61] +{/block} +{block 'b62' nocache} + [b62-nocache child b6={$b6} include={include '030_include.tpl'} b62-nocache] +{/block} +{block 'b63'} + [b63 child b6={$b6} include_2={include '030_include_2.tpl'} b63] +{/block} +{block 'b64'} + [b64 child b6={$b6} include-nocache={include '030_include.tpl' nocache} b64] +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child_nested.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child_nested.tpl new file mode 100644 index 00000000..92d60419 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child_nested.tpl @@ -0,0 +1,6 @@ +{extends file='030_parent.tpl'} +{block name='content1'} + {block name='content2'} + child pre {$smarty.block.child} child post {include file='030_include.tpl' nocache} + {/block} +{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild.tpl new file mode 100644 index 00000000..2fba50d6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild.tpl @@ -0,0 +1,14 @@ +{extends '030_child.tpl'} +{strip} +{block 'b3'} + [b3 grandchild b3={$b3} include={include '030_include.tpl'} b3] +{/block} +{block 'b4' nocache} + [b4-nocache grandchild b4={$b4} b4-nocache] +{/block} +{block 'b5'} + [b5 grandchild b5={$b5} b5] +{/block} +{block 'b6'} + [b6 grandchild b6={$b6} b6] +{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild_nested.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild_nested.tpl new file mode 100644 index 00000000..8e219545 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild_nested.tpl @@ -0,0 +1,2 @@ +{extends file='030_child_nested.tpl'} +{block name='content2'}-grandchild content-{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include.tpl new file mode 100644 index 00000000..a2848d8e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include.tpl @@ -0,0 +1 @@ +include:{$test nocache} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include_2.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include_2.tpl new file mode 100644 index 00000000..b3738594 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include_2.tpl @@ -0,0 +1,6 @@ +{strip} +[include_2 +{block 'b6' nocache} + [b6-nocache include_2 b6={$b6} b6-nocache] +{/block} +include_2] \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_parent.tpl new file mode 100644 index 00000000..70c36693 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='content1'}Default content{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/031_post_filter.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/031_post_filter.tpl new file mode 100644 index 00000000..bfbcb272 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/031_post_filter.tpl @@ -0,0 +1 @@ +{block name='title'}{$foo}{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_child.tpl new file mode 100644 index 00000000..9ec7d00b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_child.tpl @@ -0,0 +1,3 @@ +{extends "032_parent.tpl"} + +{block "foo"}foo in 032_child.tpl{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_child.tpl new file mode 100644 index 00000000..471ec2a6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_child.tpl @@ -0,0 +1,3 @@ +{extends file="032_included_parent.tpl"} + +{block "bar"}bar in 032_included_child.tpl{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_parent.tpl new file mode 100644 index 00000000..db12e3c6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_parent.tpl @@ -0,0 +1,2 @@ +{block "bar"}bar in 032_included_parent.tpl{/block} +{block "foo"}foo in 032_included_parent.tpl{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_parent.tpl new file mode 100644 index 00000000..f55f6e7a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_parent.tpl @@ -0,0 +1,2 @@ +{include file="032_included_child.tpl"} +{block "foo"}foo in 032_parent.tpl{/block} \ No newline at end of file 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/034_1child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_1child.tpl new file mode 100644 index 00000000..58501aec --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_1child.tpl @@ -0,0 +1,2 @@ +{extends '034_parent.tpl'} +{block 'b1'}{$smarty.block.parent}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_2child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_2child.tpl new file mode 100644 index 00000000..07ff346b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_2child.tpl @@ -0,0 +1,2 @@ +{extends '034_parent.tpl'} +{block 'b1'}{parent assign='foo'}{$foo}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_3child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_3child.tpl new file mode 100644 index 00000000..a4e701b0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_3child.tpl @@ -0,0 +1,2 @@ +{extends '034_parent.tpl'} +{block 'b1'}{parent}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_4child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_4child.tpl new file mode 100644 index 00000000..431145fd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_4child.tpl @@ -0,0 +1,2 @@ +{extends '034_parent.tpl'} +{block 'b1'}{block_parent}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_parent.tpl new file mode 100644 index 00000000..1f3bc7f5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block 'b1'}parent b1{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_1parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_1parent.tpl new file mode 100644 index 00000000..9774ebb4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_1parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$smarty.block.child} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_2parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_2parent.tpl new file mode 100644 index 00000000..06fed627 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_2parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {child assign='foo'}{$foo} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_3parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_3parent.tpl new file mode 100644 index 00000000..1ada9dfa --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_3parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {child} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_4parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_4parent.tpl new file mode 100644 index 00000000..9cea0612 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_4parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {block_child} b(parent|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_child.tpl new file mode 100644 index 00000000..d0435049 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_child.tpl @@ -0,0 +1,2 @@ +{extends file=$parenttpl} +{block name='b'}(child|b)content {$child} b(child|/b){/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_1_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_1_parent.tpl new file mode 100644 index 00000000..b1432cf2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_1_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{$smarty.block.parent}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_2_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_2_parent.tpl new file mode 100644 index 00000000..f96cb679 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_2_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{block_parent}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_3_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_3_parent.tpl new file mode 100644 index 00000000..6c8516f2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_3_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{parent}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_parent.tpl new file mode 100644 index 00000000..8e3ed9da --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{$smarty.block.foo}{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/037_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/037_parent.tpl new file mode 100644 index 00000000..96a2a583 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/037_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{$smarty.block}{/block} \ No newline at end of file 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/helloworld.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/helloworld.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/helloworld.tpl @@ -0,0 +1 @@ +hello world \ 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 diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_child_nested_rel.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_child_nested_rel.tpl new file mode 100644 index 00000000..7a56aa37 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_child_nested_rel.tpl @@ -0,0 +1,6 @@ +{extends file='../030_parent.tpl'} +{block name='content1'} + {block name='content2'} + child pre {$smarty.block.child} child post {include file='../030_include.tpl' nocache} + {/block} +{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_grandchild_nested_rel.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_grandchild_nested_rel.tpl new file mode 100644 index 00000000..79060995 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_grandchild_nested_rel.tpl @@ -0,0 +1,2 @@ +{extends file='./030_child_nested_rel.tpl'} +{block name='content2'}-grandchild content-{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/mustcompile/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/mustcompile/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/mustcompile/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/CompileCaptureTest.php b/tests/UnitTests/TemplateSource/TagTests/Capture/CompileCaptureTest.php new file mode 100644 index 00000000..b76b5f7d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/CompileCaptureTest.php @@ -0,0 +1,149 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test capture tags + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestCapture + */ + public function testCapture($code, $result, $testName, $testNumber) + { + $file = "testCapture{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->assertEquals($result, $this->smarty->fetch($file), "testCapture - {$code} - {$testName}"); + } + + /* + * Data provider für testCapture + */ + public function dataTestCapture() + { + $i = 1; + /* + * Code + * result + * test name + */ + return array(// old format + array('{assign var=foo value=bar}{capture assign=foo}hello world{/capture}{$foo}', 'hello world', '', $i ++), + array('{capture name=foo}hello world{/capture}{$smarty.capture.foo}', 'hello world', '', $i ++), + array('{capture name=foo assign=bar}hello world{/capture}{$smarty.capture.foo} {$bar}', 'hello world hello world', '', $i ++), + array('{capture}hello world{/capture}{$smarty.capture.default}', 'hello world', '', $i ++), + array('{capture short}hello shorttag{/capture}{$smarty.capture.short}', 'hello shorttag', '', $i ++), + array('{capture append=foo}hello{/capture}bar{capture append=foo}world{/capture}{foreach $foo item} {$item@key} {$item}{/foreach}', 'bar 0 hello 1 world', '', $i ++), + array('{capture assign=foo}hello {capture assign=bar}this is my {/capture}world{/capture}{$foo} {$bar}', 'hello world this is my ', '', $i ++), + array('{capture name=foo}hello world{/capture}{capture name=Foo}Smarty 3{/capture}{$smarty.capture.foo} {$smarty.capture.Foo}', 'hello world Smarty 3', '', $i ++), + ); + } + /* + * Test that capture results are global + */ + public function testCapture9() + { + $result = $this->smarty->fetch('009_capture.tpl'); + $this->assertContains('-->hello world<--', $result); + $this->assertContains('-->hello world2<--', $result); + } + + public function testCompileCaptureNocache1() + { + $this->smarty->assign('foo', 1); + $this->smarty->caching = 1; + $this->assertContains('foo 1', $this->smarty->fetch('test_capture_nocache.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileCaptureNocache2() + { + $this->smarty->assign('foo', 2); + $this->smarty->caching = 1; + $this->assertTrue($this->smarty->isCached('test_capture_nocache.tpl')); + $this->assertContains('foo 2', $this->smarty->fetch('test_capture_nocache.tpl')); + } + /* + * Test capture buffer names with uppercase + */ + public function testCapture10() + { + $result = $this->smarty->fetch('010_capture.tpl'); + $this->assertContains('lowercase', $result); + $this->assertContains('uppercase', $result); + } + + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "Spacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{capture}B{/capture}C{\$smarty.capture.default}", "ACB", 'Newline1', $i++), + array("A{capture}\nB{/capture}C{\$smarty.capture.default}", "ACB", 'Newline2', $i++), + array("A{capture}B\n{/capture}C{\$smarty.capture.default}", "ACB\n", 'Newline3', $i++), + array("A\n{capture}\nB\n{/capture}C{\$smarty.capture.default}", "A\nCB\n", 'Newline4', $i++), + array("{capture}B{/capture}A{\$smarty.capture.default}C", "ABC", 'Newline5', $i++), + array("{capture}B{/capture}A\n{\$smarty.capture.default}C", "A\nBC", 'Newline6', $i++), + array("{capture}B{/capture}A{\$smarty.capture.default}\nC", "AB\nC", 'Newline7', $i++), + array("{capture}B{/capture}A\n{\$smarty.capture.default}\nC", "A\nB\nC", 'Newline8', $i++), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Capture/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture.tpl b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture.tpl new file mode 100644 index 00000000..00c7fecf --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture.tpl @@ -0,0 +1,3 @@ +{capture name='test'}hello world{/capture} +{include '009_capture_include.tpl'} +-->{$smarty.capture.test2}<-- \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture_include.tpl b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture_include.tpl new file mode 100644 index 00000000..b37f029a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture_include.tpl @@ -0,0 +1,2 @@ +-->{$smarty.capture.test}<-- +{capture name='test2'}hello world2{/capture} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates/010_capture.tpl b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/010_capture.tpl new file mode 100644 index 00000000..56bc97cf --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/010_capture.tpl @@ -0,0 +1,4 @@ +{capture name='testname'}lowercase{/capture} +{capture name='testName'}uppercase{/capture} +{$smarty.capture.testname} +{$smarty.capture.testName} diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates/test_capture_nocache.tpl b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/test_capture_nocache.tpl new file mode 100644 index 00000000..f34f731a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/test_capture_nocache.tpl @@ -0,0 +1,2 @@ +{capture assign=bar nocache}foo {$foo}{/capture} +{$bar nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Capture/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Capture/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/CompilerPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/CompilerPluginTest.php new file mode 100644 index 00000000..eca3d1a3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/CompilerPluginTest.php @@ -0,0 +1,36 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test compiler plugin + */ + public function testCompilerPlugin() + { + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->assertEquals('test output', $this->smarty->fetch('eval:{test data="test output"}{/test}')); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php new file mode 100644 index 00000000..615e0413 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php @@ -0,0 +1,28 @@ +required_attributes = array('data'); + + $_attr = $this->getAttributes($compiler, $args); + + $this->openTag($compiler, 'test'); + + return ""; + } +} + +// compiler.testclose.php +class smarty_compiler_testclose extends Smarty_Internal_CompileBase +{ + public function compile($args, $compiler) + { + + $this->closeTag($compiler, 'test'); + + return ''; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.testclose.php b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.testclose.php new file mode 100644 index 00000000..bd751f06 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.testclose.php @@ -0,0 +1,13 @@ +closeTag($compiler, 'test'); + + return ''; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php new file mode 100644 index 00000000..50a8a321 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php @@ -0,0 +1,172 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + /** + * empty template_c and cache folders + */ + public function testInit() + { + $this->cleanDirs(); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test {load_config} loading section2 + */ + public function testConfigVariableSection2Template_001() + { + $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('001_section2.tpl')); + } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test {load_config} loading section2 + */ + public function testConfigVariableSection2Template_0012() + { + $this->smarty->caching = true; + $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('001_section2.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test {load_config} loading section2 + */ + public function testConfigVariableInclude_003() + { + $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('003_section2.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test {load_config} loading section2 shorttags + */ + public function testConfigVariableSection2TemplateShorttags() + { + $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('002_section2.tpl')); + } + + /** + * test config varibales loading all sections from template + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableAllSectionsTemplate_004() + { + $this->smarty->setConfigOverwrite(true); + $this->assertEquals("Welcome to Smarty! Global Section1 Global Section2", $this->smarty->fetch('004_allsection.tpl')); + } + + /** + * test config varibales overwrite + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableOverwrite_005() + { + $this->assertEquals("Overwrite2", $this->smarty->fetch('005_overwrite.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableOverwrite_006() + { + $this->assertEquals("Welcome to Smarty! Overwrite3", $this->smarty->fetch('006_overwrite.tpl')); + } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableOverwrite_0061() + { + $this->smarty->configLoad('test.conf', 'default'); + $this->smarty->configLoad('test2.conf', 'default'); + $this->assertEquals('Welcome to overwrite test! this overwitten', $this->smarty->fetch('0061_overwrite.tpl')); + } + + /** + * test config varibales overwrite false + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableOverwrite_007() + { + $this->smarty->setConfigOverwrite(false); + $this->assertEquals("Overwrite1 Overwrite2 Overwrite3 ", $this->smarty->fetch('007_overwrite.tpl')); + } + + /** + * test config varibales booleanize on + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableBooleanizeOn_008() + { + $this->smarty->setConfigBooleanize(true); + $this->smarty->assign('expected', true); + $this->assertEquals("passed", $this->smarty->fetch('008_booleanize.tpl')); + } + + /** + * test config varibales booleanize off + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableBooleanizeOff_008() + { + $this->smarty->setConfigBooleanize(false); + $this->smarty->assign('expected', 'on'); + $this->assertEquals("passed", $this->smarty->fetch('008_booleanize.tpl')); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage Syntax error in config file + * test config file syntax error + */ + public function testConfigSyntaxError_009() + { + $this->smarty->fetch('009_error.tpl'); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/data.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/data.conf new file mode 100644 index 00000000..c9349c71 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/data.conf @@ -0,0 +1 @@ +foo = data diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/smarty.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/smarty.conf new file mode 100644 index 00000000..d65d1fd0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/smarty.conf @@ -0,0 +1 @@ +foo = smarty diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/template.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/template.conf new file mode 100644 index 00000000..303000d4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/template.conf @@ -0,0 +1 @@ +foo = newvar diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test.conf new file mode 100644 index 00000000..cd5cd4dd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test.conf @@ -0,0 +1,53 @@ +title = Welcome to Smarty! + +overwrite = Overwrite1 +overwrite = Overwrite2 + +booleanon = on + +Intro = """This is a value that spans more + than one line. you must enclose + it in triple quotes.""" + +Number = 123.4 + +text = 123bvc + +line = 123 This is a line + +sec1 = Global Section1 + +sec2 = Global Section2 + +sec = Global char +[/] +sec = special char + +[foo/bar] +sec = section foo/bar + +[section1] +sec1 = Hello Section1 + +[default] +title = Welcome to overwrite test! +over = shall not show + +[section2] +sec2 = 'Hello Section2' + +[.hidden] +hiddentext = Hidden Section + +#Comment +# Comment with a space first line first + #Comment line starting with space + # Space before and after # +#The line below only contains a # +# +# +# title = This is not the correct title + +#[section1] +#sec1 = Wrong text + diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test2.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test2.conf new file mode 100644 index 00000000..94f31bc4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test2.conf @@ -0,0 +1,5 @@ + +overwrite = Overwrite3 + +[default] +over = this overwitten \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test_error.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test_error.conf new file mode 100644 index 00000000..586e0c75 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test_error.conf @@ -0,0 +1,15 @@ +title = Welcome to Smarty! + +overwrite = Overwrite1 +overwrite = Overwrite2 + +[section1=]] +# Here is an error +sec1 = "Hello Section1" + +[section2] +sec2 = 'Hello Section2' + +[.hidden] +hiddentext = Hidden Section + diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/001_section2.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/001_section2.tpl new file mode 100644 index 00000000..c8c7baf9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/001_section2.tpl @@ -0,0 +1 @@ +{config_load file='test.conf' section='section2'}{#title#} {#sec1#} {#sec2#} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/002_section2.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/002_section2.tpl new file mode 100644 index 00000000..3de3b450 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/002_section2.tpl @@ -0,0 +1 @@ +{config_load 'test.conf' 'section2'}{#title#} {#sec1#} {#sec2#} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_include.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_include.tpl new file mode 100644 index 00000000..694aecb5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_include.tpl @@ -0,0 +1 @@ +{#sec2#} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_section2.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_section2.tpl new file mode 100644 index 00000000..8155c48f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_section2.tpl @@ -0,0 +1 @@ +{config_load file='test.conf' section='section2'}{#title#} {#sec1#} {include '003_include.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/004_allsection.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/004_allsection.tpl new file mode 100644 index 00000000..bb3a8783 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/004_allsection.tpl @@ -0,0 +1 @@ +{config_load 'test.conf'}{#title#} {#sec1#} {#sec2#} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/005_overwrite.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/005_overwrite.tpl new file mode 100644 index 00000000..d58fcdb4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/005_overwrite.tpl @@ -0,0 +1 @@ +{config_load 'test.conf'}{#overwrite#} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/0061_overwrite.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/0061_overwrite.tpl new file mode 100644 index 00000000..e82e5c74 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/0061_overwrite.tpl @@ -0,0 +1 @@ +{#title#} {#over#} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/006_overwrite.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/006_overwrite.tpl new file mode 100644 index 00000000..5f5abfbf --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/006_overwrite.tpl @@ -0,0 +1 @@ +{config_load 'test.conf'}{config_load 'test2.conf'}{#title#} {#overwrite#} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/007_overwrite.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/007_overwrite.tpl new file mode 100644 index 00000000..093ea298 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/007_overwrite.tpl @@ -0,0 +1 @@ +{config_load 'test.conf'}{config_load 'test2.conf'}{foreach #overwrite# as $over}{$over} {/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/008_booleanize.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/008_booleanize.tpl new file mode 100644 index 00000000..bc59712f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/008_booleanize.tpl @@ -0,0 +1 @@ +{config_load 'test.conf'}{if #booleanon# === $expected}passed{/if} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/009_error.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/009_error.tpl new file mode 100644 index 00000000..e97c16b6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/009_error.tpl @@ -0,0 +1 @@ +{config_load 'test_error.conf'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Delimiter/CompileDelimiterTest.php b/tests/UnitTests/TemplateSource/TagTests/Delimiter/CompileDelimiterTest.php new file mode 100644 index 00000000..16ae980f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Delimiter/CompileDelimiterTest.php @@ -0,0 +1,55 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test delimiter tag test + */ + public function testLeftDelimiter() + { + $tpl = $this->smarty->createTemplate('string:x{ldelim}x'); + $this->assertEquals('x{x', $this->smarty->fetch($tpl)); + } + + public function testRightDelimiter() + { + $tpl = $this->smarty->createTemplate('string:x{rdelim}x'); + $this->assertEquals('x}x', $this->smarty->fetch($tpl)); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage nocache option not allowed + */ + public function testLeftDelimiterError() + { + $tpl = $this->smarty->createTemplate('string:x{ldelim nocache}x'); + $this->assertEquals('x{x', $this->smarty->fetch($tpl)); + } + + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Delimiter/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Delimiter/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Delimiter/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Delimiter/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Delimiter/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Delimiter/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Eval/CompileEvalTest.php b/tests/UnitTests/TemplateSource/TagTests/Eval/CompileEvalTest.php new file mode 100644 index 00000000..5053e42d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Eval/CompileEvalTest.php @@ -0,0 +1,48 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test eval tag + */ + public function testEval1() + { + $tpl = $this->smarty->createTemplate("string:{eval var='hello world'}"); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + public function testEval2() + { + $tpl = $this->smarty->createTemplate("string:{eval var='hello world' assign=foo}{\$foo}"); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + public function testEval3() + { + $tpl = $this->smarty->createTemplate("string:{eval var='hello world' assign=foo}"); + $this->assertEquals("", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Eval/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Eval/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Eval/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Eval/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Eval/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Eval/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/For/CompileForTest.php b/tests/UnitTests/TemplateSource/TagTests/For/CompileForTest.php new file mode 100644 index 00000000..0a1c5d9d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/For/CompileForTest.php @@ -0,0 +1,200 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test For + * + * @preserveGlobalState disabled + * @dataProvider dataTestFor + * @runInSeparateProcess + */ + public function testFor($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "For_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testFor + */ + public function dataTestFor() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array('{for $x=0;$x<10;$x++}{$x}{/for}', '0123456789', 'T1', $i++), + array('{for $x=0; $x<10; $x++}{$x}{forelse}else{/for}', '0123456789', 'T2', $i++), + array('{for $x=10;$x<10;$x++}{$x}{forelse}else{/for}', 'else', 'T3', $i++), + array('{for $x=9;$x>=0;$x--}{$x}{forelse}else{/for}', '9876543210', 'T4', $i++), + array('{for $x=-1;$x>=0;$x--}{$x}{forelse}else{/for}', 'else', 'T5', $i++), + array('{for $x=0,$y=10;$x<$y;$x++}{$x}{forelse}else{/for}', '0123456789', 'T6', $i++), + array('{for $x=0;$x<10;$x=$x+2}{$x}{/for}', '02468', 'T7', $i++), + array('{for $x=0 to 8}{$x}{/for}', '012345678', 'T8', $i++), + array('{for $x=0 to 8 step=2}{$x}{/for}', '02468', 'T9', $i++), + array('{for $x=0 to 8 step=2}{if $x@first}{$x} {$x@total}{/if}{/for}', '0 5', 'T10', $i++), + array('{for $x=0 to 8 step=2}{if $x@last}{$x} {$x@iteration}{/if}{/for}', '8 5', 'T11', $i++), + array('{for $x=8 to 0 step=-2}{$x}{/for}', '86420', 'T12', $i++), + array('{for $x=8 to 0 step=2}{$x}{forelse}step error{/for}', 'step error', 'T13', $i++), + array('{for $x=8 to 0 step -1 max=3}{$x}{/for}', '876', 'T14', $i++), + ); + } + + + + /* + * test for and nocache + */ + public function testForNocacheVar1() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 5}{$x} {/for}'); + $tpl->assign('foo', 1, true); + $this->assertFalse($this->smarty->isCached($tpl)); + $this->assertEquals("1 2 3 4 5 ", $this->smarty->fetch($tpl)); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForNocacheVar2() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 5}{$x} {/for}'); + $tpl->assign('foo', 4, true); + $this->assertTrue($this->smarty->isCached($tpl)); + $this->assertEquals("4 5 ", $this->smarty->fetch($tpl)); + } + + public function testForNocacheTag1() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 5 nocache}{$x} {/for}'); + $tpl->assign('foo', 1); + $this->assertFalse($this->smarty->isCached($tpl)); + $this->assertEquals("1 2 3 4 5 ", $this->smarty->fetch($tpl)); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForNocacheTag2() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 5 nocache}{$x} {/for}'); + $tpl->assign('foo', 4); + $this->assertTrue($this->smarty->isCached($tpl)); + $this->assertEquals("4 5 ", $this->smarty->fetch($tpl)); + } + + public function testForCache1() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 2}{$x} {/for}'); + $tpl->assign('foo', 1); + $this->assertFalse($this->smarty->isCached($tpl)); + $this->assertEquals("1 2 ", $this->smarty->fetch($tpl)); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForCache2() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 2}{$x} {/for}'); + $tpl->assign('foo', 6); + $this->assertTrue($this->smarty->isCached($tpl)); + $this->assertEquals("1 2 ", $this->smarty->fetch($tpl)); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('buh', 'buh'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "Spacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{for \$bar = 1 to 2}{\$bar}{/for}C", "A12C", 'T1', $i++), + array("A{for \$bar = 1 to 2}\n{\$bar}{/for}C", "A12C", 'T2', $i++), + array("A{for \$bar = 1 to 2}{\$bar}\n{/for}C", "A1\n2\nC", 'T3', $i++), + array("A{for \$bar = 1 to 2}\n{\$bar}\n{/for}C", "A1\n2\nC", 'T4', $i++), + array("A\n{for \$bar = 1 to 2}{\$bar}{/for}C", "A\n12C", 'T5', $i++), + array("A{for \$bar = 1 to 2}{\$bar}{/for}\nC", "A12C", 'T6', $i++), + array("A{for \$bar = 1 to 2}{\$bar}{forelse}D{/for}C", "A12C", 'T7', $i++), + array("A{for \$bar = 1 to 2}{\$bar}\n{forelse}D{/for}C", "A1\n2\nC", 'T8', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}A{\$buh}B{/for}", "AbuhB", 'T9', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}\nA{\$buh}B{/for}", "AbuhB", 'T10', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}A{\$buh}\nB{/for}", "Abuh\nB", 'T11', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}\nA{\$buh}\nB{/for}", "Abuh\nB", 'T12', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}{\$buh}\nB{/for}", "buh\nB", 'T13', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}{\$buh}{/for}", "buh", 'T14', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/For/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/For/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/For/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/For/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/For/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/For/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/For/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/For/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/For/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php b/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php new file mode 100644 index 00000000..ac186b58 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php @@ -0,0 +1,389 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test foreach tags + * + * + * @preserveGlobalState disabled + * @dataProvider dataTestForeach + */ + public function testForeach($code, $foo, $result, $testName, $testNumber) + { + $file = "testForeach_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assign('x', 'x'); + $this->smarty->assign('y', 'y'); + if ($foo !== null) { + $this->smarty->assign('foo', $foo); + } else { + // unassigned $from parameter + $this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + } + + $this->assertEquals($result, $this->smarty->fetch($file), "testForeach - {$code} - {$testName}"); + } + + /* + * Data provider für testForeach + */ + public function dataTestForeach() + { + $i = 0; + /* + * Code + * $foo value + * result + * test name + */ + return array( + array('{foreach item=x from=$foo}{$x}{/foreach}', array(1,2,3), '123', '', $i ++), + array('{foreach $foo as $x}{$x}{/foreach}', array(1,2,3), '123', '', $i ++), + array('{foreach item=x from=$foo}{if $x == 2}{break}{/if}{$x}{/foreach}', array(0,1,2,3,4), '01', '', $i ++), + array('{foreach item=x from=$foo}{if $x == 2}{continue}{/if}{$x}{/foreach}', array(0,1,2,3,4), '0134', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}', array(1,2,3), '123', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}', array(), 'else', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}', null, 'else', '', $i ++), + array('{foreach item=x key=y from=$foo}{$y}=>{$x},{foreachelse}else{/foreach}', array(1,2,3), '0=>1,1=>2,2=>3,', '', $i ++), + array('{foreach $foo as $y => $x}{$y}=>{$x},{foreachelse}else{/foreach}', array(1,2,3), '0=>1,1=>2,2=>3,', '', $i ++), + array('{foreach $foo as $y => $x}{$y}=>{$x},{/foreach}-{$x}-{$y}', array(1,2,3), '0=>1,1=>2,2=>3,-x-y', 'saved loop variables', $i ++), + array('{foreach $foo as $y => $x}{$y}=>{$x},{foreachelse}else{/foreach}-{$x}-{$y}', array(1,2,3), '0=>1,1=>2,2=>3,-x-y', 'saved loop variables', $i ++), + array('{foreach $foo as $y => $x}{$y}=>{$x},{foreachelse}else{/foreach}-{$x}-{$y}', array(), 'else-x-y', 'saved loop variables', $i ++), + array('{foreach $foo as $x}{$x@key}=>{$x},{foreachelse}else{/foreach}', array(1,2,3), '0=>1,1=>2,2=>3,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{$x}{foreachelse}else{/foreach}total{$smarty.foreach.foo.total}', array(1,2,3), '123total3', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}total{$x@total}', array(1,2,3), '123total3', '', $i ++), + array('{foreach item=x name=foo from=$foo}{$smarty.foreach.foo.index}.{$x},{/foreach}', array(9,10,11), '0.9,1.10,2.11,', '', $i ++), + array('{foreach item=x from=$foo}{$x@index}.{$x},{/foreach}', array(9,10,11), '0.9,1.10,2.11,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{$smarty.foreach.foo.iteration}.{$x},{/foreach}', array(9,10,11), '1.9,2.10,3.11,', '', $i ++), + array('{foreach item=x from=$foo}{$x@iteration}.{$x},{/foreach}', array(9,10,11), '1.9,2.10,3.11,', '', $i ++), + array('{foreach item=x from=$foo}{$x@iteration}.{$x}-{$x=\'foo\'}{$x},{/foreach}', array(9,10,11), '1.9-foo,2.10-foo,3.11-foo,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{if $smarty.foreach.foo.first}first{/if}{$x},{/foreach}', array(9,10,11), 'first9,10,11,', '', $i ++), + array('{foreach item=x from=$foo}{if $x@first}first{/if}{$x},{/foreach}', array(9,10,11), 'first9,10,11,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{if $smarty.foreach.foo.last}last{/if}{$x},{/foreach}', array(9,10,11), '9,10,last11,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{if $smarty.foreach.foo.last}last{/if}{$smarty.foreach.foo.iteration}.{$x},{/foreach}', array(9,10,11), '1.9,2.10,last3.11,', '', $i ++), + array('{foreach item=x from=$foo}{if $x@last}last{/if}{$x},{/foreach}', array(9,10,11), '9,10,last11,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{$x}{foreachelse}else{/foreach}{if $smarty.foreach.foo.show}-show{else}-noshow{/if}', array(9,10,11), '91011-show', '', $i ++), + array('{foreach item=x name=foo from=$foo}{$x}{foreachelse}else{/foreach}{if $smarty.foreach.foo.show}-show{else}-noshow{/if}', array(), 'else-noshow', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}{if $x@show}-show{else}-noshow{/if}', array(9,10,11), '91011-show', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}{if $x@show}-show{else}-noshow{/if}', array(), 'else-noshow', '', $i ++), + array('{foreach $foo x y foo}{$y}.{$x},{foreachelse}else{/foreach}total{$smarty.foreach.foo.total}', array(9,10,11), '0.9,1.10,2.11,total3', '', $i ++), + array('{$x = "hallo"}{$bar=[1,2,3]}{foreach $foo as $x}outer={$x@index}.{$x}#{foreach $bar as $x}inner={$x@index}.{$x}{/foreach}##{/foreach}###{$x}', array(9,10,11), 'outer=0.9#inner=0.1inner=1.2inner=2.3##outer=1.10#inner=0.1inner=1.2inner=2.3##outer=2.11#inner=0.1inner=1.2inner=2.3#####hallo', '', $i ++), + array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', null, 'else', '', $i ++), + array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', [], 'else', '', $i ++), + array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', new \ArrayIterator(), 'else', '', $i ++), + ); + } + + + /** + * Test foreach tags caching + * + * + * @preserveGlobalState disabled + * @dataProvider dataTestForeachNocache + */ + public function testForeachCaching($code, $new, $assignNocache, $foo, $result, $testName, $testNumber) + { + $this->smarty->caching = true; + $file = "testForeachNocache_{$testNumber}.tpl"; + if ($new) { + $this->makeTemplateFile($file, $code); + } + if ($foo !== null) { + $this->smarty->assign('foo', $foo, $assignNocache); + } else { + // unassigned $from parameter + $this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + } + + $this->assertEquals($result, $this->smarty->fetch($file), "testForeach - {$code} - {$testName}"); + } + + /* + * Data provider für testForeachNocache + */ + public function dataTestForeachNocache() + { + $i = 0; + /* + * Code + * new name new file + * assign nocache + * $foo value + * result + * test name + */ + return array( + array('{foreach item=x from=$foo}{$x}{/foreach}', true, true, array(1, 2, 3), '123', '', $i), + array('{foreach item=x from=$foo}{$x}{/foreach}', false, true, array(4, 5, 6), '456', '', $i ++), + array('{foreach item=x from=$foo}{$x}{/foreach}', true, false, array(1, 2, 3), '123', '', $i), + array('{foreach item=x from=$foo}{$x}{/foreach}', false, false, array(4, 5, 6), '123', '', $i ++), + array('{nocache}{foreach item=x from=$foo}{$x}{/foreach}{/nocache}', true, false, array(1, 2, 3), '123', '', $i), + array('{nocache}{foreach item=x from=$foo}{$x}{/foreach}{/nocache}', false, false, array(4, 5, 6), '456', '', $i ++), + ); + } + /* + * test foreach and nocache + * + * @runInSeparateProcess + * @preserveGlobalState disabled + + */ + public function testForeachNocacheVar1_024() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(1, 2), true); + $this->assertFalse($this->smarty->isCached('024_foreach.tpl')); + $this->assertEquals("1 2 ", $this->smarty->fetch('024_foreach.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForeachNocacheVar2_024() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(9, 8), true); + $this->assertTrue($this->smarty->isCached('024_foreach.tpl')); + $this->assertEquals("9 8 ", $this->smarty->fetch('024_foreach.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForeachNocacheTag1_025() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(1, 2)); + $this->assertFalse($this->smarty->isCached('025_foreach.tpl')); + $this->assertEquals("1 2 ", $this->smarty->fetch('025_foreach.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForeachNocacheTag2_25() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(9, 8)); + $this->assertTrue($this->smarty->isCached('025_foreach.tpl')); + $this->assertEquals("9 8 ", $this->smarty->fetch('025_foreach.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForeachCache1_26() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(1, 2)); + $this->assertFalse($this->smarty->isCached('026_foreach.tpl')); + $this->assertEquals("1 2 ", $this->smarty->fetch('026_foreach.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForeachCache2_26() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(9, 8)); + $this->assertTrue($this->smarty->isCached('026_foreach.tpl')); + $this->assertEquals("1 2 ", $this->smarty->fetch('026_foreach.tpl')); + } + + public function testForeachNested_27() + { + $this->smarty->assign('foo', array(9, 8)); + $this->smarty->assign('bar', array(4, 10)); + $this->assertEquals("outer=0#9inner=0#4inner=1#10##outer=1#8inner=0#4inner=1#10#####hallo", + $this->smarty->fetch('027_foreach.tpl')); + } + + public function testForeachNestedNamed_28() + { + $this->smarty->assign('foo', array(9, 8)); + $this->smarty->assign('bar', array(4, 10)); + $this->assertEquals("outer=0#0-9inner=1#0-4inner=2#0-10##outer=1#1-8inner=1#1-4inner=2#1-10#####hallo", + $this->smarty->fetch('028_foreach.tpl')); + } + + public function testForeachBreak_29() + { + $this->assertEquals("12", + $this->smarty->fetch('029_foreach.tpl')); + } + + public function testForeachBreak_30() + { + $this->assertEquals("a1a2b1b2for20a1a2b1b2for21", + $this->smarty->fetch('030_foreach.tpl')); + } + + public function testForeachBreak_31() + { + $this->assertEquals("a1a2for20a1a2for21", + $this->smarty->fetch('031_foreach.tpl')); + } + + public function testForeachContinue_32() + { + $this->assertEquals("1245", + $this->smarty->fetch('032_foreach.tpl')); + } + + public function testForeachContinue_33() + { + $this->assertEquals("a1a2a4a5b1b2b4b5for20a1a2a4a5b1b2b4b5for21", + $this->smarty->fetch('033_foreach.tpl')); + } + + public function testForeachContinue_34() + { + $this->assertEquals("a1a2b1b2for20a1a2b1b2for21", + $this->smarty->fetch('034_foreach.tpl')); + } + + public function testForeachContinue_35() + { + $this->assertEquals("a1a2a1a2", + $this->smarty->fetch('035_foreach.tpl')); + } + public function testForeachIsset_36() + { + $this->assertEquals("false", + $this->smarty->fetch('036_foreach.tpl')); + } + public function testForeachIsset_37() + { + $this->assertEquals("false", + $this->smarty->fetch('037_foreach.tpl')); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', array(1,2)); + $this->assertEquals($result, + $this->smarty->fetch($file), + "Spacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{foreach from=\$foo item='bar'}{\$bar}{/foreach}C", "A12C", 'Newline1', $i++), + array("A{foreach from=\$foo item='bar'}\n{\$bar}{/foreach}C", "A12C", 'Newline2', $i++), + array("A{foreach from=\$foo item='bar'}{\$bar}\n{/foreach}C", "A1\n2\nC", 'Newline3', $i++), + array("A{foreach from=\$foo item='bar'}\n{\$bar}\n{/foreach}C", "A1\n2\nC", 'Newline4', $i++), + array("A\n{foreach from=\$foo item='bar'}{\$bar}{/foreach}C", "A\n12C", 'Newline5', $i++), + array("A{foreach from=\$foo item='bar'}{\$bar}{/foreach}\nC", "A12C", 'Newline6', $i++), + array("A{foreach from=\$foo item='bar'}{\$bar}{foreachelse}D{/foreach}C", "A12C", 'Newline7', $i++), + array("A{foreach from=\$foo item='bar'}{\$bar}\n{foreachelse}D{/foreach}C", "A1\n2\nC", 'Newline8', $i++), + array("{foreach from=\$foo item='bar' name='buh'}{\$bar}{/foreach}A{\$smarty.foreach.buh.total}C", "12A2C", 'Newline9', $i++), + array("{foreach from=\$foo item='bar' name='buh'}{\$bar}{/foreach}A\n{\$smarty.foreach.buh.total}C", "12A\n2C", 'Newline10', $i++), + array("{foreach from=\$foo item='bar' name='buh'}{\$bar}{/foreach}A{\$smarty.foreach.buh.total}\nC", "12A2\nC", 'Newline11', $i++), + ); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestElseSpacing + * @runInSeparateProcess + */ + public function testElseSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_Else_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', array()); + $this->smarty->assign('buh', 'buh'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "Spacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestElseSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}A{\$buh}B{/foreach}", "AbuhB", 'Newline1', $i++), + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}\nA{\$buh}B{/foreach}", "AbuhB", 'Newline2', $i++), + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}A{\$buh}\nB{/foreach}", "Abuh\nB", 'Newline3', $i++), + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}\nA{\$buh}\nB{/foreach}", "Abuh\nB", 'Newline4', $i++), + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}{\$buh}\nB{/foreach}", "buh\nB", 'Newline5', $i++), + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}{\$buh}{/foreach}", "buh", 'Newline6', $i++), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Foreach/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/024_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/024_foreach.tpl new file mode 100644 index 00000000..44f3cb37 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/024_foreach.tpl @@ -0,0 +1 @@ +{foreach $foo as $x}{$x} {/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/025_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/025_foreach.tpl new file mode 100644 index 00000000..fe5193af --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/025_foreach.tpl @@ -0,0 +1 @@ +{foreach $foo as $x nocache}{$x} {/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/026_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/026_foreach.tpl new file mode 100644 index 00000000..9a2b698b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/026_foreach.tpl @@ -0,0 +1 @@ +{foreach $foo as $x name=bar}{$x} {/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/027_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/027_foreach.tpl new file mode 100644 index 00000000..ad2fe7cf --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/027_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{$x = "hallo"} +{foreach $foo as $x} + outer={$x@index}#{$x} +{foreach $bar as $x} + inner={$x@index}#{$x} +{/foreach}## +{/foreach} +###{$x} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/028_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/028_foreach.tpl new file mode 100644 index 00000000..8d1c07f9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/028_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{$x = 'hallo'} +{foreach from=$foo item=x key=y name='b'} + outer={$smarty.foreach.b.index}#{$y}-{$x} +{foreach from=$bar item=x name='b'} + inner={$smarty.foreach.b.iteration}#{$y}-{$x} +{/foreach}## +{/foreach} +###{$x} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/029_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/029_foreach.tpl new file mode 100644 index 00000000..afae1b27 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/029_foreach.tpl @@ -0,0 +1,5 @@ +{strip} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{break}{/if} + {$i} +{/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/030_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/030_foreach.tpl new file mode 100644 index 00000000..45feb6f3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/030_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{for $i=20;$i<22;$i++} +{foreach ['a','b'] as $a} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{break}{/if} + {$a}{$i} +{/foreach} +{/foreach} +for{$i}{/for} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/031_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/031_foreach.tpl new file mode 100644 index 00000000..70a2859b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/031_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{for $i=20;$i<22;$i++} +{foreach ['a','b'] as $a} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{break 2}{/if} + {$a}{$i} +{/foreach} +{/foreach} +for{$i}{/for} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/032_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/032_foreach.tpl new file mode 100644 index 00000000..c0bae38b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/032_foreach.tpl @@ -0,0 +1,5 @@ +{strip} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{continue}{/if} + {$i} +{/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/033_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/033_foreach.tpl new file mode 100644 index 00000000..c2ade6d5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/033_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{for $i=20;$i<22;$i++} +{foreach ['a','b'] as $a} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{continue}{/if} + {$a}{$i} +{/foreach} +{/foreach} +for{$i}{/for} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/034_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/034_foreach.tpl new file mode 100644 index 00000000..ad256a96 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/034_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{for $i=20;$i<22;$i++} +{foreach ['a','b'] as $a} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{continue 2}{/if} + {$a}{$i} +{/foreach} +{/foreach} +for{$i}{/for} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/035_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/035_foreach.tpl new file mode 100644 index 00000000..dd61dd28 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/035_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{for $i=20;$i<22;$i++} +{foreach ['a','b'] as $a} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{continue 3}{/if} + {$a}{$i} +{/foreach} +{/foreach} +for{$i}{/for} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/036_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/036_foreach.tpl new file mode 100644 index 00000000..9aa2865c --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/036_foreach.tpl @@ -0,0 +1 @@ +{if !isset($smarty.foreach.name.index)}false{/if} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/037_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/037_foreach.tpl new file mode 100644 index 00000000..81ba1e51 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/037_foreach.tpl @@ -0,0 +1 @@ +{if false}no{elseif !isset($smarty.foreach.name.index)}false{/if} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php new file mode 100644 index 00000000..4622e578 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php @@ -0,0 +1,62 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + + /** + * test function plugin tag in compiled template file + */ + public function testFunctionPluginFromCompiledTemplateFile() + { + $this->smarty->setForceCompile(false); + $tpl = $this->smarty->createTemplate('functionplugintest.tpl', $this->smarty); + $this->assertEquals("10", $this->smarty->fetch($tpl)); + } + + /** + * test function plugin function definition in script + */ + public function testFunctionPluginRegisteredFunction() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'plugintest', 'myplugintest'); + $tpl = $this->smarty->createTemplate('string:{plugintest foo=bar}', $this->smarty); + $this->assertEquals("plugin test called bar", $this->smarty->fetch($tpl)); + } + + /** + * test muiltiline tags + */ + public function testMultiLineTags() + { + $this->assertEquals("10", $this->smarty->fetch("string:{counter\n\tstart=10}")); + } +} + +function myplugintest($params, $smarty) +{ + return "plugin test called $params[foo]"; +} diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintest.tpl b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintest.tpl new file mode 100644 index 00000000..8faa5d5f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintest.tpl @@ -0,0 +1 @@ +{counter start=10 name=tpl} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintestnocache.tpl b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintestnocache.tpl new file mode 100644 index 00000000..9134519a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintestnocache.tpl @@ -0,0 +1 @@ +{getvar var=foo nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php b/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php new file mode 100644 index 00000000..1eb7bd30 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php @@ -0,0 +1,261 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test if tags + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestIf + */ + public function testIf($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testIf_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('bar', 'buh'); + $this->assertEquals($result, $this->smarty->fetch($file), + "testIf - {$code} - {$name}"); + } + + /* + * Data provider für testIf + */ + public function dataTestIf() + { + $i = 1; + /* + * Code + * result + * test name + */ + return array(array('{if 0<1}yes{/if}', 'yes', '', $i ++), + array('{if false}false{elseif 0<1}yes{/if}', 'yes', '', $i ++), + array('{if 2<1}yes{else}no{/if}', 'no', '', $i ++), + array('{if 2<1}yes{elseif 4<5}yes1{else}no{/if}', 'yes1', '', $i ++), + array('{if 2<1}yes{elseif 6<5}yes1{else}no{/if}', 'no', '', $i ++), + array('{if false}false{elseif true}yes{else}no{/if}', 'yes', '', $i ++), + array('{if false}yes{else}no{/if}', 'no', '', $i ++), + array('{if !(1<2)}yes{else}no{/if}', 'no', '', $i ++), + array('{if not (true)}yes{else}no{/if}', 'no', '', $i ++), + array('{if 1 == 1}yes{else}no{/if}', 'yes', '', $i ++), + array('{if 1 EQ 1}yes{else}no{/if}', 'yes', '', $i ++), + array('{if 1 eq 1}yes{else}no{/if}', 'yes', '', $i ++), + array('{$foo=true}{if $foo===true}yes{else}no{/if}', 'yes', '', $i ++), + array('{$foo=true}{if $foo!==true}yes{else}no{/if}', 'no', '', $i ++), + array('{if 1 > 0}yes{else}no{/if}', 'yes', '', $i ++), + array('{if $x=1}yes{else}no{/if}{$x}', 'yes1', '', $i ++), + array('{$x=0}{if $x++}yes{else}no{/if} {$x}', 'no 1', '', $i ++), + array('{$x=[1,2]}{if $x[] = 7}{$x|var_export:true}{else}no{/if}', var_export(array(0=>1,1=>2,2=>7,),true), '', + $i ++), + array('{$x=[1,2]}{if $x[][\'a\'] = 7}{$x|var_export:true}{else}no{/if}', + var_export(array(0=>1,1=>2,2=>array('a'=>7,),),true), '', $i ++), + array('{$foo=\'foo\'}{$bar=\'bar\'}{if $bar = "new_{$foo|default:\'\'}"}yes-{else}no{/if}{$bar}', + 'yes-new_foo', '', $i ++), + array('{$foo=\'foo\'}{$bar=\'bar\'}{if false}false{elseif $bar = "new_{$foo|default:\'\'}"}yes-{else}no{/if}{$bar}', + 'yes-new_foo', '', $i ++), + array('{$foo=\'foo\'}{$bar=\'bar\'}{if false}false{elseif $bar[3] = "new_{$foo|default:\'\'}"}yes-{else}no{/if}{$bar[0]}-{$bar[3]}', + 'yes-bar-new_foo', '', $i ++), + + array('{$x=0}{if $x}yes{else}no{/if}', 'no', 'AssignVar', $i ++), + array('{$x=0}{if $x++}yes{else}no{/if} {$x}', 'no 1', 'IncVar', $i ++), + array('{$x=1}{if $x}yes{else}no{/if}', 'yes', 'SimpleVar', $i ++), + array('{if $x=true}yes{else}no{/if}', 'yes', 'AssignTrue', $i ++), + array('{if $x=false}yes{else}no{/if}', 'no', 'AssignFalse', $i ++), + array('{if 3 ge strlen("foo")}yes{else}no{/if}', 'yes', 'CmpWithFunc', $i ++), + array('{if isset($foo)}yes{else}no{/if}', 'no', 'NotIsset', $i ++), + array('{$foo=1}{if isset($foo)}yes{else}no{/if}', 'yes', 'Isset', $i ++), + array('{$foo=1}{if !isset($foo)}yes{else}no{/if}', 'no', 'IssetNegate', $i ++), + array('{$foo=\'\'}{if empty($foo)}yes{else}no{/if}', 'yes', 'Empty', $i ++), + array('{$foo=\'foo\'}{if empty($foo)}yes{else}no{/if}', 'no', 'NotEmpty', $i ++), + array('{if 6 is div by 3}yes{else}no{/if}', 'yes', 'IsDivBy', $i ++), + array('{if 6 is not div by 3}yes{else}no{/if}', 'no', 'IsNotDivBye', $i ++), + array('{if 6 is even}yes{else}no{/if}', 'yes', 'IsEven', $i ++), + array('{if 6 is not even}yes{else}no{/if}', 'no', 'IsNotEven', $i ++), + array('{if 3 is odd}yes{else}no{/if}', 'yes', 'IsOdd', $i ++), + array('{if 3 is not odd}yes{else}no{/if}', 'no', 'IsNotOdd', $i ++), + array('{$foo=3}{if 3 is odd by $foo}yes{else}no{/if}', 'yes', 'IsOddByVar', $i ++), + array('{$foo=3}{$bar=6}{if $bar is not odd by $foo}yes{else}no{/if}', 'yes', 'IsNotOddByVar', $i ++), + array('{$foo=3}{$bar=3}{if 3+$bar is not odd by $foo}yes{else}no{/if}', 'yes', 'ExprIsNotOddByVar', $i ++), + array('{$foo=2}{$bar=6}{if (3+$bar) is not odd by ($foo+1)}yes{else}no{/if}', 'no', 'ExprIsNotOddByExpr', $i ++), + array('{if strlen("hello world") === 11}yes{else}no{/if}', 'yes', 'FuncCmp', $i ++), + array('{if 0>1}yes{else}no{/if}', 'no', 'GT2', $i ++), + array('{if 1 GT 0}yes{else}no{/if}', 'yes', 'GT3', $i ++), + array('{if 0 gt 1}yes{else}no{/if}', 'no', 'GT4', $i ++), + array('{if 1 >= 0}yes{else}no{/if}', 'yes', 'GE1', $i ++), + array('{if 1>=1}yes{else}no{/if}', 'yes', 'GE2', $i ++), + array('{if 1 GE 1}yes{else}no{/if}', 'yes', 'GE3', $i ++), + array('{if 0 ge 1}yes{else}no{/if}', 'no', 'GE4', $i ++), + array('{if 0 < 0}yes{else}no{/if}', 'no', 'LT1', $i ++), + array('{if 0<1}yes{else}no{/if}', 'yes', 'LT2', $i ++), + array('{if 0 <= 0}yes{else}no{/if}', 'yes', 'LE1', $i ++), + array('{if 0<=1}yes{else}no{/if}', 'yes', 'LE2', $i ++), + array('{if 1 LE 0}yes{else}no{/if}', 'no', 'LE3', $i ++), + array('{if 0 le 1}yes{else}no{/if}', 'yes', 'LE4', $i ++), + array('{if 1 != 1}yes{else}no{/if}', 'no', 'NE1', $i ++), + array('{if 1!=2}yes{else}no{/if}', 'yes', 'NE2', $i ++), + array('{if 1 NE 1}yes{else}no{/if}', 'no', 'NE3', $i ++), + array('{if 1 ne 2}yes{else}no{/if}', 'yes', 'NE4', $i ++), + array('{if 1 === "1"}yes{else}no{/if}', 'no', 'Ident1', $i ++), + array('{if "1" === "1"}yes{else}no{/if}', 'yes', 'Ident2', $i ++), + array('{if 1 > 0 && 5 < 6}yes{else}no{/if}', 'yes', 'And1', $i ++), + array('{if 1 > 0&&5 < 6}yes{else}no{/if}', 'yes', 'And2', $i ++), + array('{if 1 > 0 AND 5 > 6}yes{else}no{/if}', 'no', 'And3', $i ++), + array('{if (1 > 0) and (5 < 6)}yes{else}no{/if}', 'yes', 'And4', $i ++), + array('{if 1 > 0 || 7 < 6}yes{else}no{/if}', 'yes', 'Or1', $i ++), + array('{if 1 > 0||5 < 6}yes{else}no{/if}', 'yes', 'Or2', $i ++), + array('{if 1 > 0 OR 5 > 6}yes{else}no{/if}', 'yes', 'Or3', $i ++), + array('{if (0 > 0) or (9 < 6)}yes{else}no{/if}', 'no', 'Or4', $i ++), + array('{if ((7>8)||(1 > 0)) and (5 < 6)}yes{else}no{/if}', 'yes', 'AndOr1', $i ++), + array('{if {counter start=1} == 1}yes{else}no{/if}', 'yes', 'Tag1', $i ++), + array('{if false}false{elseif {counter start=1} == 1}yes{else}no{/if}', 'yes', 'Tag2', $i ++), + array('{if {counter start=1} == 0}false{elseif {counter} == 2}yes{else}no{/if}', 'yes', 'Tag3', $i ++), + ); + } + + + + + /** + * Test if nocache tags + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestIfNocache + */ + public function testIfNocache($var, $value, $code, $result, $testName, $testNumber, $file = null) + { + if (!isset($file)) { + $file = "testIfNoCache_{$testNumber}.tpl"; + } + if ($code) { + $this->makeTemplateFile($file, $code); + } + $this->smarty->setCaching(true); + $this->smarty->assign('file', $file, true); + $this->smarty->assign($var, $value, true); + $this->smarty->assign($var . '2', $value); + $this->assertEquals($result, $this->strip($this->smarty->fetch('run_code_caching.tpl')), + "testIfNocahe - {$code} - {$testName}"); + } + + /* + * Data provider für testIfNocache + */ + public function dataTestIfNocache() + { + $i = 1; + /* + * var + * value + * Code + * result + * test name + */ + return array(array('foo', true, '{if $foo}yes{else}no{/if}', 'yes', '', $i ++, 'testIfNoCache_Var1.tpl'), + array('foo', true, false, 'yes', '', $i ++, 'testIfNoCache_Var1.tpl'), + array('foo', false, false, 'no', '', $i ++, 'testIfNoCache_Var1.tpl'), + array('foo', false, false, 'no', '', $i ++, 'testIfNoCache_Var1.tpl'), + array('foo', true, '{$bar=$foo}{if $bar}yes{else}no{/if}', 'yes', '', $i ++, + 'testIfNoCache_Var2.tpl'), + array('foo', true, false, 'yes', '', $i ++, 'testIfNoCache_Var2.tpl'), + array('foo', false, false, 'no', '', $i ++, 'testIfNoCache_Var2.tpl'), + array('foo', false, false, 'no', '', $i ++, 'testIfNoCache_Var2.tpl'), + array('foo', 1, '{if $bar=$foo}yes{else}no{/if}{$bar}', 'yes1', '', $i ++, + 'testIfNoCache_Var3.tpl'), + array('foo', 1, false, 'yes1', '', $i ++, 'testIfNoCache_Var3.tpl'), + array('foo', 0, false, 'no0', '', $i ++, 'testIfNoCache_Var3.tpl'), + array('foo', 0, false, 'no0', '', $i ++, 'testIfNoCache_Var3.tpl'), + array('bar', 4, '{if $bar2=$bar+3}yes{else}no{/if}{$bar2}', 'yes7', '', $i ++, + 'testIfNoCache_Var4.tpl'), + array('bar', 4, false, 'yes7', '', $i ++, 'testIfNoCache_Var4.tpl'), + array('bar', 0, false, 'yes3', '', $i ++, 'testIfNoCache_Var4.tpl'), + array('bar', 0, false, 'yes3', '', $i ++, 'testIfNoCache_Var4.tpl'),); + } + + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('bar', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{if false}false{elseif true}{\$bar}{/if}C", "AbarC", 'T1', $i++), + array("A{if false}false{elseif true}\n{\$bar}{/if}C", "AbarC", 'T2', $i++), + array("A{if false}false{elseif true}{\$bar}\n{/if}C", "Abar\nC", 'T3', $i++), + array("A{if false}false{elseif true}\n{\$bar}\n{/if}C", "Abar\nC", 'T4', $i++), + array("A\n{if false}false{elseif true}{\$bar}{/if}C", "A\nbarC", 'T5', $i++), + array("A{if false}false{elseif true}{\$bar}{/if}\nC", "AbarC", 'T6', $i++), + array("A{if false}false{elseif true}{\$bar}{else}D{/if}C", "AbarC", 'T7', $i++), + array("A{if false}false{elseif true}{\$bar}\n{else}D{/if}C", "Abar\nC", 'T8', $i++), + array("{if false}false{else}A{\$bar}B{/if}", "AbarB", 'T9', $i++), + array("{if false}false{else}\nA{\$bar}B{/if}", "AbarB", 'T10', $i++), + array("{if false}false{else}A{\$bar}\nB{/if}", "Abar\nB", 'T11', $i++), + array("{if false}false{else}\nA{\$bar}\nB{/if}", "Abar\nB", 'T12', $i++), + array("{if false}false{else}{\$bar}\nB{/if}", "bar\nB", 'T13', $i++), + array("{if false}false{else}{\$bar}{/if}", "bar", 'T14', $i++), + array("A{if false}false{elseif true}{\$bar}{/if}C", "AbarC", 'T15', $i++), + array("A{if false}false{elseif true}\n{\$bar}{/if}C", "AbarC", 'T16', $i++), + array("A{if false}false{elseif true}{\$bar}\n{/if}C", "Abar\nC", 'T17', $i++), + array("A{if false}false{elseif true}\n{\$bar}\n{/if}C", "Abar\nC", 'T18', $i++), + array("A\n{if false}false{elseif true}{\$bar}{/if}C", "A\nbarC", 'T19', $i++), + array("A{if false}false{elseif true}{\$bar}{/if}\nC", "AbarC", 'T20', $i++), + array("A{if false}false{elseif true}{\$bar}{else}D{/if}C", "AbarC", 'T21', $i++), + array("A{if false}false{elseif true}{\$bar}\n{else}D{/if}C", "Abar\nC", 'T22', $i++), + ); + } + + + } diff --git a/tests/UnitTests/TemplateSource/TagTests/If/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/If/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/If/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/If/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/If/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/If/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/If/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/If/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/If/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php new file mode 100644 index 00000000..830089ae --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php @@ -0,0 +1,327 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test spacing + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProviderCaching + */ + public function testSpacing_001($merge, $caching, $text) + { + $this->smarty->setCaching($caching); + if ($merge) { + $this->smarty->setCacheId('1'); + } + $this->smarty->setMergeCompiledIncludes($merge); + $content = $this->smarty->fetch('test_include_001.tpl'); + $this->assertEquals('I1I2I3', $content, $text); + } + + /** + * test spacing + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProviderCaching + */ + public function testSpacing_001V2($merge, $caching, $text) + { + $this->smarty->setCaching($caching); + if ($merge) { + $this->smarty->setCacheId('1'); + } + $this->smarty->setMergeCompiledIncludes($merge); + $content = $this->smarty->fetch('test_include_001V2.tpl'); + $this->assertEquals('I1I2I3', $content, $text); + } + + /** + * test spacing + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProviderCaching + */ + public function testSpacing_001V3($merge, $caching, $text) + { + $this->smarty->setCaching($caching); + if ($merge) { + $this->smarty->setCacheId('1'); + } + $this->smarty->setMergeCompiledIncludes($merge); + $content = $this->smarty->fetch('test_include_001V3.tpl'); + $this->assertEquals('I1I2I3', $content, $text); + } + + /** + * test standard output + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludeStandard_001($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_include_standard.tpl'); + $content = $this->smarty->fetch($tpl); + $this->assertEquals("hello world", $content, $text); + } + + /** + * test standard output var + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludeStandardNocacheVar($merge, $text) + { + $this->smarty->setMergeCompiledIncludes(false); + $this->smarty->caching = true; + $this->smarty->assign('foo', 'foo', true); + $tpl = $this->smarty->createTemplate('test_include_standard_nocache_var.tpl', $this->smarty); + $content = $this->smarty->fetch($tpl); + $this->assertEquals("foo\n\nhello world", $content, $text); + } + + /** + * Test that assign attribute does not create standard output + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludeAssign1($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_include_assign1.tpl'); + $this->assertEquals("", $this->smarty->fetch($tpl), $text); + } + + /** + * Test that assign attribute does load variable + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludeAssign2($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_include_assign2.tpl'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl), $text); + } + + /** + * Test passing local vars eval + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludePassVars($merge, $text) + { + //$this->smarty->caching = true; + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_include_pass_vars.tpl'); + $this->assertEquals("12", $this->smarty->fetch($tpl), $text); + } + + /** + * Test passing local vars include + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludePassVars2($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_include_pass_vars2.tpl'); + $this->assertEquals("12", $this->smarty->fetch($tpl), $text); + } + + + + + /** + * Test recursive includes + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testRecursiveIncludes1($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $this->smarty->assign('foo', 1); + $this->smarty->assign('bar', 'bar'); + $content = $this->smarty->fetch('test_recursive_includes.tpl'); + $this->assertContains("before 1 bar
\nbefore 2 bar
\nbefore 3 bar
\nafter 3 bar
\nafter 2 bar
\nafter 1 bar
", $content, $text); + } + + /** + * Test recursive includes 2 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testRecursiveIncludes2($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $this->smarty->assign('foo', 1); + $this->smarty->assign('bar', 'bar'); + $content = $this->smarty->fetch('test_recursive_includes2.tpl'); + $this->assertContains("before 1 bar
\nbefore 3 bar
\nbefore 5 bar
\nafter 5 bar
\nafter 3 bar
\nafter 1 bar
", $content, $text); + } + + /** + * Include data provider + */ + public function includeProvider() + { + return array( + array(false, 'normal'), + array(true, 'merged'), + ); + } + + /** + * Include data provider caching + * + * @dataProvider fileProvider + */ + public function includeProviderCaching($file) + { + return array( + array(false, false, 'normal'), + array(true, false, 'merged'), + array(false, true, 'normal cached 1'), + array(false, true, 'normal cached 2'), + array(true, true, 'merged cached 1'), + array(true, true, 'merged cached 2'), + ); + } + + public function fileProvider() + { + return array( + array('normal'), + array('merged'), + ); + } + /** + * Test Include spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testIncludeSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testIncludeSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testIncludeSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array('A{include file=\'include_spacing2.tpl\'}B', 'A barB', '2_Text1', $i++), + array('A {include file=\'include_spacing2.tpl\'}B', 'A barB', '2_Text2', $i++), + array('A{include file=\'include_spacing2.tpl\'}B', 'A barB', '2_Text3', $i++), + array("A{include file='include_spacing2.tpl'}\nB", "A barB", '2_Newline1', $i++), + array("A\n{include file='include_spacing2.tpl'}\nB", "A\n barB", '2_Newline2', $i++), + array("A{include file='include_spacing2.tpl'}B\nC", "A barB\nC", '2_Newline3', $i++), + array('A{include file=\'include_spacing3.tpl\'}B', "AbarB", '3_Text1', $i++), + array('A {include file=\'include_spacing3.tpl\'}B', "A barB", '3_Text2', $i++), + array('A{include file=\'include_spacing3.tpl\'}B', "AbarB", '3_Text3', $i++), + array("A{include file='include_spacing3.tpl'}\nB", "AbarB", '3_Newline1', $i++), + array("A\n{include file='include_spacing3.tpl'}\nB", "A\nbarB", '3_Newline2', $i++), + array("A{include file='include_spacing3.tpl'}B\nC", "AbarB\nC", '3_Newline3', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Include/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/helloworld.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/helloworld.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/helloworld.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing1.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing1.tpl new file mode 100644 index 00000000..ba0e162e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing1.tpl @@ -0,0 +1 @@ +bar \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing2.tpl new file mode 100644 index 00000000..2f9aec39 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing2.tpl @@ -0,0 +1 @@ + {$foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing3.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing3.tpl new file mode 100644 index 00000000..b9490d3b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing3.tpl @@ -0,0 +1 @@ +{$foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001.tpl new file mode 100644 index 00000000..8dd11b1e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001.tpl @@ -0,0 +1 @@ +I1{include file='test_include_001_2.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V2.tpl new file mode 100644 index 00000000..49d4a5bb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V2.tpl @@ -0,0 +1 @@ +I1{include file='test_include_001_2.tpl' cache_lifetime=30} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V3.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V3.tpl new file mode 100644 index 00000000..a1eee482 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V3.tpl @@ -0,0 +1 @@ +I1{include file='test_include_001_2V3.tpl' cache_lifetime=30} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2.tpl new file mode 100644 index 00000000..c2a6f309 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2.tpl @@ -0,0 +1 @@ +I2{include file='test_include_001_3.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2V3.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2V3.tpl new file mode 100644 index 00000000..64bf6c17 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2V3.tpl @@ -0,0 +1 @@ +I2{include file='test_include_001_3.tpl' nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_3.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_3.tpl new file mode 100644 index 00000000..ebf6bc50 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_3.tpl @@ -0,0 +1 @@ +I3 \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign1.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign1.tpl new file mode 100644 index 00000000..6021362f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign1.tpl @@ -0,0 +1 @@ +{include file="helloworld.tpl" assign=foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign2.tpl new file mode 100644 index 00000000..aee9b8ad --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign2.tpl @@ -0,0 +1 @@ +{assign var=foo value=bar}{include file="helloworld.tpl" assign=foo}{$foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars.tpl new file mode 100644 index 00000000..0cf974d1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars.tpl @@ -0,0 +1 @@ +{include file='test_include_pass_vars2_sub.tpl' myvar1=1 myvar2=2} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2.tpl new file mode 100644 index 00000000..0cf974d1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2.tpl @@ -0,0 +1 @@ +{include file='test_include_pass_vars2_sub.tpl' myvar1=1 myvar2=2} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2_sub.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2_sub.tpl new file mode 100644 index 00000000..e2b94437 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2_sub.tpl @@ -0,0 +1 @@ +{$myvar1}{$myvar2} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard.tpl new file mode 100644 index 00000000..9837d596 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard.tpl @@ -0,0 +1 @@ +{include file='helloworld.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard_nocache_var.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard_nocache_var.tpl new file mode 100644 index 00000000..8a545348 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard_nocache_var.tpl @@ -0,0 +1,3 @@ +{$foo} + +{include file="helloworld.tpl"} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes.tpl new file mode 100644 index 00000000..344c0dd6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes.tpl @@ -0,0 +1,2 @@ +before {$foo} {$bar}
+{if $foo < 3}{include 'test_recursive_includes.tpl' foo=$foo+1}{/if}after {$foo} {$bar}
diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes2.tpl new file mode 100644 index 00000000..f550809e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes2.tpl @@ -0,0 +1,2 @@ +before {$foo} {$bar}
+{if $foo < 4}{include 'test_recursive_includes_pass.tpl' foo=$foo+1}{/if}after {$foo} {$bar}
diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes_pass.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes_pass.tpl new file mode 100644 index 00000000..eb31fc18 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes_pass.tpl @@ -0,0 +1 @@ +{include 'test_recursive_includes2.tpl' foo=$foo+1} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope.tpl new file mode 100644 index 00000000..bfb1e6cb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope.tpl @@ -0,0 +1 @@ +{include $file} diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_assign.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_assign.tpl new file mode 100644 index 00000000..ae7268d8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_assign.tpl @@ -0,0 +1 @@ +{$foo = 'newvar'}{checkvar var=foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_pluginassign.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_pluginassign.tpl new file mode 100644 index 00000000..e19a560a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_pluginassign.tpl @@ -0,0 +1 @@ +{pluginassign var=foo value='newvar'}{checkvar var=foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Include/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Include/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/IncludePhp/CompileIncludePhpTest.php b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/CompileIncludePhpTest.php new file mode 100644 index 00000000..acdd1429 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/CompileIncludePhpTest.php @@ -0,0 +1,74 @@ +setUpSmarty(dirname(__FILE__)); + $this->smartyBC->setForceCompile(true); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test include_php string file_name function + */ + public function testIncludePhpStringFileName() + { + $this->smartyBC->disableSecurity(); + $tpl = $this->smartyBC->createTemplate('include_php.tpl'); + $result = $this->smartyBC->fetch($tpl); + $this->assertContains("test include php", $result); + } + + /** + * test include_php from trusted dir + */ + public function testIncludePhpTrusted() + { + $this->smartyBC->enableSecurity(); + $this->smartyBC->security_policy->trusted_dir = '.\\scripts\\'; + $tpl = $this->smartyBC->createTemplate('include_php_trusted.tpl'); + $result = $this->smartyBC->fetch($tpl); + $this->assertContains("test include php", $result); + } + + /** + * test include_php string file_name function + */ + public function testIncludePhpVariableFileName() + { + $this->smartyBC->disableSecurity(); + $tpl = $this->smartyBC->createTemplate('string:start {include_php file=$filename once=false} end'); + $tpl->assign('filename', 'scripts/test_include_php.php'); + $result = $this->smartyBC->fetch($tpl); + $this->assertContains("test include php", $result); + } + + public function testIncludePhpVariableFileNameShortag() + { + $this->smartyBC->disableSecurity(); + $tpl = $this->smartyBC->createTemplate('string:start {include_php $filename once=false} end'); + $tpl->assign('filename', 'scripts/test_include_php.php'); + $result = $this->smartyBC->fetch($tpl); + $this->assertContains("test include php", $result); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/IncludePhp/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/IncludePhp/scripts/test_include_php.php b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/scripts/test_include_php.php new file mode 100644 index 00000000..2bb96d8a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/scripts/test_include_php.php @@ -0,0 +1,2 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->smarty->enableSecurity(); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * Test For + * + * @preserveGlobalState disabled + * @dataProvider dataTestInsert + * @runInSeparateProcess + */ + public function testInsert($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Insert_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assign('variable', 'test'); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testInsert + */ + public function dataTestInsert() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array('start {insert name=\'test\' foo=\'bar\'} end', 'start insert function parameter value bar end', 'T1', $i++), + array('start {insert name="test" foo=\'bar\'} end', 'start insert function parameter value bar end', 'T2', $i++), + array('start {insert name=$variable foo=\'bar\'} end', 'start insert function parameter value bar end', 'T3', $i++), + array("start {insert name='test' foo='bar' assign=blar} end {\$blar}", 'start end insert function parameter value bar', 'T4', $i++), + array("start {insert name='test' foo='bar' assign=blar} end", 'start end', 'T5', $i++), + ); + } + + + + + /** + * test insert plugin + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPlugin1() + { + global $insertglobal; + $insertglobal = 'global'; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'bar'); + $this->assertEquals('param foo bar globalvar global', $this->smarty->fetch($tpl)); + } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * test insert plugin + */ + public function testInsertPlugin2() + { + global $insertglobal; + $insertglobal = 'global 2'; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'buh'); + $this->assertEquals('param foo buh globalvar global 2', $this->smarty->fetch($tpl)); + } + + /** + * test insert plugin caching + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPluginCaching1_1() + { + global $insertglobal; + $insertglobal = 'global'; + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'bar', true); + $this->assertEquals('param foo bar globalvar global', $this->smarty->fetch($tpl)); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testInsertPluginCaching1_2() + { + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + global $insertglobal; + $insertglobal = 'changed global 2'; + $this->smarty->caching = 1; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'buh', true); +// $this->assertTrue($tpl->isCached()); + $this->assertEquals('param foo buh globalvar changed global 2', $this->smarty->fetch($tpl)); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testInsertPluginCaching1_3() + { + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + global $insertglobal; + $insertglobal = 'changed global'; + $this->smarty->caching = 1; +// $this->smarty->setForceCompile(true); + $this->smarty->assign('foo', 'bar', true); + $this->assertEquals('param foo bar globalvar changed global', $this->smarty->fetch('insertplugintest.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testInsertPluginCaching1_4() + { + global $insertglobal; + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $insertglobal = 'changed global 4'; + $this->smarty->caching = 1; + $this->smarty->assign('foo', 'buh', true); + $this->assertTrue($this->smarty->isCached('insertplugintest.tpl')); + $this->assertEquals('param foo buh globalvar changed global 4', $this->smarty->fetch('insertplugintest.tpl')); + } + /** + * test insert plugin caching 2 + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPluginCaching2_1() + { + global $insertglobal; + $insertglobal = 'global'; + $this->smarty->caching = true; + $this->smarty->compile_id = 1; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'bar'); + $this->assertEquals('param foo bar globalvar global', $this->smarty->fetch($tpl)); + } + + /** + * test insert plugin caching 2 + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPluginCaching2_2() + { + global $insertglobal; + $insertglobal = 'global 2'; + $this->smarty->caching = true; + $this->smarty->compile_id = 1; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'buh'); + $this->assertContains('param foo bar globalvar global 2', $this->smarty->fetch($tpl)); + } + /** + * test insert plugin caching 3 + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPluginCaching3_1() + { + $this->smarty->caching = true; + $this->smarty->assign('insert',$t=time()); + $this->assertContains($t.'Inner template', $this->smarty->fetch('insertplugintest2.tpl')); + } + + /** + * test insert plugin caching 2 + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPluginCaching3_2() + { + sleep(2); + $this->smarty->caching = true; + $this->smarty->assign('insert',$t=time()); + $this->assertContains($t.'Inner template', $this->smarty->fetch('insertplugintest2.tpl')); + } + + + /** + * test inserted function none existing function + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertFunctionNoneExistingFunction() + { + $tpl = $this->smarty->createTemplate("eval:start {insert name='mustfail' foo='bar' assign=blar} end {\$blar}"); + try { + $this->smarty->fetch($tpl); + } + catch (Exception $e) { + $this->assertContains("{insert} no function or plugin found for 'mustfail'", $e->getMessage()); + + return; + } + $this->fail('Exception for "function is not callable" has not been raised.'); + } + + /** + * test inserted function none existing script + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertFunctionNoneExistingScript() + { + $tpl = $this->smarty->createTemplate("eval:{insert name='mustfail' foo='bar' script='nofile.php'}"); + try { + $this->smarty->fetch($tpl); + } + catch (Exception $e) { + $this->assertContains('missing script file', $e->getMessage()); + + return; + } + $this->fail('Exception for "missing file" has not been raised.'); + } +} + +/** + * test function + */ +function insert_test($params, $template) +{ + return "insert function parameter value $params[foo]"; +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.insertplugintest.php b/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.insertplugintest.php new file mode 100644 index 00000000..cd2e27cd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.insertplugintest.php @@ -0,0 +1,7 @@ +tpl_vars[$params['var']]->value; +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Insert/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/inner.tpl b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/inner.tpl new file mode 100644 index 00000000..e5f67304 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/inner.tpl @@ -0,0 +1 @@ +Inner template diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest.tpl b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest.tpl new file mode 100644 index 00000000..579f2548 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest.tpl @@ -0,0 +1 @@ +{insert name='insertplugintest' foo=$foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest2.tpl b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest2.tpl new file mode 100644 index 00000000..a1834ab0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest2.tpl @@ -0,0 +1,2 @@ +{insert name='test2' var='insert'} +{include 'inner.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Insert/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Insert/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Literal/LiteralTest.php b/tests/UnitTests/TemplateSource/TagTests/Literal/LiteralTest.php new file mode 100644 index 00000000..972f9e25 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Literal/LiteralTest.php @@ -0,0 +1,67 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /* + * Test literal tag + */ + public function testLiteralTag() + { + $tpl = $this->smarty->createTemplate("string:{literal} {\$foo} {/literal}"); + $this->assertEquals(' {$foo} ', $this->smarty->fetch($tpl)); + } + + /* + * Test auto literal space + */ + public function testAutoLiteralSpace() + { + $tpl = $this->smarty->createTemplate("string: { \$foo} "); + $tpl->assign('foo', 'literal'); + $this->assertEquals(' { $foo} ', $this->smarty->fetch($tpl)); + } + + /* + * Test auto literal line break + */ + public function testAutoLiteralLineBreak() + { + $tpl = $this->smarty->createTemplate("string: {\n\$foo} "); + $tpl->assign('foo', 'literal'); + $this->assertEquals(" {\n\$foo} ", $this->smarty->fetch($tpl)); + } + + /* + * Test auto literal disabled + */ + public function testAutoLiteralDisabled() + { + $this->smarty->setAutoLiteral(false); + $tpl = $this->smarty->createTemplate("string: { \$foo} "); + $tpl->assign('foo', 'literal'); + $this->assertEquals(' literal ', $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Literal/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Literal/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Literal/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Literal/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Literal/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Literal/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/CompileMakeNocacheTest.php b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/CompileMakeNocacheTest.php new file mode 100644 index 00000000..718c7313 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/CompileMakeNocacheTest.php @@ -0,0 +1,309 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test {make_nocache} tags caching disabled + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001 + */ + public function testMakeNocache_001($foo, $result) + { + if ($foo) { + $this->smarty->assign('foo', $foo); + } + $this->assertEquals($result, $this->smarty->fetch('001_test_foo.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001 + */ + public function dataTestMakeNocache001() + { + + /* + * $foo + * result + * + */ + return array(array(1, '#001_test_foo.tpl:$foo =1'), array(2, '#001_test_foo.tpl:$foo =2'), + array(null, '#001_test_foo.tpl:$foo =>unassigned<'),); + } + + /** + * Test {make_nocache} cached tags + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_1 + */ + public function testMakeNocache_001_1($foo, $result) + { + $this->smarty->setCaching(true); + if ($foo) { + $this->smarty->assign('foo', $foo); + } + $this->assertEquals($result, $this->smarty->fetch('001_test_foo.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_1 + */ + public function dataTestMakeNocache001_1() + { + + /* + * $foo + * result + * + */ + return array(array(1, '#001_test_foo.tpl:$foo =1'), array(2, '#001_test_foo.tpl:$foo =1'), + array(null, '#001_test_foo.tpl:$foo =1'),); + } + + /** + * Test {make_nocache} cached tags existing nocahe variable + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_2 + */ + public function testMakeNocache_001_2($foo, $result) + { + $this->smarty->setCaching(true); + if ($foo) { + $this->smarty->assign('foo', $foo, true); + } + $this->assertEquals($result, $this->smarty->fetch('001_test_foo.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_2 + */ + public function dataTestMakeNocache001_2() + { + + /* + * $foo + * result + * + */ + return array(array(1, '#001_test_foo.tpl:$foo =1'), array(2, '#001_test_foo.tpl:$foo =2'), + array(null, '#001_test_foo.tpl:$foo =1'),); + } + + /** + * Test {make_nocache} cached tags reassign + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_3 + */ + public function testMakeNocache_001_3($foo, $result) + { + $this->smarty->setCaching(true); + if ($foo) { + $this->smarty->assign('foo', $foo); + } + $this->smarty->assign('bar', $foo + 4, true); + $this->assertEquals($result, $this->smarty->fetch('001_test_foo_assign.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_3 + */ + public function dataTestMakeNocache001_3() + { + + /* + * $foo + * result + * + */ + return array(array(1, '#001_test_foo_assign.tpl:$foo =5'), array(2, '#001_test_foo_assign.tpl:$foo =6'), + array(null, '#001_test_foo_assign.tpl:$foo =4'),); + } + + /** + * Test {make_nocache} cached tags {if} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_4 + */ + public function testMakeNocache_001_4($foo, $bar, $result) + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', $foo); + $this->smarty->assign('bar', $bar); + $this->assertEquals($result, $this->smarty->fetch('001_test_foo_if.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_4 + */ + public function dataTestMakeNocache001_4() + { + /* + * $foo + * $bar + * result + * + */ + return array(array(10, 9, 'greater'), array(9, 10, 'greater'),); + } + + /** + * Test {make_nocache} cached tags {if} nocache + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_5 + */ + public function testMakeNocache_001_5($foo, $bar, $result) + { + $this->smarty->setCaching(true); + $this->smarty->compile_id = 1; + if ($foo) { + $this->smarty->assign('foo', $foo); + } + $this->smarty->assign('bar', $bar, true); + $this->assertEquals($result, $this->smarty->fetch('001_test_foo_if.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_5 + */ + public function dataTestMakeNocache001_5() + { + /* + * $foo + * $bar + * result + * + */ + return array(array(10, 9, 'greater'), array(9, 10, 'not greater'), array(null, 11, 'not greater'), + array(null, 2, 'greater'),); + } + + /** + * Test {make_nocache} cached tags {foreach} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_6 + */ + public function testMakeNocache_001_6($foo, $bar, $result) + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', $foo, true); + $this->smarty->assign('bar', $bar); + $this->assertEquals($result, $this->smarty->fetch('001_test_foo_foreach.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_6 + */ + public function dataTestMakeNocache001_6() + { + + /* + * $foo + * $bar + * result + * + */ + return array(array(2, array(1, 2, 3, 4), ' 1 2match 3 4'), array(3, array(7, 8, 9), ' 1 2 3match 4'),); + } + + /** + * Test {make_nocache} cached tags {foreach} nocache + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_7 + */ + public function testMakeNocache_001_7($foo, $bar, $result) + { + $this->smarty->setCaching(true); + $this->smarty->compile_id = 1; + $this->smarty->assign('foo', $foo, true); + $this->smarty->assign('bar', $bar, true); + $this->assertEquals($result, $this->smarty->fetch('001_test_foo_foreach.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_7 + */ + public function dataTestMakeNocache001_7() + { + + /* + * $foo + * $bar + * result + * + */ + return array(array(2, array(1, 2, 3, 4), ' 1 2match 3 4'), array(7, array(7, 8, 9), ' 7match 8 9'),); + } + /** + * Test {make_nocache} with values containing '\' + * + * @preserveGlobalState disabled + */ + public function testMakeNocache_002() + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', 'uwe\'s'); + $this->assertEquals($this->strip('uwe\'s'), $this->smarty->fetch('002_test_backslash.tpl')); + } + + /** + * Test {make_nocache} with values containing spaces + * + * @preserveGlobalState disabled + */ + public function testMakeNocache_003() + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', 'the Smarty template engine'); + $this->assertEquals('the Smarty template engine', $this->smarty->fetch('003_test_spaces.tpl')); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo.tpl new file mode 100644 index 00000000..4253b8dd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo.tpl @@ -0,0 +1 @@ +{make_nocache $foo}{checkvar var=foo types='template' nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_assign.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_assign.tpl new file mode 100644 index 00000000..7042daf3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_assign.tpl @@ -0,0 +1 @@ +{make_nocache $foo}{$foo=$bar nocache}{checkvar var=foo types='template' nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_foreach.tpl new file mode 100644 index 00000000..326fa569 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_foreach.tpl @@ -0,0 +1,3 @@ +{foreach $bar as $i} + {$i}{make_nocache $i}{if $i == $foo}match{/if} +{/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_if.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_if.tpl new file mode 100644 index 00000000..fe2c88e1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_if.tpl @@ -0,0 +1 @@ +{make_nocache $foo}{if $foo > $bar}greater{else}not greater{/if} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/002_test_backslash.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/002_test_backslash.tpl new file mode 100644 index 00000000..ab21fba8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/002_test_backslash.tpl @@ -0,0 +1 @@ +{make_nocache $foo}{$foo nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/003_test_spaces.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/003_test_spaces.tpl new file mode 100644 index 00000000..ab21fba8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/003_test_spaces.tpl @@ -0,0 +1 @@ +{make_nocache $foo}{$foo nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Nocache/CompileNocacheTest.php b/tests/UnitTests/TemplateSource/TagTests/Nocache/CompileNocacheTest.php new file mode 100644 index 00000000..a0a7e373 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Nocache/CompileNocacheTest.php @@ -0,0 +1,75 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test nocache tag caching disabled + */ + public function testNocacheCachingNo() + { + $this->smarty->caching = 0; + $this->smarty->assign('foo', 0); + $this->smarty->assign('bar', 'A'); + $content = $this->smarty->fetch('test_nocache_tag.tpl'); + $this->assertContains("root 2A", $content); + $this->assertContains("include 4A", $content); + $this->smarty->assign('foo', 2); + $this->smarty->assign('bar', 'B'); + $content = $this->smarty->fetch('test_nocache_tag.tpl'); + $this->assertContains("root 4B", $content); + $this->assertContains("include 6B", $content); + } + + /** + * test nocache tag caching enabled + */ + public function testNocacheCachingYes1() + { + $this->smarty->caching = 1; + $this->smarty->assign('foo', 0); + $this->smarty->assign('bar', 'A'); + $content = $this->smarty->fetch('test_nocache_tag.tpl'); + $this->assertContains("root 2A", $content); + $this->assertContains("include 4A", $content); + + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testNocacheCachingYes2() + { + $this->smarty->caching = 1; + $this->smarty->assign('foo', 2); + $this->smarty->assign('bar', 'B'); + $content = $this->smarty->fetch('test_nocache_tag.tpl'); + $this->assertContains("root 4A", $content); + $this->assertContains("include 6A", $content); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Nocache/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Nocache/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Nocache/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag.tpl b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag.tpl new file mode 100644 index 00000000..fed2d1fa --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag.tpl @@ -0,0 +1,2 @@ +
root {nocache}{$foo + 2}{/nocache}{$bar} +{include file='test_nocache_tag_include.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag_include.tpl b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag_include.tpl new file mode 100644 index 00000000..6ef97be7 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag_include.tpl @@ -0,0 +1 @@ +
include {nocache}{$foo + 4}{/nocache}{$bar} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Nocache/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/CompilePhpTest.php b/tests/UnitTests/TemplateSource/TagTests/Php/CompilePhpTest.php new file mode 100644 index 00000000..fb34e9f4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/CompilePhpTest.php @@ -0,0 +1,198 @@ + tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {php} and tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompilePhpTest extends PHPUnit_Smarty +{ + public $loadSmartyBC = true; + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->setUseSubDirs(true); + $this->smartyBC->setUseSubDirs(true); + $this->smartyBC->disableSecurity(); + $this->smarty->disableSecurity(); + $this->smarty->setCompileId($this->getName()); + $this->smartyBC->setCompileId($this->getName()); + } + + public function testInit() + { + $this->cleanDirs(); + } + + + /** + * Test + * @run InSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + * + */ + public function testPHP($phpHandling, $templateFile, $result, $testName) + { + $result = str_replace("\r", '', $result); + $this->smartyBC->force_compile = true; + $this->smartyBC->php_handling = $phpHandling; + $this->smartyBC->compile_id = $testName.$this->smartyBC->php_handling ; + $tpl = $this->smartyBC->createTemplate($templateFile); + if ($phpHandling == Smarty::PHP_PASSTHRU || $phpHandling == Smarty::PHP_QUOTE) { + $result = str_replace("\r", '', $tpl->source->getContent()); + } + if ($phpHandling == Smarty::PHP_QUOTE) { + $result = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|()|(\?>)|(%>)|(<\/script>)#i', array($this, 'quote'), $result); + } + $content = $tpl->fetch(); + $this->assertEquals($result, $content, $testName); + } /** + * Test + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + * + */ + public function testPHPcaching($phpHandling, $templateFile, $result, $testName) + { + $result = str_replace("\r", '', $result); + $this->smartyBC->php_handling = $phpHandling; + $this->smartyBC->compile_id = $testName.$this->smartyBC->php_handling ; + $this->smartyBC->caching = true; + $this->smartyBC->force_cache = true; + $tpl = $this->smartyBC->createTemplate($templateFile); + if ($phpHandling == Smarty::PHP_PASSTHRU || $phpHandling == Smarty::PHP_QUOTE) { + $result = str_replace("\r", '', $tpl->source->getContent()); + } + if ($phpHandling == Smarty::PHP_QUOTE) { + $result = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|()|(\?>)|(%>)|(<\/script>)#i', array($this, 'quote'), $result); + } + $content = $tpl->fetch(); + $this->assertEquals($result, $content, $testName); + } + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage $smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it + */ + + public function testPHP_ALLOW_error() + { + $this->smarty->setPhpHandling(Smarty::PHP_ALLOW); + $content = $this->smarty->fetch("string:aa ae"); + } + + /** + * test {php nocache}{/php} tag + */ + public function testPHP_Tag_Nocache1() + { + $this->smartyBC->caching = 1; + $this->smartyBC->assign('foo', 'foo'); + $this->smartyBC->compile_id = 'Tag nocache' ; + $content = $this->smartyBC->fetch('phptag_nocache.tpl'); + $this->assertEquals('-->foo<--', $content,'Tag nocache 1'); + } + + public function testPHP_Tag_Nocache2() + { + $this->smartyBC->caching = 1; + $this->smartyBC->assign('foo', 'bar'); + $this->smartyBC->compile_id = 'Tag nocache' ; + $content = $this->smartyBC->fetch('phptag_nocache.tpl'); + $this->assertEquals('-->bar<--', $content,'Tag nocache 2'); + } + /** + * test {php no cache}illegal option + * @expectedException SmartyCompilerException + * @expectedExceptionMessage illegal value of option flag 'no cache' + * + */ + public function testPHP_Tag_IllegalOption() + { + $content = $this->smartyBC->fetch("string:aa {php no cache} echo 'hallo'; {/php} ae"); + } + + /** + * Test regression that plugin names starting with 'php' do work + */ + public function testPHPfooPlugin() + { + $this->smarty->addPluginsDir("./PHPunitplugins/"); + $this->smartyBC->compile_id = 'Tag nocache' ; + $this->assertEquals('phptest okay', $this->smarty->fetch('string:{phptest}'),'testPHPfooPlugin'); + } + + public function data() + { + $shortTag = ini_get('short_open_tag') == 1; + $aspTag = ini_get('asp_tags') == 1; + + $data = array( + /* + * php_handling + * template file + * result + * text + */ + array(Smarty::PHP_REMOVE, 'php.tpl', '--><--', 'PHP_REMOVE, \'php.tpl\''), + array(Smarty::PHP_PASSTHRU, 'php.tpl', '', 'PHP_PASSTHRU, \'php.tpl\''), + array(Smarty::PHP_QUOTE, 'php.tpl', '', 'PHP_QUOTE, \'php.tpl\''), + array(Smarty::PHP_ALLOW, 'php.tpl', '--> hello world <--', 'PHP_ALLOW, \'php.tpl\''), + array(Smarty::PHP_REMOVE, 'php_line_comment.tpl', '--><--', 'PHP_REMOVE, \'php_line_comment.tpl\''), + array(Smarty::PHP_PASSTHRU, 'php_line_comment.tpl', '', 'PHP_PASSTHRU, \'php_line_comment.tpl\''), + array(Smarty::PHP_QUOTE, 'php_line_comment.tpl', '', 'PHP_QUOTE, \'php_line_comment.tpl\''), + array(Smarty::PHP_ALLOW, 'php_line_comment.tpl', '--> hello world <--', 'PHP_ALLOW, \'php_line_comment.tpl\''), + array(Smarty::PHP_REMOVE, 'php_block_comment.tpl', '--><--', 'PHP_REMOVE, \'php_block_comment.tpl\''), + array(Smarty::PHP_PASSTHRU, 'php_block_comment.tpl', '', 'PHP_PASSTHRU, \'php_block_comment.tpl\''), + array(Smarty::PHP_QUOTE, 'php_block_comment.tpl', '', 'PHP_QUOTE, \'php_block_comment.tpl\''), + array(Smarty::PHP_ALLOW, 'php_block_comment.tpl', '--> hello world <--', 'PHP_ALLOW, \'php_block_comment.tpl\''), + array(Smarty::PHP_REMOVE, 'php2.tpl', '--><--', 'PHP_REMOVE, \'php2.tpl\''), + array(Smarty::PHP_PASSTHRU, 'php2.tpl', '', 'PHP_PASSTHRU, \'php2.tpl\''), + array(Smarty::PHP_QUOTE, 'php2.tpl', '', 'PHP_QUOTE, \'php2.tpl\''), + array(Smarty::PHP_ALLOW, 'php2.tpl', $shortTag || strpos(phpversion(), 'hhvm') !== false ? '--> hello world <--' : '--> \'; +?><--', 'PHP_ALLOW, \'php2.tpl\''), + array(Smarty::PHP_REMOVE, 'asp.tpl', '--><--', 'PHP_REMOVE, \'asp.tpl\''), + array(Smarty::PHP_PASSTHRU, 'asp.tpl', '', 'PHP_PASSTHRU, \'asp.tpl\''), + array(Smarty::PHP_QUOTE, 'asp.tpl', '', 'PHP_QUOTE, \'asp.tpl\''), + array(Smarty::PHP_ALLOW, 'asp.tpl', $aspTag ? '-->hello world <% %> <--' : '--><% echo \'hello world \'; +echo \'<% \'; +echo \'%> \'; +%><--', 'PHP_ALLOW, \'asp.tpl\''), + array(Smarty::PHP_REMOVE, 'script.tpl', '

', 'PHP_REMOVE, \'script.tpl\''), + array(Smarty::PHP_PASSTHRU, 'script.tpl', '', 'PHP_PASSTHRU, \'script.tpl\''), + array(Smarty::PHP_QUOTE, 'script.tpl', '', 'PHP_QUOTE, \'script.tpl\''), + array(Smarty::PHP_ALLOW, 'phptag.tpl', '--> hello world {php} {/php} <--', 'PHP_ALLOW, \'phptag.tpl\''), + array(Smarty::PHP_ALLOW, 'phptag_line_comment.tpl', '--> hello world {php} {/php} <--', 'PHP_ALLOW, \'phptag_line_comment.tpl\''), + array(Smarty::PHP_ALLOW, 'phptag_block_comment.tpl', '--> hello world {php} {/php} <--', 'PHP_ALLOW, \'phptag_block_comment.tpl\''), + array(Smarty::PHP_ALLOW, 'phptag_literal.tpl', '-->{ php} echo \' hello world \'; +echo \'foo \'; +echo \'bar \'; +$foo = 3; +{ /php}<--', 'PHP_ALLOW, \'phptag_literal.tpl\''), + ); + if (version_compare(phpversion(), '5.7.0', '<')) { + $data[] = array(Smarty::PHP_ALLOW, 'script.tpl', '
This is a script
5
', 'PHP_ALLOW, \'script.tpl\''); + } + return $data; + } + /* + * Call back function for $php_handling = PHP_QUOTE + * + */ + private function quote($match) + { + return htmlspecialchars($match[0], ENT_QUOTES); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/PHPunitplugins/function.phptest.php b/tests/UnitTests/TemplateSource/TagTests/Php/PHPunitplugins/function.phptest.php new file mode 100644 index 00000000..922609e4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/PHPunitplugins/function.phptest.php @@ -0,0 +1,5 @@ +<% echo 'hello world '; +echo '<% '; +echo '%> '; +%><-- \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/php.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php.tpl new file mode 100644 index 00000000..8a9acec6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php.tpl @@ -0,0 +1,5 @@ +--> '; +$foo = 3; +?><-- \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/php2.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php2.tpl new file mode 100644 index 00000000..44beed4a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php2.tpl @@ -0,0 +1,4 @@ +--> '; +?><-- \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_block_comment.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_block_comment.tpl new file mode 100644 index 00000000..4524e45e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_block_comment.tpl @@ -0,0 +1,16 @@ +--> '; +$foo = 3; +?><-- \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_line_comment.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_line_comment.tpl new file mode 100644 index 00000000..176d3580 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_line_comment.tpl @@ -0,0 +1,12 @@ +--> '; +$foo = 3; +?><-- \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag.tpl new file mode 100644 index 00000000..f7b92e9f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag.tpl @@ -0,0 +1,5 @@ +-->{php} echo ' hello world '; +echo '{php} '; +echo '{/php} '; +$foo = 3; +{/php}<-- \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_block_comment.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_block_comment.tpl new file mode 100644 index 00000000..af837c78 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_block_comment.tpl @@ -0,0 +1,16 @@ +-->{php} echo ' hello world '; +/* +* comment {/php} is okay +* +* comment {/php} once again {/php} foo +*/ + +echo '{php} '; + +/* +* other comment <% foo +*/ + +echo '{/php} '; +$foo = 3; +{/php}<-- \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_line_comment.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_line_comment.tpl new file mode 100644 index 00000000..16907ce2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_line_comment.tpl @@ -0,0 +1,12 @@ +-->{php} echo ' hello world '; +// comment {/php} is okay +// +// comment {/php} once again {/php} foo + +echo '{php} '; + +// other comment <% foo + +echo '{/php} '; +$foo = 3; +{/php}<-- \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_literal.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_literal.tpl new file mode 100644 index 00000000..24420541 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_literal.tpl @@ -0,0 +1,5 @@ +-->{ php} echo ' hello world '; +echo 'foo '; +echo 'bar '; +$foo = 3; +{ /php}<-- \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_nocache.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_nocache.tpl new file mode 100644 index 00000000..086a25f0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_nocache.tpl @@ -0,0 +1,2 @@ +-->{php nocache} echo $_smarty_tpl->getTemplateVars('foo'); +{/php}<-- \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/script.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/script.tpl new file mode 100644 index 00000000..076e32dd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/script.tpl @@ -0,0 +1 @@ +

\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Php/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php new file mode 100644 index 00000000..382c73ce --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php @@ -0,0 +1,136 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = "This is foo. This is foo. This is foo.\nThis is foo. This is foo. This is foo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo\nfoo. bar foo bar foo foo. bar foo bar\nfoo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = "This is foo. This is foo. This is foo.\nThis is foo. This is foo. This is foo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo\nfoo. bar foo bar foo foo. bar foo bar\nfoo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testIndent() + { + $result = " This is foo. This is foo. This is\n foo. This is foo. This is foo. This\n is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo. bar foo bar foo foo.\n bar foo bar foo foo. bar foo bar foo\n foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testIndentWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = " This is foo. This is foo. This is\n foo. This is foo. This is foo. This\n is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo. bar foo bar foo foo.\n bar foo bar foo foo. bar foo bar foo\n foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testIndentFirst() + { + $result = " This is foo. This is foo. This\n is foo. This is foo. This is foo.\n This is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar\n foo foo. bar foo bar foo foo. bar\n foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testIndentFirstWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = " This is foo. This is foo. This\n is foo. This is foo. This is foo.\n This is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar\n foo foo. bar foo bar foo foo. bar\n foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testIndentchar() + { + $result = "####This is foo. This is foo. This is\n####foo. This is foo. This is foo. This\n####is foo.\n\n####This is bar.\n\n####bar foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo. bar foo bar foo foo.\n####bar foo bar foo foo. bar foo bar foo\n####foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testIndentcharWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = "####This is foo. This is foo. This is\n####foo. This is foo. This is foo. This\n####is foo.\n\n####This is bar.\n\n####bar foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo. bar foo bar foo foo.\n####bar foo bar foo foo. bar foo bar foo\n####foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testIndentcharFirst() + { + $result = "########This is foo. This is foo. This\n####is foo. This is foo. This is foo.\n####This is foo.\n\n########This is bar.\n\n########bar foo bar foo foo. bar foo bar\n####foo foo. bar foo bar foo foo. bar\n####foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4 indent_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testIndentcharFirstWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = "########This is foo. This is foo. This\n####is foo. This is foo. This is foo.\n####This is foo.\n\n########This is bar.\n\n########bar foo bar foo foo. bar foo bar\n####foo foo. bar foo bar foo foo. bar\n####foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4 indent_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testWrapchar() + { + $result = " This is foo. This is foo. This is#foo. This is foo. This is foo. This#is foo.## This is bar.## bar foo bar foo foo. bar foo bar foo#foo. bar foo bar foo foo. bar foo#bar foo foo. bar foo bar foo foo.#bar foo bar foo foo. bar foo bar foo#foo.##"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 wrap_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testWrapcharWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = " This is foo. This is foo. This is#foo. This is foo. This is foo. This#is foo.## This is bar.## bar foo bar foo foo. bar foo bar foo#foo. bar foo bar foo foo. bar foo#bar foo foo. bar foo bar foo foo.#bar foo bar foo foo. bar foo bar foo#foo.##"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 wrap_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testStyleEmail() + { + $result = "This is foo. This is foo. This is foo. This is foo. This is foo. This is\nfoo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo\nfoo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat style="email"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testStyleEmailWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = "This is foo. This is foo. This is foo. This is foo. This is foo. This is\nfoo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo\nfoo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat style="email"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginBlock/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginBlock/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php new file mode 100644 index 00000000..acea7def --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php @@ -0,0 +1,85 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + +/** +* test {fetch} from UIR +* +* @runInSeparateProcess +* @preserveGlobalState disabled +*/ + public function testFetchUri() + { + $this->assertContains('Preface | Smarty', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}')); + } + +/** +* test {fetch} invalid uri +* +* @expectedException SmartyException +* @expectedExceptionMessage {fetch} cannot read resource 'https://foo.smarty.net/foo.dat' +* @runInSeparateProcess +* @preserveGlobalState disabled +*/ + public function testFetchInvalidUri() + { + $result = $this->smarty->fetch('string:{fetch file="https://foo.smarty.net/foo.dat"}'); + } + + /** + * test {fetch file=...} access to file from path not aloo/wed by security settings + * + * @expectedException SmartyException + * @expectedExceptionMessage not trusted file path + * @run InSeparateProcess + * @preserveGlobalState disabled + */ + public function testFetchSecurity() + { + $this->cleanDirs(); + $dir=$this->smarty->getTemplateDir(); + $this->smarty->enableSecurity(); + $result = $this->smarty->fetch('string:{fetch file=\''. $dir[0]. '../../../../../etc/passwd\'}'); + } + /** + * test {fetch file=...} access to file from path not aloo/wed by security settings + * + * @expectedException SmartyException + * @expectedExceptionMessage not trusted file path + * @run InSeparateProcess + * @preserveGlobalState disabled + */ + public function testFetchSecurity2() + { + $this->cleanDirs(); + $dir=$this->smarty->getTemplateDir(); + $this->smarty->enableSecurity(); + $this->smarty->setTemplateDir('/templates'); + $result = $this->smarty->fetch('string:{fetch file="/templates/../etc/passwd"}'); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php new file mode 100644 index 00000000..3d28dc67 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php @@ -0,0 +1,415 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testAssociativeArray() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testSeparateArrays() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" values=$cust_ids output=$cust_names selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_ids', array(1000, 1001, 1002, 1003)); + $tpl->assign('cust_names', array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testIterator() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" values=$cust_ids output=$cust_names selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_ids', array(1000, 1001, 1002, 1003)); + $tpl->assign('cust_names', new ArrayIterator(array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown', + ))); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNoLabels() + { + $n = "\n"; + $expected = 'Joe Schmoe
' + . $n . 'Jack Smith
' + . $n . 'Jane Johnson
' + . $n . 'Charlie Brown
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios labels=false selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testWithId() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id label_ids=true separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 'work s ä' => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullString() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$options selected=$selected separator="
"}'); + $tpl->assign('selected', "null"); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullValue() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$options selected=$selected separator="
"}'); + $tpl->assign('selected', null); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroValue() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$options selected=$selected separator="
"}'); + $tpl->assign('selected', 0); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroStringValue() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$options selected=$selected separator="
"}'); + $tpl->assign('selected', "0"); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testEmptyStringValue() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$options selected=$selected separator="
"}'); + $tpl->assign('selected', ""); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObject() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObjectList() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => new _object_toString('Joe Schmoe'), + 1001 => new _object_toString('Jack Smith'), + 1002 => new _object_toString('Jane Johnson'), + 1003 => new _object_toString('Charlie Brown'), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + protected $_errors = array(); + + public function error_handler($errno, $errstr, $errfile, $errline, $errcontext) + { + $this->_errors[] = $errstr; + } + + public function testObjectNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', new _object_noString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testObjectListNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => new _object_toString('Joe Schmoe'), + 1001 => new _object_noString('Jack Smith'), + 1002 => new _object_toString('Jane Johnson'), + 1003 => new _object_toString('Charlie Brown'), + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testDisabled() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
" disabled="1"}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testDisabledStrict1() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
" disabled=true strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + public function testDisabledStrict2() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
" disabled=1 strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + + } + public function testDisabledStrict3() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
" disabled="disabled" strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlImageTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlImageTest.php new file mode 100644 index 00000000..4293450f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlImageTest.php @@ -0,0 +1,27 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testFoo() + { + // TODO: UnitTests for {html_image} + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php new file mode 100644 index 00000000..c5f7e6c9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php @@ -0,0 +1,502 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testAssociativeArray() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', 9904); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testSeparateArrays() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" values=$cust_ids output=$cust_names selected=$customer_id}'); + $tpl->assign('customer_id', 92); + $tpl->assign('cust_ids', array(56, 92, 13)); + $tpl->assign('cust_names', array( + 'Joe Schmoe', + 'Jane Johnson', + 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testIterator() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', 9904); + $tpl->assign('myOptions', new ArrayIterator(array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + ))); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testOptgroup() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$lookups selected=$fav}'); + $tpl->assign('fav', 7); + $tpl->assign('lookups', array( + 'Sport' => array( + 6 => 'Golf', + 9 => 'Cricket', + 7 => 'Swim' + ), + 'Rest' => array( + 3 => 'Sauna', + 1 => 'Massage' + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullString() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', "null"); + $tpl->assign('array', array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + 'optgroup' => array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullValue() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', null); + $tpl->assign('array', array( + '' => 'empty string', + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + 'optgroup' => array( + '' => 'empty string', + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroValue() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', 0); + $tpl->assign('array', array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + 'optgroup' => array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroStringValue() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', "0"); + $tpl->assign('array', array( + 'null' => "null", + 0 => 'zero', + 1 => 'one', + 2 => 'two', + 'optgroup' => array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testEmptyStringValue() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', ""); + $tpl->assign('array', array( + 'null' => 'null', + '0' => 'zero', + '1' => 'one', + '2' => 'two', + 'optgroup' => array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testEmptyStringValues() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', ""); + $tpl->assign('array', array( + '' => 'empty string', + 'null' => 'null', + '0' => 'zero', + '1' => 'one', + '2' => 'two', + 'optgroup' => array( + '' => 'empty string', + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObject() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObjectList() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => new _object_toString('Joe Schmoe'), + 9904 => new _object_toString('Jack Smith'), + 2003 => new _object_toString('Charlie Brown'), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + protected $_errors = array(); + + public function error_handler($errno, $errstr, $errfile, $errline, $errcontext) + { + $this->_errors[] = $errstr; + } + + public function testObjectNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', new _object_noString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testObjectListNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => new _object_toString('Joe Schmoe'), + 9904 => new _object_noString('Jack Smith'), + 2003 => new _object_toString('Charlie Brown'), + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testDisabled() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect disabled=1}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testDisabledStrict() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect disabled=1 strict=true}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect disabled=true strict=true}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect disabled="disabled" strict=true}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php new file mode 100644 index 00000000..0f5789b2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php @@ -0,0 +1,410 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testAssociativeArray() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testSeparateArrays() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" values=$cust_ids output=$cust_names selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_ids', array(1000, 1001, 1002, 1003)); + $tpl->assign('cust_names', array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testIterator() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" values=$cust_ids output=$cust_names selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_ids', array(1000, 1001, 1002, 1003)); + $tpl->assign('cust_names', new ArrayIterator(array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown', + ))); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNoLabels() + { + $n = "\n"; + $expected = 'Joe Schmoe
' + . $n . 'Jack Smith
' + . $n . 'Jane Johnson
' + . $n . 'Charlie Brown
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios labels=false selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testWithId() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id label_ids=true separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 'work s ä' => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullString() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$options selected=$selected separator="
"}'); + $tpl->assign('selected', "null"); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullValue() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$options selected=$selected separator="
"}'); + $tpl->assign('selected', null); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroValue() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$options selected=$selected separator="
"}'); + $tpl->assign('selected', 0); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroStringValue() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$options selected=$selected separator="
"}'); + $tpl->assign('selected', "0"); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testEmptyStringValue() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$options selected=$selected separator="
"}'); + $tpl->assign('selected', ""); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObject() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObjectList() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => new _object_toString('Joe Schmoe'), + 1001 => new _object_toString('Jack Smith'), + 1002 => new _object_toString('Jane Johnson'), + 1003 => new _object_toString('Charlie Brown'), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + protected $_errors = array(); + + public function error_handler($errno, $errstr, $errfile, $errline, $errcontext) + { + $this->_errors[] = $errstr; + } + + public function testObjectNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', new _object_noString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testObjectListNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => new _object_toString('Joe Schmoe'), + 1001 => new _object_noString('Jack Smith'), + 1002 => new _object_toString('Jane Johnson'), + 1003 => new _object_toString('Charlie Brown'), + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testDisabled() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
" disabled=1}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testDisabledStrict() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
" disabled=true strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
" disabled=1 strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
" disabled="disabled" strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php new file mode 100644 index 00000000..8f4f79de --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php @@ -0,0 +1,604 @@ + ' + + + + + + + + + + +', + 'default' => ' + + + + + + + + + + +', + 'format_%b' => ' + + + + + + + + + + +', + 'format_value_%b' => ' + + + + + + + + + + +', + 'names' => ' + + + + + + + + + + +', + ); + + protected $days = array( + 'none' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + 'default' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + 'format_%03d' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + 'format_value_%03d' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + ); + + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + + $year = date('Y'); + $this->now = mktime(15, 0, 0, 2, 20, $year); + $o = ''; + for ($i = 2005; $i < $year; $i ++) { + $o .= "\n"; + } + $o .= ""; + $this->years['start_2005'] = $o; + $this->years['end_2005'] = $o; + + $o = ""; + for ($i = $year + 1; $i < $year + 6; $i ++) { + $o .= "\n"; + } + $this->years['start_+5'] = $o; + $this->years['end_+5'] = $o; + + $o = ''; + for ($i = $year - 5; $i < $year; $i ++) { + $o .= "\n"; + } + $o .= ""; + $this->years['start_-5'] = $o; + $this->years['end_-5'] = $o; + + $this->years['default'] = ""; + $this->years['none'] = ""; + } + + protected function reverse($string) + { + $t = explode("\n", $string); + $t = array_reverse($t); + + return join("\n", $t); + } + + public function testDefault() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . '}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testPrefix() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' prefix="foobar_"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testFieldArray() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_array="namorized"}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_array="namorized" prefix="foobar_"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testExtra() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_extra="data-foo=\"xy\""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_extra="data-foo=\"day\"" month_extra="data-foo=\"month\"" year_extra="data-foo=\"year\""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' data_foo="foo"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testFieldOrder() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="DMY"}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="YMD"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testFieldSeparator() + { + $n = "\n"; + $result = '' + . ' - ' + . ' - '; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="DMY" field_separator=" - "}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . ' / ' + . ' / '; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="YMD" field_separator=" / "}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEmpty() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_empty=""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_empty="all"}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_empty=""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_empty="year" month_empty="month" day_empty="day"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEmptyUnset() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=null all_empty=""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=null all_empty="all"}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=null year_empty=""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=null year_empty="year" month_empty="month" day_empty="day"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testId() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_id=""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_id="all-"}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_id="year" month_id="month" day_id="day"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testStartYearAbsolute() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year=2005}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testStartYearRelative() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="+5"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testStartYearRelativeNegative() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="-5"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEndYearAbsolute() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year=2005}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEndYearRelative() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year="+5"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEndYearRelativeNegative() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year="-5"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testDisplayDaysMonthYear() + { + $n = "\n"; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_days=false}'); + $result = '' + . $n . ''; + $this->assertEquals($result, $tpl->fetch()); + + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_months=false}'); + $result = '' + . $n . ''; + $this->assertEquals($result, $tpl->fetch()); + + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_years=false}'); + $result = '' + . $n . ''; + $this->assertEquals($result, $tpl->fetch()); + } + + public function testYearsReversed() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year=2005 reverse_years=true}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="+5" reverse_years=true}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testYearText() + { + $year = date('Y'); + $n = "\n"; + $result = '' + . $n . '' + . $n . ""; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_as_text=true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ""; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_as_text=true prefix="foo_"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testMonthFormat() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' month_format="%b"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testMonthFormatValue() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' month_value_format="%b"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testMonthNames() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{$names = [1 => "alpha","bravo","charlie","delta","echo","foxtrot","golf","hotel","india","juliet","kilo","lima"]}{html_select_date time=' . $this->now . ' month_names=$names}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testDayFormat() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_format="%03d"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testDayFormatValue() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_value_format="%03d"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testTimeArray() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + + $date_array = array( + 'namorized' => array( + 'foobar_Month' => '02', + 'foobar_Day' => '20', + 'foobar_Year' => date('Y'), + ), + ); + + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=$date_array.namorized field_array="namorized" prefix="foobar_"}'); + $tpl->assign('date_array', $date_array); + $this->assertEquals($result, $tpl->fetch()); + + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=$date_array field_array="namorized" prefix="foobar_"}'); + $tpl->assign('date_array', $date_array); + $this->assertEquals($result, $tpl->fetch()); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectTimeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectTimeTest.php new file mode 100644 index 00000000..f152a8e8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectTimeTest.php @@ -0,0 +1,1151 @@ +setUpSmarty(dirname(__FILE__)); + $this->now = mktime(16, 15, 11, 2, 20, 2011); + } + + protected $now = null; + protected $hours = array( + 'none' => ' + + + + + + + + + + + + + + + + + + + + + + +', + 'default' => ' + + + + + + + + + + + + + + + + + + + + + + +', + '12h' => ' + + + + + + + + + + +', + 'format_%03d' => ' + + + + + + + + + + + + + + + + + + + + + + +', + 'format_value_%03d' => ' + + + + + + + + + + + + + + + + + + + + + + +', + ); + protected $minutes = array( + 'none' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + 'default' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + '30' => ' +', + '15' => ' + + +', + '10' => ' + + + + +', + '5' => ' + + + + + + + + + + +', + 'format_%03d' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + 'format_value_%03d' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + ); + protected $seconds = array( + 'none' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + 'default' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + '30' => ' +', + '15' => ' + + +', + '10' => ' + + + + +', + '5' => ' + + + + + + + + + + +', + 'format_%03d' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + 'format_value_%03d' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +', + ); + protected $meridians = array( + 'default' => ' +', + ); + + public function testDefault() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . '}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testPrefix() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' prefix="foobar_"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testFieldArray() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' field_array="namorized"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' field_array="namorized" prefix="foobar_"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testExtra() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' all_extra="data-foo=\"xy\""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' hour_extra="data-foo=\"hour\"" minute_extra="data-foo=\"minute\"" second_extra="data-foo=\"second\""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' data_foo="foo"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testFieldSeparator() + { + $n = "\n"; + $result = '' + . ' - ' + . ' - '; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' field_separator=" - "}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEmpty() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' all_empty=""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' all_empty="all"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_empty=""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' hour_empty="hour" minute_empty="minute" second_empty="second"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEmptyUnset() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=null all_empty=""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=null all_empty="all"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=null second_empty=""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=null hour_empty="hour" minute_empty="minute" second_empty="second"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testId() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' all_id=""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' all_id="all-"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' hour_id="hour" minute_id="minute" second_id="second"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDisplay() + { + $n = "\n"; + $result = ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' display_minutes=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' display_hours=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' display_hours=false display_minutes=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testMeridian1() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' use_24_hours=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMeridian2() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' use_24_hours=false display_meridian=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMeridian3() + { + $n = "\n"; + $time = mktime(0, 15, 11, 2, 20, 2011); + $result = ' +'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $time . ' use_24_hours=false display_minutes=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMeridian4() + { + $n = "\n"; + + $time = mktime(4, 15, 11, 2, 20, 2011); + $result = ' +'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $time . ' use_24_hours=false display_minutes=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMeridian5() + { + $n = "\n"; + + $time = mktime(12, 15, 11, 2, 20, 2011); + $result = ' +'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $time . ' use_24_hours=false display_minutes=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMeridian6() + { + $n = "\n"; + + $time = mktime(16, 15, 11, 2, 20, 2011); + $result = ' +'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $time . ' use_24_hours=false display_minutes=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testMinuteInterval1() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_interval=30}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMinuteInterval2() + { + $n = "\n"; + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_interval=15}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMinuteInterval3() + { + $n = "\n"; + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_interval=10}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMinuteInterval4() + { + $n = "\n"; + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_interval=5}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testSecondInterval1() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_interval=30}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testSecondInterval2() + { + $n = "\n"; + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_interval=15}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testSecondInterval3() + { + $n = "\n"; + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_interval=10}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testSecondInterval4() + { + $n = "\n"; + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_interval=5}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testFormat1() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' hour_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testFormat2() + { + $n = "\n"; + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testFormat3() + { + $n = "\n"; + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testValueFormat1() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' hour_value_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testValueFormat2() + { + $n = "\n"; + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_value_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testValueFormat3() + { + $n = "\n"; + + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_value_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testTimeArray1() + { + $n = "\n"; + $time_array = array( + 'namorized' => array( + 'foobar_Hour' => '16', + 'foobar_Minute' => '15', + 'foobar_Second' => '11', + ), + ); + $result = '' + . $n . '' + . $n . ''; + + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=$time_array.namorized field_array="namorized" prefix="foobar_"}'); + $tpl->assign('time_array', $time_array); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testTimeArray2() + { + $n = "\n"; + $time_array = array( + 'namorized' => array( + 'foobar_Hour' => '16', + 'foobar_Minute' => '15', + 'foobar_Second' => '11', + ), + ); + $result = '' + . $n . '' + . $n . ''; + + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=$time_array field_array="namorized" prefix="foobar_"}'); + $tpl->assign('time_array', $time_array); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testTimeArrayMerdidian() + { + $n = "\n"; + $result = '' + . $n . '' + . $n . '' + . $n . ''; + + $time_array = array( + 'namorized' => array( + 'foobar_Hour' => '04', + 'foobar_Minute' => '15', + 'foobar_Second' => '11', + 'foobar_Meridian' => 'pm', + ), + ); + + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=$time_array use_24_hours=false field_array="namorized" prefix="foobar_"}'); + $tpl->assign('time_array', $time_array); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php new file mode 100644 index 00000000..2ea16ce5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php @@ -0,0 +1,166 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = 'me@example.com'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = 'me@example.com'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testText() + { + $result = 'send me some mail'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" text="send me some mail"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testTextWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = 'send me some mail'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" text="send me some mail"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testEncodeJavascript() + { + $result = ''; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEncodeJavascriptWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = ''; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testEncodeJavascriptCharcode() + { + $result = "\n"; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEncodeJavascriptCharcodeWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = "\n"; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testEncodeHex() + { + $result = 'me@example.com'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="hex"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEncodeHexWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = 'me@example.com'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="hex"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testSubject() + { + $result = 'me@example.com'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" subject="Hello to you!"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testSubjectWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = 'me@example.com'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" subject="Hello to you!"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testCc() + { + $result = 'me@example.com'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" cc="you@example.com,they@example.com"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testCcWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = 'me@example.com'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" cc="you@example.com,they@example.com"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testExtra() + { + $result = ''; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" extra=\'class="email"\'}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testExtraWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = ''; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" extra=\'class="email"\'}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $result = 'me+smtpext@example.com'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me+smtpext@example.com" cc="you@example.com,they@example.com" subject="hällo wörld"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = 'me+smtpext@example.com'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me+smtpext@example.com" cc="you@example.com,they@example.com" subject="hällo wörld"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/helpers/_object_tostring.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/helpers/_object_tostring.php new file mode 100644 index 00000000..4cb55e7f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/helpers/_object_tostring.php @@ -0,0 +1,26 @@ +string = (string) $string; + } + + public function __toString() + { + return $this->string; + } +} + +class _object_noString +{ + protected $string = null; + + public function __construct($string) + { + $this->string = (string) $string; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php new file mode 100644 index 00000000..a78dce31 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php @@ -0,0 +1,153 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl)); + } + + public function testDigits() + { + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl)); + } + + public function testTrueCaptials() + { + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, Delayed.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testDigitsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, Delayed.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testTrueCaptialsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, Delayed.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testQuotes() + { + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + } + + public function testQuotesWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testQuotesDigits() + { + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + } + + public function testQuotesDigitsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testQuotesTrueCapitals() + { + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + } + + public function testQuotesTrueCapitalsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testQuotesBeginning() + { + $tpl = $this->smarty->createTemplate('string:{"\"delayed. umlauts\" foo."|capitalize}'); + $this->assertEquals("\"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"\'delayed. umlauts\' foo."|capitalize}'); + $this->assertEquals("'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + } + + public function testQuotesBeginningWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"\"delayed. umlauts\" foo."|capitalize}'); + $this->assertEquals("\"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"\'delayed. umlauts\' foo."|capitalize}'); + $this->assertEquals("'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php new file mode 100644 index 00000000..87fd673f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php @@ -0,0 +1,98 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testToLatin1() + { + $encoded = "hällö wörld 1"; + $result = utf8_decode($encoded); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset}'); + $this->assertEquals(str_replace("\r", '', $result), $tpl->fetch()); + } + + public function testToLatin1WithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $encoded = "hällö wörld 2"; + $result = utf8_decode($encoded); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset}'); + $this->assertEquals($encoded, $tpl->fetch()); + Smarty::$_MBSTRING = true; + } + + public function testFromLatin1() + { + $result = "hällö wörld 3"; + $encoded = utf8_decode($result); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset}'); + $this->assertEquals(str_replace("\r", '', $result), $tpl->fetch()); + } + + public function testFromLatin1WithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $result = "hällö wörld 4"; + $encoded = utf8_decode($result); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset}'); + $this->assertEquals($encoded, $tpl->fetch()); + Smarty::$_MBSTRING = true; + } + + public function testFromUtf32le() + { + $result = "hällö wörld 5"; + $encoded = mb_convert_encoding($result, "UTF-32LE", "UTF-8"); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset:"UTF-32LE"}'); + $this->assertEquals(str_replace("\r", '', $result), $tpl->fetch()); + } + + public function testFromUtf32leWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $result = "hällö wörld 6"; + $encoded = mb_convert_encoding($result, "UTF-32LE", "UTF-8"); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset:"UTF-32LE"}'); + $this->assertEquals($encoded, $tpl->fetch()); + Smarty::$_MBSTRING = true; + } + + public function testToUtf32le() + { + $encoded = "hällö wörld 7"; + $result = mb_convert_encoding($encoded, "UTF-32LE", "UTF-8"); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset:"UTF-32LE"}'); + $this->assertEquals(str_replace("\r", '', $result), $tpl->fetch()); + } + + public function testToUtf32leWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $encoded = "hällö wörld 8"; + $result = mb_convert_encoding($encoded, "UTF-32LE", "UTF-8"); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset:"UTF-32LE"}'); + $this->assertEquals($encoded, $tpl->fetch()); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php new file mode 100644 index 00000000..b2026cc8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php @@ -0,0 +1,90 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = "29"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId ('mb'); + $result = "29"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testSpaces() + { + $result = "33"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters:true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testSpacesWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId ('mb'); + $result = "33"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters:true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $result = "29"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId ('mb'); + $result = "29"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlautsSpaces() + { + $result = "33"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters:true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsSpacesWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId ('mb'); + $result = "33"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters:true}'); + $this->assertNotEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php new file mode 100644 index 00000000..acca87cb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php @@ -0,0 +1,63 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{"hello world."|count_sentences}'); + $this->assertEquals("1", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello world. I\'m another? Sentence!"|count_sentences}'); + $this->assertEquals("3", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello world.wrong"|count_sentences}'); + $this->assertEquals("0", $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"hello world."|count_sentences}'); + $this->assertEquals("1", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello world. I\'m another? Sentence!"|count_sentences}'); + $this->assertEquals("3", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello world.wrong"|count_sentences}'); + $this->assertEquals("0", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $tpl = $this->smarty->createTemplate('string:{"hello worldä."|count_sentences}'); + $this->assertEquals("1", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello worldü. ä\'m another? Sentence!"|count_sentences}'); + $this->assertEquals("3", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello worlä.ärong"|count_sentences}'); + $this->assertEquals("0", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello worlä.wrong"|count_sentences}'); + $this->assertEquals("0", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello world.ärong"|count_sentences}'); + $this->assertEquals("0", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php new file mode 100644 index 00000000..2da98e1b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php @@ -0,0 +1,70 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Car Talk at Noon."|count_words}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Car Talk at Noon."|count_words}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testDashes() + { + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Smalltime-Dealers Will Hear Car Talk at Noon."|count_words}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDashesWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Smalltime-Dealers Will Hear Car Talk at Noon."|count_words}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Cär Talk at Nöön."|count_words}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Cär Talk at Nöön."|count_words}'); + $this->assertNotEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php new file mode 100644 index 00000000..afabe71a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php @@ -0,0 +1,210 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testHtml() + { + $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"html"}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl)); + } + + public function testHtmlWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"html"}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHtmlDouble() + { + $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"html":null:false}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl)); + } + + public function testHtmlDoubleWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"html":null:false}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHtmlall() + { + $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"htmlall"}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl)); + } + + public function testHtmlallWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"htmlall"}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHtmlallDouble() + { + $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"htmlall":null:false}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl)); + } + + public function testHtmlallDoubleWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"htmlall":null:false}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUrl() + { + $tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"url"}'); + $this->assertEquals("http%3A%2F%2Fsome.encoded.com%2Furl%3Fparts%23foo", $this->smarty->fetch($tpl)); + } + + public function testUrlWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"url"}'); + $this->assertEquals("http%3A%2F%2Fsome.encoded.com%2Furl%3Fparts%23foo", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUrlpathinfo() + { + $tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"urlpathinfo"}'); + $this->assertEquals("http%3A//some.encoded.com/url%3Fparts%23foo", $this->smarty->fetch($tpl)); + } + + public function testUrlpathinfoWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"urlpathinfo"}'); + $this->assertEquals("http%3A//some.encoded.com/url%3Fparts%23foo", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHex() + { + $tpl = $this->smarty->createTemplate('string:{"a/cäa"|escape:"hex"}'); + $this->assertEquals("%61%2f%63%c3%a4%61", $this->smarty->fetch($tpl)); + } + + public function testHexWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"a/cäa"|escape:"hex"}'); + $this->assertEquals("%61%2f%63%c3%a4%61", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHexentity() + { + $q = "aäЗдравсствуйте"; + $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8'); + $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"hexentity"}'); + $this->assertEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl)); + + $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"hexentity"}'); + $this->assertEquals("abc", $this->smarty->fetch($tpl)); + } + + public function testHexentityWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $q = "aäЗдравсствуйте"; + $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8'); + $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"hexentity"}'); + $this->assertNotEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl)); + + $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"hexentity"}'); + $this->assertEquals("abc", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testDecentity() + { + $q = "aäЗдравсствуйте"; + $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8'); + $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"decentity"}'); + $this->assertEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl)); + + $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"decentity"}'); + $this->assertEquals("abc", $this->smarty->fetch($tpl)); + } + + public function testDecentityWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $q = "aäЗдравсствуйте"; + $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8'); + $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"decentity"}'); + $this->assertNotEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl)); + + $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"decentity"}'); + $this->assertEquals("abc", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testJavascript() + { + $tpl = $this->smarty->createTemplate('string:{"var x = { foo : \"bar\n\" };"|escape:"javascript"}'); + $this->assertEquals("var x = { foo : \\\"bar\\n\\\" };", $this->smarty->fetch($tpl)); + } + + public function testJavascriptWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"var x = { foo : \"bar\n\" };"|escape:"javascript"}'); + $this->assertEquals("var x = { foo : \\\"bar\\n\\\" };", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testMail() + { + $tpl = $this->smarty->createTemplate('string:{"smarty@example.com"|escape:"mail"}'); + $this->assertEquals("smarty [AT] example [DOT] com", $this->smarty->fetch($tpl)); + } + + public function testMailWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"smarty@example.com"|escape:"mail"}'); + $this->assertEquals("smarty [AT] example [DOT] com", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testNonstd() + { + $tpl = $this->smarty->createTemplate('string:{"sma\'rty|»example«.com"|escape:"nonstd"}'); + $this->assertEquals("sma'rty|»example«.com", $this->smarty->fetch($tpl)); + } + + public function testNonstdWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"' . utf8_decode('sma\'rty@»example«.com') . '"|escape:"nonstd"}'); + $this->assertEquals("sma'rty@»example«.com", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php new file mode 100644 index 00000000..e465c7b9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php @@ -0,0 +1,53 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = "two convicts evade noose, jury hung."; + $tpl = $this->smarty->createTemplate('string:{"Two Convicts Evade Noose, Jury Hung."|lower}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "two convicts evade noose, jury hung."; + $tpl = $this->smarty->createTemplate('string:{"Two Convicts Evade Noose, Jury Hung."|lower}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $result = "two convicts eväde nööse, jury hung."; + $tpl = $this->smarty->createTemplate('string:{"Two Convicts Eväde NöÖse, Jury Hung."|lower}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "two convicts eväde nööse, jury hung."; + $tpl = $this->smarty->createTemplate('string:{"Two Convicts Eväde NöÖse, Jury Hung."|lower}'); + $this->assertNotEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php new file mode 100644 index 00000000..88ce0982 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php @@ -0,0 +1,45 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{"Infertility unlikely to\nbe passed on, experts say."|regex_replace:"/[\r\t\n]/":" "}'); + $this->assertEquals("Infertility unlikely to be passed on, experts say.", $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Infertility unlikely to\nbe passed on, experts say."|regex_replace:"/[\r\t\n]/":" "}'); + $this->assertEquals("Infertility unlikely to be passed on, experts say.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $tpl = $this->smarty->createTemplate('string:{"Infertility unlikely tö\näe passed on, experts say."|regex_replace:"/[\r\t\n]/u":" "}'); + $this->assertEquals("Infertility unlikely tö äe passed on, experts say.", $this->smarty->fetch($tpl)); + + $tpl = $this->smarty->createTemplate('string:{"Infertility unlikely tä be passed on, experts say."|regex_replace:"/[ä]/ue":"ae"}'); + $this->assertEquals("Infertility unlikely tae be passed on, experts say.", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierSpacifyTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierSpacifyTest.php new file mode 100644 index 00000000..2ccd6cdb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierSpacifyTest.php @@ -0,0 +1,36 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = 'h e l l o w ö r l d'; + $tpl = $this->smarty->createTemplate('string:{"hello wörld"|spacify}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testCharacter() + { + $result = 'h##e##l##l##o## ##w##ö##r##l##d'; + $tpl = $this->smarty->createTemplate('string:{"hello wörld"|spacify:"##"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTest.php new file mode 100644 index 00000000..9dc7bdf3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTest.php @@ -0,0 +1,44 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{" hello spaced words "|strip}'); + $this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl)); + } + + public function testUnicodeSpaces() + { + // Some Unicode Spaces + $string = " hello spaced       words "; + $string = mb_convert_encoding($string, 'UTF-8', "HTML-ENTITIES"); + $tpl = $this->smarty->createTemplate('string:{"' . $string . '"|strip}'); + $this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl)); + } + + public function testLinebreak() + { + $tpl = $this->smarty->createTemplate('string:{" hello + spaced words "|strip}'); + $this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php new file mode 100644 index 00000000..7af50af6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php @@ -0,0 +1,134 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = 'Two Sisters Reunite after Eighteen Years at Checkout Counter.'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after Eighteen Years at Checkout Counter.'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testLength() + { + $result = 'Two Sisters Reunite after...'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testLengthWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after...'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testEtc() + { + $result = 'Two Sisters Reunite after'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEtcWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testEtc2() + { + $result = 'Two Sisters Reunite after---'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"---"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEtc2WithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after---'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"---"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testBreak() + { + $result = 'Two Sisters Reunite after Eigh'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"":true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testBreakWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after Eigh'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"":true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testBreak2() + { + $result = 'Two Sisters Reunite after E...'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"...":true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testBreak2WithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after E...'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"...":true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testMiddle() + { + $result = 'Two Sisters Re..ckout Counter.'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"..":true:true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testMiddleWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Re..ckout Counter.'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"..":true:true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php new file mode 100644 index 00000000..608eb5c4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php @@ -0,0 +1,68 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testHtml() + { + $encoded = "aäЗдра><&amp;ääвсствуйте"; + $result = "aäЗдра><&ääвсствуйте"; + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"html"}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testHtmlWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $encoded = "aäЗдра><&amp;ääвсствуйте"; + $result = "aäЗдра><&ääвсствуйте"; + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"html"}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHtmlall() + { + $encoded = "aäЗдра><&amp;ääвсствуйте"; + $result = "aäЗдра><&ääвсствуйте"; + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"htmlall"}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testHtmlallWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $encoded = "aäЗдра><&amp;ääвсствуйте"; + $result = "aäЗдра><&ääвсствуйте"; + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"htmlall"}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUrl() + { + $encoded = "a%C3%A4%D0%97%D0%B4%D1%80%D0%B0%3E%3C%26amp%3B%C3%A4%C3%A4%D0%B2%D1%81%D1%81%D1%82%D0%B2%3F%3D%2B%D1%83%D0%B9%D1%82%D0%B5"; + $result = "aäЗдра><&ääвсств?=+уйте"; + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"url"}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } +} + +?> \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php new file mode 100644 index 00000000..fb96fa5b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php @@ -0,0 +1,54 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = "IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE."; + $tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Settled Quickly it may Last a While."|upper}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE."; + $tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Settled Quickly it may Last a While."|upper}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $result = "IF STRIKE ISN'T SÄTTLED ÜQUICKLY IT MAY LAST A WHILE."; + $tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Sättled ÜQuickly it may Last a While."|upper}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "IF STRIKE ISN'T SÄTTLED ÜQUICKLY IT MAY LAST A WHILE."; + $tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Sättled ÜQuickly it may Last a While."|upper}'); + $this->assertNotEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php new file mode 100644 index 00000000..bd94590d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php @@ -0,0 +1,163 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap}'); + $this->assertEquals("Blind woman gets new kidney from dad she hasn't seen in years.", $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap}'); + $this->assertEquals("Blind woman gets new kidney from dad she hasn't seen in years.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testDefaultUmlauts() + { + $tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsä new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("äöüßñ woman ñsä new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl)); + } + + public function testLength() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman gets new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl)); + } + + public function testLengthWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman gets new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testBreak() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30:"
\n"}'); + $this->assertEquals("Blind woman gets new kidney
\nfrom dad she hasn't seen in
\nyears.", $this->smarty->fetch($tpl)); + } + + public function testBreakWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30:"
\n"}'); + $this->assertEquals("Blind woman gets new kidney
\nfrom dad she hasn't seen in
\nyears.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testLong() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n"}'); + $this->assertEquals("Blind woman\nwithaverylongandunpronoucablenameorso\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl)); + } + + public function testLongWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n"}'); + $this->assertEquals("Blind woman\nwithaverylongandunpronoucablenameorso\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testLongUmlauts() + { + $tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ gets new kidney from dad she hasn\'t seen in years."|wordwrap:26}'); + $this->assertEquals("äöüßñ woman\nñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl)); + } + + public function testLongCut() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}'); + $this->assertEquals("Blind woman\nwithaverylongandunpronouca\nblenameorso gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl)); + } + + public function testLongCutWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}'); + $this->assertEquals("Blind woman\nwithaverylongandunpronouca\nblenameorso gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testLongCutUmlauts() + { + $tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}'); + $this->assertEquals("äöüßñ woman\nñsääöüßñameorsoäöüßñäöüßñä\nöüßñäöüßñßñ gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl)); + } + + public function testLinebreaks() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman\ngets new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman\ngets new kidney from dad she\nhasn't seen in years.", $this->smarty->fetch($tpl)); + } + + public function testLinebreaksWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman\ngets new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman\ngets new kidney from dad she\nhasn't seen in years.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testLinebreaks2() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman + gets + new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman + gets + new kidney from\ndad she hasn't seen in years.", $this->smarty->fetch($tpl)); + } + + public function testLinebreaks2WithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman + gets + new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman + gets + new kidney from\ndad she hasn't seen in years.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + /* + public function testUnicodeSpaces() + { + // Some Unicode Spaces + $string = " hello spaced       words "; + $string = mb_convert_encoding($string, 'UTF-8', "HTML-ENTITIES"); + $tpl = $this->smarty->createTemplate('string:{"' . $string . '"|strip}'); + $this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl)); + } + */ +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php b/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php new file mode 100644 index 00000000..0cedbcfd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php @@ -0,0 +1,151 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {section} tag + */ + public function testSection_001() + { + $this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9)); + $this->assertEquals("0123456789", $this->smarty->fetch('001_section.tpl')); + } + + public function testSection_002() + { + $this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9)); + $this->assertEquals("0123456789", $this->smarty->fetch('002_section.tpl')); + } + + public function testSection_003() + { + $this->assertEquals("else", $this->smarty->fetch('003_section.tpl')); + } + + public function testSection_004() + { + $this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9)); + $this->assertEquals("0123456789", $this->smarty->fetch('004_section.tpl')); + } + + public function testSection_006() + { + $this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9)); + $this->assertEquals("0123456789total10", $this->smarty->fetch('006_section.tpl')); + } + + public function testSection_007() + { + $this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9)); + $this->assertEquals("011223344556677889910", $this->smarty->fetch('007_section.tpl')); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', array(1,2)); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{section name=bar loop=\$foo}{\$foo[bar]}{/section}C", "A12C", 'T1', $i++), + array("A{section name=bar loop=\$foo}\n{\$foo[bar]}{/section}C", "A12C", 'T2', $i++), + array("A{section name=bar loop=\$foo}{\$foo[bar]}\n{/section}C", "A1\n2\nC", 'T3', $i++), + array("A{section name=bar loop=\$foo}\n{\$foo[bar]}\n{/section}C", "A1\n2\nC", 'T4', $i++), + array("A\n{section name=bar loop=\$foo}{\$foo[bar]}{/section}C", "A\n12C", 'T5', $i++), + array("A{section name=bar loop=\$foo}{\$foo[bar]}{/section}\nC", "A12C", 'T6', $i++), + array("A{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}D{/section}C", "A12C", 'T7', $i++), + array("A{section name=bar loop=\$foo}{\$foo[bar]}\n{sectionelse}D{/section}C", "A1\n2\nC", 'T8', $i++), + array("{section loop=\$foo name='bar'}{\$foo[bar]}{/section}A{\$smarty.section.bar.total}C", "12A2C", 'T9', $i++), + array("{section loop=\$foo name='bar'}{\$foo[bar]}{/section}A\n{\$smarty.section.bar.total}C", "12A\n2C", 'T10', $i++), + array("{section loop=\$foo name='bar'}{\$foo[bar]}{/section}A{\$smarty.section.bar.total}\nC", "12A2\nC", 'T11', $i++), + ); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestElseSpacing + * @runInSeparateProcess + */ + public function testElseSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_Else_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', array()); + $this->smarty->assign('bar', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testSpacing + */ + public function dataTestElseSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}A{\$bar}B{/section}", "AbarB", 'T1', $i++), + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}\nA{\$bar}B{/section}", "AbarB", 'T2', $i++), + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}A{\$bar}\nB{/section}", "Abar\nB", 'T3', $i++), + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}\nA{\$bar}\nB{/section}", "Abar\nB", 'T4', $i++), + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}{\$bar}\nB{/section}", "bar\nB", 'T5', $i++), + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}{\$bar}{/section}", "bar", 'T6', $i++), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Section/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/001_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/001_section.tpl new file mode 100644 index 00000000..50729b42 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/001_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar]}{/section} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/002_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/002_section.tpl new file mode 100644 index 00000000..be7d4559 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/002_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo start=$i}{$foo[bar]}{sectionelse} else {/section} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/003_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/003_section.tpl new file mode 100644 index 00000000..3dc172ea --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/003_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar]}{sectionelse}else{/section} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/004_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/004_section.tpl new file mode 100644 index 00000000..4a49fc9e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/004_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/006_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/006_section.tpl new file mode 100644 index 00000000..edcd6c2e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/006_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section}total{$smarty.section.bar.total} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/007_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/007_section.tpl new file mode 100644 index 00000000..6c5f9a99 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/007_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$smarty.section.bar.index}{$smarty.section.bar.iteration}{sectionelse} else {/section} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Section/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Section/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/SetFilter/CompileSetfilterTest.php b/tests/UnitTests/TemplateSource/TagTests/SetFilter/CompileSetfilterTest.php new file mode 100644 index 00000000..89b187e5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/SetFilter/CompileSetfilterTest.php @@ -0,0 +1,57 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * @run + * InSeparateProcess + * @preserveGlobalState disabled + */ + public function testNestedSetfilter() + { + $this->smarty->setCaching(1); + $tpl = $this->smarty->createTemplate('string:{$foo}{setfilter htmlspecialchars} {$foo}{$foo nocache}{setfilter escape:"mail"} {$foo}{$foo nocache}{/setfilter} {$foo}{/setfilter} {$foo}'); + $tpl->assign('foo', ''); + $this->assertEquals(" <a@b.c><a@b.c> <a@b.c> ", $this->smarty->fetch($tpl)); + } + public function testNestedSetfilter1() + { + $this->smarty->setCaching(1); + $tpl = $this->smarty->createTemplate('string:{$foo}{setfilter htmlspecialchars} {$foo}{$foo nocache}{setfilter escape:"mail"} {$foo}{$foo nocache}{/setfilter} {$foo}{/setfilter} {$foo}'); + $tpl->assign('foo', ''); + $this->assertEquals(" <a@b.c><e@f.d> <a@b.c> ", $this->smarty->fetch($tpl)); + } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testNestedSetfilter2() + { + $tpl = $this->smarty->createTemplate('string:{$foo}{setfilter htmlspecialchars} {$foo}{setfilter escape:"mail"} {$foo}{/setfilter} {$foo}{/setfilter} {$foo}'); + $tpl->assign('foo', ''); + $this->assertEquals(" <a@b.c> <a@b.c> ", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/SetFilter/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/SetFilter/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/SetFilter/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/SetFilter/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/SetFilter/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/SetFilter/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php b/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php new file mode 100644 index 00000000..a8c37794 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php @@ -0,0 +1,83 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test {strip} tags + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestStrip + */ + public function testStrip($code, $result, $testName, $testNumber) + { + $file = "testStrip_{$testNumber}.tpl"; + $this->makeTemplateFile($file, "{strip}\n" . $code); + $this->smarty->assignGlobal('file', $file); + $this->assertEquals($result, $this->smarty->fetch($file), "testStrip - {$code} - {$testName}"); + } + + /* + * Data provider für testStrip + */ + public function dataTestStrip() + { + $i = 0; + /* + * Code + * result + * test name + */ + return array(array(" foo\n bar buh\n\n", 'foobar buh', '', $i ++), + array("\n \n\n\n foo\n bar\n", + '
[X]
foobar', + '', $i ++), + array("\n \n", + '', '', $i ++), + array("\n foo\n bar\n", + " foobar", '', $i ++), + // variable in html tag + array("\n c\n", 'c', '', $i ++), + array("\n c\n", ' c', '', $i ++), + array("\n \nc\n", 'c', '', $i ++), + array("{\$foo=1}\n {\$foo}c\n", '1c', '', $i ++), + array("{\$foo=1}\n {\$foo} c\n", '1 c', '', $i ++), + array("{\$foo=1}\n \n{\$foo} c\n", '1 c', '', $i ++), + array("\n#{'Text'}#\n", '#Text#', '', $i ++), + array("\n# {'Text'}\n", '# Text', '', $i ++), + array("\n# {'Text'}\n", '# Text', '', $i ++), + array("\n", '', '', $i ++), + array("{'Var'}\n ", 'Var ', '', $i ++), + array("{'Var'}\n ", 'Var ', '', $i ++), + array("\n ", ' ', '', $i ++), + array("\n\n ", '', '', $i ++), + + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Strip/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Strip/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Strip/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Strip/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Strip/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Strip/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php new file mode 100644 index 00000000..31ea49f2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php @@ -0,0 +1,435 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag + * + */ + public function testSimpleFunction_001($text) + { + $this->smarty->assign('param', 1); + $this->smarty->assign('default', 2); + $this->assertEquals("default param default 1 2 1", $this->smarty->fetch('test_template_function_001.tpl'), $text); + } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag + * + */ + public function testSimpleFunctionAssign_001($text) + { + $this->smarty->assign('param', 1); + $this->smarty->assign('default', 2); + $this->assertEquals("default param default 1 2 1", $this->smarty->fetch('test_template_function_assign_001.tpl'), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag cached + */ + public function testSimpleFunctionCached_001($text) + { + $this->smarty->setCaching(1); + $this->smarty->assign('param', 1); + $this->smarty->assign('default', 2); + $this->assertEquals("default param default 1 2 1", $this->smarty->fetch('test_template_function_001.tpl'), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag cached + */ + public function testSimpleFunctionCached_002($text) + { + $this->smarty->setCaching(1); + $this->smarty->assign('param', 1); + $this->smarty->assign('default', 2); + $this->assertEquals("default param default 1 2 1", $this->smarty->fetch('test_template_function_002.tpl'), $text); + } + + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag cached no cache default variable + */ + public function testSimpleFunctionCachedNocacheDefault_002_1($text) + { + $this->smarty->setCaching(1); + $this->smarty->setCompileId(1); + $this->smarty->assign('param', 1); + $this->smarty->assign('default', 2, true); + $this->assertEquals("default param default 1 2 1", $this->smarty->fetch('test_template_function_002.tpl'), $text); + } + + /** + * test simple function call tag cached no cache default variable 2 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testSimpleFunctionCachedNocacheDefault_002_2() + { + $this->smarty->setCaching(1); + $this->smarty->setCompileId(1); + $this->smarty->assign('param', 4); + $this->smarty->assign('default', 8, true); + $this->assertEquals("default param default 1 8 4", $this->smarty->fetch('test_template_function_002.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderCachingValue + * test simple function call tag plugin + * + */ + public function testSimpleFunctionPlugin_003($caching, $text, $start,$result) + { + $this->smarty->setCaching($caching); + $this->smarty->assign('start', $start, true); + $this->smarty->assign('start1', $start+10); + $this->assertEquals($result, $this->smarty->fetch('test_template_function_003.tpl'), $text); + } + + + + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag 2 + * + */ + public function testSimpleFunctionTag2($text) + { + $this->assertEquals("default param default param2 passed param2 default param", $this->smarty->fetch('test_template_function_tag2.tpl'), $text); + } + + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call recursive + */ + public function testRecursiveFunction($text) + { + $this->assertEquals("012345", $this->smarty->fetch('test_template_function_tag4.tpl'), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test inherited function call tag + * + */ + public function testInheritedFunction($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $this->assertEquals("012345", $this->smarty->fetch('test_template_function_tag5.tpl'), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test function definition in include + * + */ + public function testDefineFunctionInclude($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_template_function_tag6.tpl'); + $this->assertEquals("012345", $this->smarty->fetch('test_template_function_tag6.tpl'), $text); + } + + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test external function definition cached + * + */ + public function testExternalDefinedFunctionCached1($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $cacheId = $merge ? 'merge' : null; + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('test_template_function.tpl', $cacheId); + $tpl->assign('foo', 'foo'); + $this->assertContains('foo foo', $this->smarty->fetch($tpl), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * test external function definition and called by fetch + * + */ + public function testExternalDefinedFunctionCalledByFetch() + { + $this->smarty->assign('foo', 'foo'); + $this->assertContains('foo foo', $this->smarty->fetch('test_template_function.tpl')); + $this->smarty->assign('foo', 'bar'); + $this->assertContains('bar bar', $this->smarty->fetch('test_template_function_call.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test external function definition cached 2 + * + */ + public function testExternalDefinedFunctionCached12($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $cacheId = $merge ? 'merge' : null; + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('test_template_function.tpl', $cacheId); + $this->assertTrue($this->smarty->isCached($tpl), $text); + $tpl->assign('foo', 'bar'); + $this->assertContains('foo bar', $this->smarty->fetch($tpl), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test external function definition nocache call + * + */ + public function testExternalDefinedFunctionNocachedCall1($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $cacheId = $merge ? 'merge' : null; + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('test_template_function_nocache_call.tpl', $cacheId); + $tpl->assign('foo', 'foo'); + $this->assertContains('foo foo', $this->smarty->fetch($tpl), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test external function definition nocache call 2 + * + */ + public function testExternalDefinedFunctionNocachedCall2($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $cacheId = $merge ? 'merge' : null; + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('test_template_function_nocache_call.tpl', $cacheId); + $this->assertTrue($this->smarty->isCached($tpl), $text); + $tpl->assign('foo', 'bar'); + $this->assertContains('bar bar', $this->smarty->fetch($tpl), $text); + } + + /** + * test external function definition nocache call 3 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + */ + public function testExternalDefinedFunctionNocachedCall3($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $cacheId = $merge ? 'merge' : null; + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('test_template_function_nocache_call.tpl', $cacheId); + $this->assertTrue($this->smarty->isCached($tpl), $text); + $tpl->assign('foo', 'bar'); + $this->assertContains('bar bar', $this->smarty->fetch($tpl), $text); + } + + /** + * test external defined recursion + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + */ + public function testExternalDefinedFunctionRecursion($text) + { + $this->assertEquals('12345', $this->smarty->fetch('test_template_function_recursion2.tpl'), $text); + } + + /** + * Function data provider inline + */ + public function functionProviderInline() + { + return array( + array(false, 'normal compile'), + array(false, 'normal call'), + array(true, 'merged compile'), + array(true, 'merged call'), + ); + } + /** + * Function data provider + */ + public function functionProvider() + { + return array( + array('compile'), + 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'), + ); + } + /** + * Function data provider + */ + public function functionProviderCachingValue() + { + return array( + array(false, 'normal compile',5,'15 215 5'), + array(false, 'normal call',3,'13 213 3'), + array(true, 'cached compile',6,'16 216 6'), + array(true, 'cached call',8,'16 218 8'), + ); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('VarNocache'); + $this->smarty->setCaching(1); + $this->smarty->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testVarNocache - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('VarNocache'); + $this->smarty->setCaching(1); + $this->smarty->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testVarNocache1 - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("{include 'simple_function_lib.tpl'}A{call name='simple' bar=\$foo}C", "AbarC", 'T1', $i++), + array("{include 'simple_function_lib.tpl'}A\n{call name='simple' bar=\$foo}C", "A\nbarC", 'T2', $i++), + array("{include 'simple_function_lib.tpl'}A\n{call name='simple' bar=\$foo}\nC", "A\nbar\nC", 'T3', $i++), + array("{include 'simple_function_lib.tpl'}A\n{call name='simple' bar=\$foo}\nC", "A\nbar\nC", 'T4', $i++), + array("{include 'simple_function_lib.tpl'}A\n\n{call name='simple' bar=\$foo}\n\nC", "A\n\nbar\n\nC", 'T5', $i++), + array("{function name=simple}{\$bar}{/function}{call name='simple' bar=\$foo}", "bar", 'T6', $i++), + array("{function name=simple}A{\$bar}C{/function}{call name='simple' bar=\$foo}", "AbarC", 'T7', $i++), + array("{function name=simple}A\n{\$bar}C{/function}{call name='simple' bar=\$foo}", "A\nbarC", 'T8', $i++), + array("{function name=simple}A{\$bar}\nC{/function}{call name='simple' bar=\$foo}", "Abar\nC", 'T9', $i++), + array("{function name=simple}A\n{\$bar}\nC{/function}{call name='simple' bar=\$foo}", "A\nbar\nC", 'T10', $i++), + array("{function name=simple}{\$foo}{/function}{call name='simple'}", "bar", 'T11', $i++), + array("{function name=simple}A{\$foo}C{/function}{call name='simple'}", "AbarC", 'T12', $i++), + array("{function name=simple}A\n{\$foo}C{/function}{call name='simple'}", "A\nbarC", 'T13', $i++), + array("{function name=simple}A{\$foo}\nC{/function}{call name='simple'}", "Abar\nC", 'T14', $i++), + array("{function name=simple}A\n{\$foo}\nC{/function}{call name='simple'}", "A\nbar\nC", 'T15', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/nocache_lib.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/nocache_lib.tpl new file mode 100644 index 00000000..8602140e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/nocache_lib.tpl @@ -0,0 +1,6 @@ +{function 'nocache1' default1='d1' default2='d2'} + default1={$default1} + default2={$default1 nocache} + p1={$p1} + p2={$p2 nocache} +{/function} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test0.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test0.tpl new file mode 100644 index 00000000..ae27c661 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test0.tpl @@ -0,0 +1,4 @@ +Test 1 +
+{include 'test7.tpl' compile_id = 4} + diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test1.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test1.tpl new file mode 100644 index 00000000..c8992cca --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test1.tpl @@ -0,0 +1,7 @@ +Test 1 +
+{include 'test7.tpl' compile_id = $id} +{include 'test6.tpl'} +{include file="test2.tpl"} +{include 'test6.tpl'} + diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test2.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test2.tpl new file mode 100644 index 00000000..9b526949 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test2.tpl @@ -0,0 +1,3 @@ +Test 2 +
+{include file="test3.tpl" compile_id=4} diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test3.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test3.tpl new file mode 100644 index 00000000..c4ca3221 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test3.tpl @@ -0,0 +1,4 @@ +Test 3 {call name='f' nocache} +
+{include file="test4.tpl" compile_id=9} +{include file="test5.tpl" cache_id="7"} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test4.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test4.tpl new file mode 100644 index 00000000..13b0cbbb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test4.tpl @@ -0,0 +1,3 @@ +Test 4 +
+{include file="test5.tpl" cache_id="7"} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test5.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test5.tpl new file mode 100644 index 00000000..0a65c4c8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test5.tpl @@ -0,0 +1,4 @@ +test 5 +
+ +{call 'f'} diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test6.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test6.tpl new file mode 100644 index 00000000..d7379f81 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test6.tpl @@ -0,0 +1,8 @@ +test 6 +
+{function name='f'} +
+ function f {$id} {$foo} +
+{/function} +
Time 6 = {$t6}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test7.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test7.tpl new file mode 100644 index 00000000..cc378526 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test7.tpl @@ -0,0 +1,2 @@ +test 7 +
extern \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/simple_function_lib.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/simple_function_lib.tpl new file mode 100644 index 00000000..058f1956 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/simple_function_lib.tpl @@ -0,0 +1 @@ +{function name=simple}{$bar}{/function} diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/template_function_lib.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/template_function_lib.tpl new file mode 100644 index 00000000..a9a1c077 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/template_function_lib.tpl @@ -0,0 +1 @@ +{function name=template_func1 default='d1'}{$foo|escape} {nocache}{$foo|escape}{/nocache} {/function} diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_define_function_tag.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_define_function_tag.tpl new file mode 100644 index 00000000..35edac24 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_define_function_tag.tpl @@ -0,0 +1 @@ +{function name=functest6i loop=0}{$loop}{if $loop < 5}{call name=functest6i loop=$loop+1}{/if}{/function} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag.tpl new file mode 100644 index 00000000..f50d697e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag.tpl @@ -0,0 +1 @@ +{call name=functest4} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag6.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag6.tpl new file mode 100644 index 00000000..10d6e88b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag6.tpl @@ -0,0 +1 @@ +{call name=functest6i} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function.tpl new file mode 100644 index 00000000..0997bdd3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function.tpl @@ -0,0 +1 @@ +{include file='template_function_lib.tpl'}{call name=template_func1} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_001.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_001.tpl new file mode 100644 index 00000000..194dde9a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_001.tpl @@ -0,0 +1 @@ +{function name=functest default='default'}{$default} {$param}{/function}{call name=functest param='param'} {call name=functest param=$param} {call name=functest param=$param default=$default} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_002.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_002.tpl new file mode 100644 index 00000000..7b6dbc77 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_002.tpl @@ -0,0 +1 @@ +{function name=functest default='default'}{$default} {$param nocache}{/function}{call name=functest param='param'} {call name=functest param=$param} {call name=functest param=$param default=$default} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_003.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_003.tpl new file mode 100644 index 00000000..b332e97b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_003.tpl @@ -0,0 +1 @@ +{function name=functestplugins}{counter start=$start1} {counter start=$start nocache}{/function}{call name=functestplugins start=2}{call name=functestplugins start=$start} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_assign_001.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_assign_001.tpl new file mode 100644 index 00000000..71ad75ca --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_assign_001.tpl @@ -0,0 +1 @@ +{function name=functest default='default'}{$default} {$param}{$foo = $param scope=local}{/function}{call name=functest param='param'} {call name=functest param=$param} {call name=functest param=$param default=$default} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_call.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_call.tpl new file mode 100644 index 00000000..14829d91 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_call.tpl @@ -0,0 +1 @@ +{call name=template_func1} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_nocache_call.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_nocache_call.tpl new file mode 100644 index 00000000..3be68715 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_nocache_call.tpl @@ -0,0 +1 @@ +{include file='template_function_lib.tpl'}{call 'template_func1' nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion1.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion1.tpl new file mode 100644 index 00000000..977b8515 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion1.tpl @@ -0,0 +1,20 @@ +{strip} +{function 'recursion1' level=0} + {$level} + {if $level < 5} + {call name=recursion1 level=$level+1} + {/if} +{/function} + +{call name=recursion1} + + +{function 'recursion2' level=0} +
2 level = {$level} + {if $level < 5} + {call name=recursion2 level=$level+1} + {/if} +{/function} + +{recursion2} +{/strip} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion2.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion2.tpl new file mode 100644 index 00000000..cf9431f0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion2.tpl @@ -0,0 +1,10 @@ +{strip} +{function 'recursion2' level=0} +{$level} + {if $level < 5} + {call name=recursion2 level=$level+1} + {/if} +{/function} + +{recursion2} +{/strip} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag2.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag2.tpl new file mode 100644 index 00000000..2464e00a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag2.tpl @@ -0,0 +1 @@ +{function name=functest2 default='default'}{$default} {$param}{/function}{call name=functest2 param='param'} {call name=functest2 param='param2'} {call name=functest2 param='param2' default='passed'} {call name=functest2 param='param'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag4.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag4.tpl new file mode 100644 index 00000000..80cf6a0f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag4.tpl @@ -0,0 +1 @@ +{function name=functest4 loop=0}{$loop}{if $loop < 5}{call name=functest4 loop=$loop+1}{/if}{/function}{call name=functest4} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag5.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag5.tpl new file mode 100644 index 00000000..f20a9617 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag5.tpl @@ -0,0 +1 @@ +{function name=functest4 loop=0}{$loop}{if $loop < 5}{call name=functest4 loop=$loop+1}{/if}{/function}{include file='test_inherit_function_tag.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag6.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag6.tpl new file mode 100644 index 00000000..993a4945 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag6.tpl @@ -0,0 +1 @@ +{include file='test_define_function_tag.tpl'}{include file='test_inherit_function_tag6.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php b/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php new file mode 100644 index 00000000..78fe828a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php @@ -0,0 +1,154 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {while 'condition'} tag + */ + public function testWhileCondition() + { + $tpl = $this->smarty->createTemplate('string:{$x=0}{while $x<10}{$x}{$x=$x+1}{/while}'); + $this->assertEquals("0123456789", $this->smarty->fetch($tpl)); + } + + /** + * test {while 'statement'} tag + */ + public function testWhileStatement() + { + $tpl = $this->smarty->createTemplate('string:{$x=5}{while $x=$x-1}{$x}{/while}'); + $this->assertEquals("4321", $this->smarty->fetch($tpl)); + } + + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 3); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{while \$foo=\$foo-1}{\$foo}{/while}C", "A21C", 'T1', $i++), + array("A{while \$foo=\$foo-1}\n{\$foo}{/while}C", "A21C", 'T2', $i++), + array("A{while \$foo=\$foo-1}{\$foo}\n{/while}C", "A2\n1\nC", 'T3', $i++), + array("A{while \$foo=\$foo-1}\n{\$foo}\n{/while}C", "A2\n1\nC", 'T4', $i++), + array("A\n{while \$foo=\$foo-1}{\$foo}{/while}C", "A\n21C", 'T5', $i++), + array("A{while \$foo=\$foo-1}{\$foo}{/while}\nC", "A21\nC", 'T6', $i++), + array("A{while \$foo=\$foo-1}{\$foo}{break}{/while}C", "A2C", 'T7', $i++), + array("A{while \$foo=\$foo-1}{\$foo}\n{break}{/while}C", "A2\nC", 'T8', $i++), + array("A{while \$foo=\$foo-1}{\$foo}{break}\n{/while}C", "A2C", 'T9', $i++), + array("A{while \$foo=\$foo-1}{if \$foo === 2}{continue}{/if}{\$foo}{/while}C", "A1C", 'T10', $i++), + array("A{while \$foo=\$foo-1}{if \$foo === 2}{continue}\n{/if}{\$foo}{/while}C", "A1C", 'T11', $i++), + array("A{while \$foo=\$foo-1}{if \$foo === 2}\n{continue}\n{/if}{\$foo}{/while}C", "A1C", 'T12', $i++), + array("A{while \$foo=\$foo-1}\n{continue}{\$foo}{/while}C", "AC", 'T13', $i++), + array("A{while \$foo=\$foo-1}{continue}\n{\$foo}{/while}C", "AC", 'T14', $i++), + array("A{while \$foo=\$foo-1}{break}\n{\$foo}{/while}C", "AC", 'T15', $i++), + array("A{while \$foo=\$foo-1}{\$foo}{continue}{/while}C", "A21C", 'T16', $i++), + array("A{while \$foo=\$foo-1}{\$foo}{continue}\n{/while}C", "A21C", 'T17', $i++), + array("A{while \$foo=\$foo-1}{\$foo}\n{continue}\n{/while}C", "A2\n1\nC", 'T18', $i++), + array("A{while \$foo=\$foo-1}{\$foo} {continue} {/while}C", "A2 1 C", 'T19', $i++), + array("A{while \$foo=\$foo-1} {continue}{\$foo}{/while}C", "A C", 'T20', $i++), + array("A{while \$foo=\$foo-1} {/while}C", "A C", 'T21', $i++), + array("A{while !isset(\$x)}{\$foo}{\$x=1}{/while}C", "A3C", 'T22', $i++), + ); + } + /** + * Test nocache + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestNocache + */ + public function testNocache($value, $nocache, $code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Nocache_{$name}.tpl"; + if ($code) { + $this->makeTemplateFile($file, $code); + } + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', $value, $nocache); + $this->assertEquals($result, $this->smarty->fetch($file), + "{$file} - {$testNumber}"); + } + + /* + * Data provider für testNocache + */ + public function dataTestNocache() + { + $i = 1; + /* + * var + * value + * Code + * result + * test name + */ + return array(array(3,false, "{while \$foo=\$foo-1}\n{\$foo}{/while}", '21', 'T1', $i ++), + array(0,false, false, '21', 'T1', $i ++), + array(3,false, "{while \$foo=\$foo-1 nocache}\n{\$foo}{/while}", '21', 'T2', $i ++), + array(4,false, false, '321', 'T2', $i ++), + array(4,true, "{while \$foo=\$foo-1}\n{\$foo}{/while}", '321', 'T3', $i ++), + array(5,true, false, '4321', 'T3', $i ++), + array(array(1,2,3),false, "{\$x=1}{while isset(\$foo[\$x])}\n{\$foo[\$x]}{\$x++}{/while}", '2132', 'T4', $i ++), + array(array(3,4,5),false, false, '2132', 'T4', $i ++), + array(array(1,2,3),false, "{\$x=1 nocache}{while isset(\$foo[\$x])}\n{\$foo[\$x]}{\$x++}{/while}", '2132', 'T5', $i ++), + array(array(3,4,5),false, false, '4152', 'T5', $i ++), + array(array(1,2,3),true, "{\$x=1 nocache}{while isset(\$foo[\$x])}\n{\$foo[\$x]}{\$x++}{/while}", '2132', 'T6', $i ++), + array(array(3,4,5),true, false, '4152', 'T6', $i ++), + array(array(1,2,3,4,5),true, "{\$x=0 nocache}{while \$foo[\$x] <= 3}\n{\$foo[\$x]}{\$x++}{/while}", '102132', 'T7', $i ++), + array(array(2,3,4,5),true, false, '2031', 'T7', $i ++), + array(array(1,2,false,4,5),true, "{\$x=0 nocache}{while \$foo[\$x]}\n{\$foo[\$x]}{\$x++}{/while}", '1021', 'T8', $i ++), + array(array(2,false,4,5),true, false, '20', 'T8', $i ++), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/While/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/While/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/While/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/While/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/While/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/While/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/While/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/While/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/While/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Attributes/AttributeTest.php b/tests/UnitTests/TemplateSource/TagTests/_Attributes/AttributeTest.php new file mode 100644 index 00000000..b3fe851f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Attributes/AttributeTest.php @@ -0,0 +1,79 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage missing 'var' attribute + * test required attribute + */ + public function testRequiredAttributeVar() + { + $this->smarty->fetch('string:{assign value=1}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unexpected 'bar' attribute + * test unexpected attribute + */ + public function testUnexpectedAttribute() + { + $this->smarty->fetch('string:{assign var=foo value=1 bar=2}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage for option flag 'nocache' + * @expectedExceptionMessage illegal value + * test illegal option value + */ + public function testIllegalOptionValue() + { + $this->smarty->fetch('string:{assign var=foo value=1 nocache=buh}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage too many shorthand attributes + * test too many shorthands + */ + public function testTooManyShorthands() + { + $this->smarty->fetch('string:{assign foo 1 2}'); + } + + /** + */ + public function testNumericParams() + { + $this->assertEquals('array(\'a\'=>\'pa\',0=>\'isnull\',)', $this->strip($this->smarty->fetch('string:{getparams a=\'pa\' 0=isnull}'))); + } + + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/_Attributes/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Attributes/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Attributes/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Attributes/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Attributes/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Attributes/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Error/CompileErrorTest.php b/tests/UnitTests/TemplateSource/TagTests/_Error/CompileErrorTest.php new file mode 100644 index 00000000..b190c5ff --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Error/CompileErrorTest.php @@ -0,0 +1,67 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * @expectedException SmartyException + * @expectedExceptionMessage no.tpl + * test none existing template file error + */ + public function testNoneExistingTemplateError() + { + $this->smarty->fetch('eval:{include file=\'no.tpl\'}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unknown tag 'unknown' + * test unkown tag error + */ + public function testUnknownTagError() + { + $this->smarty->fetch('eval:{unknown}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unclosed {if} tag + * test unclosed tag error + */ + public function testUnclosedTagError() + { + $this->smarty->fetch('eval:{if true}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage Unexpected "}" + * test syntax error + */ + public function testSyntaxError() + { + $this->smarty->fetch('eval:{assign var=}'); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/_Error/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Error/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Error/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Error/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Error/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Error/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Print/PrintTest.php b/tests/UnitTests/TemplateSource/TagTests/_Print/PrintTest.php new file mode 100644 index 00000000..6c5d624a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Print/PrintTest.php @@ -0,0 +1,108 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * Test Output spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestOutputSpacing + * @runInSeparateProcess + */ + public function testOutputSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testSpacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestOutputSpacing + * @runInSeparateProcess + */ + public function testOutputSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testSpacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestOutputSpacing + * @runInSeparateProcess + */ + public function testOutputSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testSpacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testOutputSpacing + */ + public function dataTestOutputSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array('{$foo}', 'bar', 'Variable', $i++), + array('{$foo}{$foo}', 'barbar', 'twoVariables', $i++), + array('A{$foo}{$foo}B', 'AbarbarB', 'twoVariablesInText', $i++), + array('{$foo} {$foo}', 'bar bar', 'twoVariablesWithSpace', $i++), + array('A{$foo}B', 'AbarB', 'VariableInText1', $i++), + array('A {$foo}B', 'A barB', 'VariableInText2', $i++), + array('A{$foo} B', 'Abar B', 'VariableInText3', $i++), + array("A{\$foo}\nB", "Abar\nB", 'VariableInTextNewline1', $i++), + array("A{\$foo}B\nC", "AbarB\nC", 'VariableInTextNewline2', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/_Print/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Print/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Print/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Print/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Print/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Print/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Print/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Print/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Print/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php b/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php new file mode 100644 index 00000000..7594678a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php @@ -0,0 +1,45 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {break} in foreach + */ + public function testBreakForeach() + { + $this->smarty->assign('array', array(1,2,3)); + $this->assertEquals('1', $this->smarty->fetch('break_foreach.tpl')); + } + /** + * test {break} in foreach nocache + */ + public function testBreakForeachNocache() + { + $this->smarty->assign('array', array(1,2,3), true); + $this->smarty->caching = true; + $this->assertEquals('1', $this->smarty->fetch('break_foreach.tpl')); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/break/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/break/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/break/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/break/templates/break_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/break/templates/break_foreach.tpl new file mode 100644 index 00000000..b289e535 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/break/templates/break_foreach.tpl @@ -0,0 +1,7 @@ +{strip} +{foreach $array as $key => $i} + {if $key == 1} + {break} + {/if} + {$i} +{/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/break/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/break/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/break/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Array/ArrayTest.php b/tests/UnitTests/TemplateSource/ValueTests/Array/ArrayTest.php new file mode 100644 index 00000000..d8f5cd63 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Array/ArrayTest.php @@ -0,0 +1,75 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * Test array access + * + * @preserveGlobalState disabled + * @dataProvider dataTestArray + * @runInSeparateProcess + */ + public function testArray($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Array_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 3); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testArray + */ + public function dataTestArray() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array('{$foo=[1,2,3,4,5]}{foreach $foo as $bar}{$bar}{/foreach}', '12345', 'T1', $i++), + array('{$foo=[1,2,3,4,5]}{$foo.0}{$foo.1}{$foo.2}', '123', 'T2', $i++), + array('{$foo=[1,2,3,4,5]}{$foo[0]}{$foo[1]}{$foo[2]}', '123', 'T3', $i++), + array('{$x=\'d\'}{$foo=[a=>1,\'b\'=>2,"c"=>3,$x=>4]}{$foo[\'a\']}{$foo[\'b\']}{$foo[\'c\']}{$foo[\'d\']}', '1234', 'T4', $i++), + array('{$foo=[1,2,[a,b,c],4,5]}{$foo[2][1]}', 'b', 'T5', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$foo[2][1]+1}', '9', 'T6', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$foo.2.1+1}', '9', 'T7', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{2+$foo[2][1]}', '10', 'T8', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{2+$foo.2.1}', '10', 'T9', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$foo[2][0]+$foo[2][1]}', '15', 'T10', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$foo.2.0+$foo.2.1}', '15', 'T11', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$x=2}{$y=0}{$foo.$x.$y}', '7', 'T12', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$x=2}{$foo.$x.0}', '7', 'T13', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$x=0}{$foo.2.$x}', '7', 'T14', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$x=[1,0]}{$foo.2.{$x.1}}', '7', 'T15', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Array/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Array/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Array/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Array/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Array/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Array/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Array/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Array/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Array/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/BooleanNullTest.php b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/BooleanNullTest.php new file mode 100644 index 00000000..9fba0bac --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/BooleanNullTest.php @@ -0,0 +1,51 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test true + * + */ + public function testTrue() { + $this->smarty->assign('value', true); + $this->assertEquals('true', $this->smarty->fetch('eval:{if $value === true}true{else}false{/if}')); + } + /** + * test false + * + */ + public function testFalse() { + $this->smarty->assign('value', false); + $this->assertEquals('true', $this->smarty->fetch('eval:{if $value === false}true{else}false{/if}')); + } + /** + * test null + * + */ + public function testNull() { + $this->smarty->assign('value', null); + $this->assertEquals('true', $this->smarty->fetch('eval:{if $value === null}true{else}false{/if}')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php new file mode 100644 index 00000000..3ab161b9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php @@ -0,0 +1,89 @@ +setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test constants + */ + public function testConstants() + { + define('MYCONSTANTS', 'hello world'); + $tpl = $this->smarty->createTemplate('eval:{$smarty.const.MYCONSTANTS}'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + public function testConstants2() + { + $tpl = $this->smarty->createTemplate('eval:{MYCONSTANTS}'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + public function testConstants3() + { + $tpl = $this->smarty->createTemplate('eval:{$x=MYCONSTANTS}{$x}'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + public function testConstants4() + { + $tpl = $this->smarty->createTemplate('eval:{TestConst::CONSTVAL}'); + $this->assertEquals("okay", $this->smarty->fetch($tpl)); + } + + public function testConstants5() + { + $tpl = $this->smarty->createTemplate('eval:{if TestConst::CONSTVAL == "okay"}yes{/if}'); + $this->assertEquals("yes", $this->smarty->fetch($tpl)); + } + + public function testConstants6() + { + $tpl = $this->smarty->createTemplate('eval:{$obj::CONSTVAL}'); + $tpl->assign('obj', new TestConst()); + $this->assertEquals("okay", $this->smarty->fetch($tpl)); + } + + public function testConstants7() + { + $tpl = $this->smarty->createTemplate('eval:{if $obj::CONSTVAL == "okay"}yes{/if}'); + $tpl->assign('obj', new TestConst()); + $this->assertEquals("yes", $this->smarty->fetch($tpl)); + } + public function testConstantsUndefined() + { + $tpl = $this->smarty->createTemplate('string:{$smarty.const.MYCONSTANT2}'); + $this->assertEquals("", $this->smarty->fetch($tpl)); + } + public function testConstantsUndefined2() + { + $tpl = $this->smarty->createTemplate('eval:{$foo = MYCONSTANT2}{$foo}'); + $this->assertEquals("MYCONSTANT2", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/DoubleQuotedStringTest.php b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/DoubleQuotedStringTest.php new file mode 100644 index 00000000..0b647b4c --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/DoubleQuotedStringTest.php @@ -0,0 +1,105 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test double qouted strings + * + * @preserveGlobalState disabled + * @dataProvider dataTestDoubleQuoted + */ + public function testDoubleQuoted($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testDoubleQuotes_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('bar', 'buh'); + $this->assertEquals($result, $this->smarty->fetch($file), + "testDoubleQuoted - {$code} - {$name}"); + } + + /* + * Data provider für testDoubleQuoted + */ + public function dataTestDoubleQuoted() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array('{$foo="Hello World"}{$foo}', 'Hello World', 'simple', $i ++), + array('{$bar=1}{$foo="Hello {$bar+2} World"}{$foo}', 'Hello 3 World', 'withExpression', $i ++), + array('{$bar=\'blah\'}{$foo="Hello $bar World"}{$foo}', 'Hello blah World', 'withVariable', $i ++), + array('{$bar=\'blah\'}{$buh=\'wow\'}{$foo="Hello $bar$buh World"}{$foo}', 'Hello blahwow World', 'with2Variables', $i ++), + array('{$bar=\'blah\'}{$foo="Hello `$bar`.test World"}{$foo}', 'Hello blah.test World', 'withVarBacktick', $i ++), + array('{$bar=\'blah\'}{$buh=\'buh\'}{$foo="Hello `$bar``$buh`.test World"}{$foo}', 'Hello blahbuh.test World', 'with2VarBacktick', $i ++), + array('{$barbuh=\'blah\'}{$buh=\'buh\'}{$foo="Hello `$bar{$buh}`.test World"}{$foo}', 'Hello blah.test World', 'withVariableVarBacktick', $i ++), + array('{$bar[1][2]=\'blah\'}{$foo="Hello `$bar.1.2`.test World"}{$foo}', 'Hello blah.test World', 'withVarIndexSmartyBacktick', $i ++), + array('{$bar[1][2]=\'blah\'}{$foo="Hello `$bar[1][2]`.test World"}{$foo}', 'Hello blah.test World', 'withVarIndexPhPBacktick', $i ++), + array('{$a=1}{"`$a+1`"}', '2', 'withExpressionBacktick', $i ++), + array('{$foo="Hello {counter start=3} World"}{$foo}', 'Hello 3 World', 'withCounterTag', $i ++), + array('{$foo="Hello {counter start=2}{counter} World"}{$foo}', 'Hello 23 World', 'with2CounterTag', $i ++), + array('{$x=1}{$y=2}{$z=true}{"Hello{if $z} {$x} {else}{$y}{/if}World"}', 'Hello 1 World', 'withIfTag', $i ++), + array('{$bar=\'blah\'}{$foo="Hello {$bar}.test World"}{$foo}', 'Hello blah.test World', 'withDelimiter', $i ++), + array('{$foo="Hello \" World"}{$foo}', 'Hello " World', 'escaped', $i ++), + array('{$foo="Hello \'World\'"}{$foo}', 'Hello \'World\'', 'withSingleQuotes', $i ++), + array('{$foo="Hello {\'World\'} Test"}{$foo}', 'Hello World Test', 'withSingleQuoteTag', $i ++), + array('{$foo=""}{$foo}', '', 'empty', $i ++), + ); + } + + + /** + * + * test unclosed block tag + * + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unclosed '{if}' in doubled quoted string + */ + public function testDoubleQuotedUnclosedBlock_001() + { + $this->smarty->fetch('001_unclosedBlock.tpl'); + } + + /** + * + * test closed block tag + * {"{if true}hello world{/if}"} + * + */ + public function testDoubleQuotedClosedBlock_001() + { + $this->assertEquals('hello world', $this->smarty->fetch('001_closedBlock.tpl')); + } + +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_closedBlock.tpl b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_closedBlock.tpl new file mode 100644 index 00000000..1ae63043 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_closedBlock.tpl @@ -0,0 +1 @@ +{"{if true}hello world{/if}"} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_unclosedBlock.tpl b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_unclosedBlock.tpl new file mode 100644 index 00000000..f30d396c --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_unclosedBlock.tpl @@ -0,0 +1 @@ +{"{if true} world"} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php new file mode 100644 index 00000000..ff0b3a1c --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php @@ -0,0 +1,110 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test PHP function as modifier + */ + public function testSyntax() + { + $this->smarty->disableSecurity(); + $expected = "20 -- 4"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5}{$x * $y} -- {20 / 5}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testFunction() + { + $this->smarty->disableSecurity(); + $expected = "20 -- 4"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5}{math equation="x * y" x=$x y=$y} -- {math equation="20 / 5"}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testSyntaxSin() + { + $this->smarty->disableSecurity(); + $expected = sin(4) . ' -- ' . sin(4); + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$x|sin} -- {$y = sin($x)}{$y}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testFunctionSin() + { + $this->smarty->disableSecurity(); + $expected = sin(4) . ' -- ' . sin(4); + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{math equation="sin(x)" x=$x} -- {math equation="sin(x)" x=$x assign="y"}{$y}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testSyntaxFloat() + { + $this->smarty->disableSecurity(); + $expected = "22 -- 4.1"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5.5}{$x * $y} -- {20.5 / 5}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testFunctionFloat() + { + $this->smarty->disableSecurity(); + $expected = "22 -- 4.1"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5.5}{math equation="x * y" x=$x y=$y} -- {math equation="20.5 / 5"}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testSyntaxFormat() + { + $this->smarty->disableSecurity(); + $expected = "22.00 -- 4.10"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5.5}{$z = $x * $y}{"%0.2f"|sprintf:$z} -- {$x = 20.5}{$y = 5}{$z = $x / $y}{"%0.2f"|sprintf:$z}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testFunctionFormat() + { + $this->smarty->disableSecurity(); + $expected = "22.00 -- 4.10"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5.5}{math equation="x * y" x=$x y=$y format="%0.2f"} -- {math equation="20.5 / 5" format="%0.2f"}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testSyntaxString() + { + $this->smarty->disableSecurity(); + $expected = "22.00 -- 4.10"; + $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{$z = $x * $y}{"%0.2f"|sprintf:$z} -- {$x = "20.5"}{$y = "5"}{$z = $x / $y}{"%0.2f"|sprintf:$z}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testFunctionString() + { + $this->smarty->disableSecurity(); + $expected = "22.00 -- 4.10"; + $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="x * y" x=$x y=$y format="%0.2f"} -- {math equation="20.5 / 5" format="%0.2f"}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Math/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Math/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Math/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Math/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Math/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Math/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php b/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php new file mode 100644 index 00000000..2dc1751b --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php @@ -0,0 +1,135 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test modifier + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestModifier + */ + public function testModifier($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testModifier_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('bar', 'buh'); + $this->assertEquals($result, $this->smarty->fetch($file), + "testModifier - {$code} - {$name}"); + } + + /* + * Data provider für testModifier + */ + public function dataTestModifier() + { + $i = 1; + /* + * Code + * result + * test name + */ + return array(array('{"hello world"|strlen}', '11', 'OnString', $i ++), + array('{$foo ="hello world"}{$foo|strlen}', '11', 'OnVar', $i ++), + array('{"hello world"|truncate:6}', 'hel...', 'TruncatePlugin', $i ++), + array('{$foo=7}{"hello world"|truncate:$foo}', 'hell...', 'TruncatePluginLengthVar', $i ++), + array('{$foo=10}{$bar=\'<>\'}{"hello world"|truncate:$foo:$bar}', 'hello<>', 'TruncatePluginAllVar', $i ++), + array('{"hello world"|truncate:6|strlen}', '6', 'Chain', $i ++), + array('{"hello world"|truncate:6:"xx"|cat:"Smarty"}', 'hellxxSmarty', 'ChainVar', $i ++), + array('{"hello world"|truncate:6|strlen}', '6', 'Chain', $i ++), + array('{if "hello world"|truncate:6|strlen == 6}okay{/if}', 'okay', 'InIF', $i ++), + array('{"hello world"|truncate:6|strlen + ("hello world"|truncate:8|strlen)}', '14', 'Expression', $i ++), + array('{1.1*7.1|round}', '7.7', 'InExpression', $i ++), + array('{counter|truncate:5 start=100000}', '10...', 'PluginOutput', $i ++), + array('{1 + [1,2,3]|count}', '4', 'SumExpression', $i ++), + ); + } + + + + + /** + * test registered modifier static class + */ + public function testModifierRegisteredStaticClass() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', array('testmodifierclass', 'staticcall')); + $this->smarty->assign('foo', 1); + $this->assertEquals("mymodifier static 1", $this->smarty->fetch('testModifier_RegisteredStatic.tpl')); + } + + /** + * test registered modifier method call + */ + public function testModifierRegisteredMethodCall() + { + $obj = new testmodifierclass(); + $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', array($obj, 'method')); + $this->smarty->assign('foo', 3); + $this->assertEquals("mymodifier method 3", $this->smarty->fetch('testModifier_RegisteredMethod.tpl')); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unknown modifier 'unknown' + * test unknown modifier error + */ + public function testUnknownModifier() + { + $this->smarty->fetch('eval:{"hello world"|unknown}'); + } + + /** + * test default modifier + */ + public function testDefaultModifier() + { + $this->smarty->default_modifiers = array('escape'); + $this->smarty->assign('foo', ''); + $this->assertEquals('<bar>', $this->smarty->fetch('testModifier_Default.tpl')); + } +} + +function testmodifier($value) +{ + return "mymodifier function $value"; +} + +class testmodifierclass +{ + static function staticcall($value) + { + return "mymodifier static $value"; + } + + public function method($value) + { + return "mymodifier method $value"; + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Modifier/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_Default.tpl b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_Default.tpl new file mode 100644 index 00000000..e5c4736d --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_Default.tpl @@ -0,0 +1 @@ +{$foo}{$foo nofilter} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredMethod.tpl b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredMethod.tpl new file mode 100644 index 00000000..60ea1847 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredMethod.tpl @@ -0,0 +1 @@ +{$foo|testmodifier} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredStatic.tpl b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredStatic.tpl new file mode 100644 index 00000000..60ea1847 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredStatic.tpl @@ -0,0 +1 @@ +{$foo|testmodifier} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Objects/ObjectVariableTest.php b/tests/UnitTests/TemplateSource/ValueTests/Objects/ObjectVariableTest.php new file mode 100644 index 00000000..717b94e8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Objects/ObjectVariableTest.php @@ -0,0 +1,106 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->setForceCompile(true); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test simple object variable + */ + public function testObjectVariableOutput() + { + $object = new VariableObject; + $tpl = $this->smarty->createTemplate('string:{$object->hello}'); + $tpl->assign('object', $object); + $this->assertEquals('hello_world', $this->smarty->fetch($tpl)); + } + + /** + * test simple object variable with variable property + */ + public function testObjectVariableOutputVariableProperty() + { + $object = new VariableObject; + $this->smarty->disableSecurity(); + $tpl = $this->smarty->createTemplate('string:{$p=\'hello\'}{$object->$p}'); + $tpl->assign('object', $object); + $this->assertEquals('hello_world', $this->smarty->fetch($tpl)); + } + + /** + * test simple object variable with method + */ + public function testObjectVariableOutputMethod() + { + $object = new VariableObject; + $tpl = $this->smarty->createTemplate('string:{$object->myhello()}'); + $tpl->assign('object', $object); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + + /** + * test simple object variable with method + */ + public function testObjectVariableOutputVariableMethod() + { + $object = new VariableObject; + $this->smarty->disableSecurity(); + $tpl = $this->smarty->createTemplate('string:{$p=\'myhello\'}{$object->$p()}'); + $tpl->assign('object', $object); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + + /** + * test object variable in double quoted string + */ + public function testObjectVariableOutputDoubleQuotes() + { + $object = new VariableObject; + $tpl = $this->smarty->createTemplate('string:{"double quoted `$object->hello` okay"}'); + $tpl->assign('object', $object); + $this->assertEquals('double quoted hello_world okay', $this->smarty->fetch($tpl)); + } + + /** + * test object variable in double quoted string as include name + */ + public function testObjectVariableOutputDoubleQuotesInclude() + { + $object = new VariableObject; + $tpl = $this->smarty->createTemplate('string:{include file="`$object->hello`_test.tpl"}'); + $tpl->assign('object', $object); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } +} + +Class VariableObject +{ + public $hello = 'hello_world'; + + public function myhello() + { + return 'hello world'; + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Objects/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Objects/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Objects/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Objects/templates/hello_world_test.tpl b/tests/UnitTests/TemplateSource/ValueTests/Objects/templates/hello_world_test.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Objects/templates/hello_world_test.tpl @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/Objects/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Objects/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Objects/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php new file mode 100644 index 00000000..8892a542 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php @@ -0,0 +1,186 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test PHP empty() on variables true + */ + public function testEmpty1() + { + $this->smarty->disableSecurity(); + $this->smarty->assign('var', array(null, + false, + (int) 0, + (float) 0.0, + '', + array())); + $expected = ' true , true , true , true , true , true , true , true '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if empty($var[0])} true {else} false {/IF} + ,{if empty($var[1])} true {else} false {/IF} + ,{if empty($var[2])} true {else} false {/IF} + ,{if empty($var[3])} true {else} false {/IF} + ,{if empty($var[4])} true {else} false {/IF} + ,{if empty($var[5])} true {else} false {/IF} + ,{if empty($var[6])} true {else} false {/IF} + ,{if empty($varr)} true {else} false {/IF} + ')); + } + + /** + * test PHP empty() on function result true + */ + public function testEmpty2() + { + if (version_compare(phpversion(), '5.5', '<')) { + $this->markTestSkipped('runs only on PHP > 5.5'); + } + + $this->smarty->disableSecurity(); + $this->smarty->assign('var', array(null, + false, + (int) 0, + (float) 0.0, + '', + array())); + $expected = ' true , true , true , true , true , true '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if empty(pass($var[0]))} true {else} false {/IF} + ,{if empty(pass($var[1]))} true {else} false {/IF} + ,{if empty(pass($var[2]))} true {else} false {/IF} + ,{if empty(pass($var[3]))} true {else} false {/IF} + ,{if empty(pass($var[4]))} true {else} false {/IF} + ,{if empty(pass($var[5]))} true {else} false {/IF} + ')); + } + /** + * test PHP empty() on function result false + */ + public function testEmpty3() + { + if (version_compare(phpversion(), '5.5', '<')) { + $this->markTestSkipped('runs only on PHP > 5.5'); + } + $this->smarty->disableSecurity(); + $this->smarty->assign('var', array(true, + (int) 1, + (float) 0.1, + ' ', + array(1))); + $expected = ' false , false , false , false , false '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if empty(pass($var[0]))} true {else} false {/IF} + ,{if empty(pass($var[1]))} true {else} false {/IF} + ,{if empty(pass($var[2]))} true {else} false {/IF} + ,{if empty(pass($var[3]))} true {else} false {/IF} + ,{if empty(pass($var[4]))} true {else} false {/IF} + ')); + } + /** + * test PHP empty() on object + */ + public function testEmpty4() + { + if (version_compare(phpversion(), '5.5', '<')) { + $this->markTestSkipped('runs only on PHP > 5.5'); + } + + $this->smarty->disableSecurity(); + $this->smarty->assign('var', new TestIsset()); + $expected = ' true , false , false , true , true , true , false '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if empty($var->isNull)} true {else} false {/IF} + ,{if empty($var->isSet)} true {else} false {/IF} + ,{if empty($var->arr[\'isSet\'])} true {else} false {/IF} + ,{if empty($var->arr[\'isNull\'])} true {else} false {/IF} + ,{if empty($var->arr[\'foo\'])} true {else} false {/IF} + ,{if empty($var->pass(null))} true {else} false {/IF} + ,{if empty($var->pass(1))} true {else} false {/IF} + ')); + } + /** + * test PHP isset() on variables and functions + */ + public function testIsset1() + { + $this->smarty->disableSecurity(); + $this->smarty->assign('isNull', null); + $this->smarty->assign('isSet', 1); + $this->smarty->assign('arr', array('isNull' => null, 'isSet' => 1)); + $expected = ' false , true , false , true , false , false , false , true '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if isset($isNull)} true {else} false {/IF} + ,{if isset($isSet)} true {else} false {/IF} + ,{if isset($foo)} true {else} false {/IF} + ,{if isset($arr[\'isSet\'])} true {else} false {/IF} + ,{if isset($arr[\'isNull\'])} true {else} false {/IF} + ,{if isset($arr[\'foo\'])} true {else} false {/IF} + ,{if isset(pass(null))} true {else} false {/IF} + ,{if isset(pass(1))} true {else} false {/IF} + ')); + } + /** + * test PHP isset() on object + */ + public function testIsset2() + { + $this->smarty->disableSecurity(); + $this->smarty->assign('var', new TestIsset()); + $expected = ' false , true , true , false , false , false , true '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if isset($var->isNull)} true {else} false {/IF} + ,{if isset($var->isSet)} true {else} false {/IF} + ,{if isset($var->arr[\'isSet\'])} true {else} false {/IF} + ,{if isset($var->arr[\'isNull\'])} true {else} false {/IF} + ,{if isset($var->arr[\'foo\'])} true {else} false {/IF} + ,{if isset($var->pass(null))} true {else} false {/IF} + ,{if isset($var->pass(1))} true {else} false {/IF} + ')); + } +} + +/** + * @param mixed $v + * + * @return mixed + */ +function pass($v) { + return $v; +} + +/** + * Class TestIsset + */ +class TestIsset { + public $isNull = null; + public $isSet = 1; + public $arr = array('isNull' => null, 'isSet' => 1); + + /** + * @param mixed $v + * + * @return mixed + */ + public function pass($v) { + return $v; + } +} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php new file mode 100644 index 00000000..41378e1b --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php @@ -0,0 +1,81 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test simple single quoted string + */ + public function testSimpleSingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello World\'}{$foo}'); + $this->assertEquals('Hello World', $this->smarty->fetch($tpl)); + } + + /** + * test that tags not interpreted in single quoted strings + */ + public function testTagsInSingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello {1+2} World\'}{$foo}'); + $this->assertEquals('Hello {1+2} World', $this->smarty->fetch($tpl)); + } + + /** + * test that vars not interpreted in single quoted strings + */ + public function testVarsInSingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello $bar World\'}{$foo}'); + $this->assertEquals('Hello $bar World', $this->smarty->fetch($tpl)); + } + + /** + * test double quotes in single quoted strings + */ + public function testDoubleQuotesInSingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello "World"\'}{$foo}'); + $this->assertEquals('Hello "World"', $this->smarty->fetch($tpl)); + } + + /** + * test escaped single quotes in single quoted strings + */ + public function testEscapedSingleQuotesInSingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello \\\'World\'}{$foo}'); + $this->assertEquals("Hello 'World", $this->smarty->fetch($tpl)); + } + + /** + * test empty single quoted strings + */ + public function testEmptySingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'\'}{$foo}'); + $this->assertEquals("", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/SmartyConstantTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/SmartyConstantTest.php new file mode 100644 index 00000000..179f7123 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/SmartyConstantTest.php @@ -0,0 +1,45 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {$smarty.constant.foo} + * + */ + public function testSmartyConstant() { + define('MY_CONST_VAL','MyConstant'); + + $this->assertEquals('MyConstant', $this->smarty->fetch('constant.tpl')); + } + /** + * test {$smarty.constant.foo} + * + */ + public function testSmartyConstantVariable() { + define('MY_CONST_VAL2','MyConstantVar'); + $this->smarty->assign('foo', 'MY_CONST_VAL2'); + $this->assertEquals('MyConstantVar', $this->smarty->fetch('constant_variable.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant.tpl new file mode 100644 index 00000000..4349b8c1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant.tpl @@ -0,0 +1 @@ +{$smarty.const.MY_CONST_VAL} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant_variable.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant_variable.tpl new file mode 100644 index 00000000..4166c879 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant_variable.tpl @@ -0,0 +1 @@ +{$smarty.const.$foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php new file mode 100644 index 00000000..cb92b776 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php @@ -0,0 +1,84 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test cookies + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataProvider + */ + public function testCookie($caching, $value) { + $_COOKIE['fooBar'] = $value; + $this->smarty->caching = $caching; + $this->assertEquals($value, $this->smarty->fetch('cookie.tpl')); + } + /** + * test variable cookies + * + */ + public function testCookieVariable() { + $_COOKIE['fooBarVar'] = 'fooBarVarValue'; + $this->smarty->assign('foo', 'fooBarVar'); + $this->assertEquals('fooBarVarValue', $this->smarty->fetch('cookie_variable.tpl')); + } + + /** + * test cookies with modifier + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataProviderModifier + */ + public function testCookieModifier($caching, $value, $result) { + $_COOKIE['fooBar'] = $value; + $this->smarty->caching = $caching; + $this->assertEquals($result, $this->smarty->fetch('cookie_modifier.tpl')); + } + + /** + * data provider + */ + public function dataProvider() + { + return array( + 'compile' => array(false, 'buh'), + 'compiled' => array(false, 'bar'), + 'create cache' => array(true, 'cached buh'), + 'cacheded' => array(true, 'cached bar'), + ); + } + public function dataProviderModifier() + { + return array( + 'compile' => array(false, 'buh', 3), + 'compiled' => array(false, 'bar1', 4), + 'create cache' => array(true, 'cached buh', 10), + 'cacheded' => array(true, 'cached bar1', 11), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie.tpl new file mode 100644 index 00000000..9f206d7b --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie.tpl @@ -0,0 +1 @@ +{$smarty.cookies.fooBar nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_modifier.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_modifier.tpl new file mode 100644 index 00000000..7ed949ef --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_modifier.tpl @@ -0,0 +1 @@ +{$smarty.cookies.fooBar|strlen nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_variable.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_variable.tpl new file mode 100644 index 00000000..6a135606 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_variable.tpl @@ -0,0 +1 @@ +{$smarty.cookies.$foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/SmartyDelimiterTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/SmartyDelimiterTest.php new file mode 100644 index 00000000..3a298362 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/SmartyDelimiterTest.php @@ -0,0 +1,34 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {$smarty.ldelim} {$smarty.rdelim} + * + */ + public function testSmartyDelimiter() { + $this->assertEquals('left = { right = }', $this->smarty->fetch('delimiter.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates/delimiter.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates/delimiter.tpl new file mode 100644 index 00000000..937b53fc --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates/delimiter.tpl @@ -0,0 +1 @@ +left = {$smarty.ldelim} right = {$smarty.rdelim} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php new file mode 100644 index 00000000..b14c271c --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php @@ -0,0 +1,36 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * @expectedException SmartyException + * @expectedExceptionMessage $smarty.foo is not defined + * test undefined Smarty special variable + * + */ + public function testSmartyError() { + $this->assertEquals(Smarty::SMARTY_VERSION, $this->smarty->fetch('error.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates/error.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates/error.tpl new file mode 100644 index 00000000..7c541f67 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates/error.tpl @@ -0,0 +1 @@ +{$smarty.foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php new file mode 100644 index 00000000..724f2bf5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php @@ -0,0 +1,50 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {$smarty.now} + * + */ + public function testSmartyNow() { + $result = $this->smarty->fetch('now.tpl'); + $this->assertTrue(is_numeric($result)); + $this->assertTrue((time() - $result) <= 1); + } + /** + * test {$smarty.now nocache} + * + */ + public function testSmartyNowNocache() { + $this->smarty->setCaching(true); + $result = $this->smarty->fetch('now_nocache.tpl'); + $this->assertTrue(is_numeric($result)); + $this->assertTrue((time() - $result) <= 1); + sleep(2); + $result2 = $this->smarty->fetch('now_nocache.tpl'); + $this->assertTrue(is_numeric($result2)); + $this->assertTrue((time() - $result2) <= 1); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now.tpl new file mode 100644 index 00000000..057fabdf --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now.tpl @@ -0,0 +1 @@ +{$smarty.now} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now_nocache.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now_nocache.tpl new file mode 100644 index 00000000..3d450d50 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now_nocache.tpl @@ -0,0 +1 @@ +{$smarty.now nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/PostTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/PostTest.php new file mode 100644 index 00000000..a49e44d8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/PostTest.php @@ -0,0 +1,84 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test $_POST + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataProvider + */ + public function testPost($caching, $value) { + $_POST['fooBar'] = $value; + $this->smarty->caching = $caching; + $this->assertEquals($value, $this->smarty->fetch('post.tpl')); + } + + /** + * test $_POST with modifier + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataProviderModifier + */ + public function testPostModifier($caching, $value, $result) { + $_POST['fooBar'] = $value; + $this->smarty->caching = $caching; + $this->assertEquals($result, $this->smarty->fetch('post_modifier.tpl')); + } + + /** + * test variable post + * + */ + public function testPostVariable() { + $_POST['fooBarVar'] = 'fooBarVarValue'; + $this->smarty->assign('foo', 'fooBarVar'); + $this->assertEquals('fooBarVarValue', $this->smarty->fetch('post_variable.tpl')); + } + /** + * data provider + */ + public function dataProvider() + { + return array( + 'compile' => array(false, 'buh'), + 'compiled' => array(false, 'bar'), + 'create cache' => array(true, 'cached buh'), + 'cacheded' => array(true, 'cached bar'), + ); + } + public function dataProviderModifier() + { + return array( + 'compile' => array(false, 'buh', 3), + 'compiled' => array(false, 'bar1', 4), + 'create cache' => array(true, 'cached buh', 10), + 'cacheded' => array(true, 'cached bar1', 11), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post.tpl new file mode 100644 index 00000000..fa50e50a --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post.tpl @@ -0,0 +1 @@ +{$smarty.post.fooBar nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_modifier.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_modifier.tpl new file mode 100644 index 00000000..8078b898 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_modifier.tpl @@ -0,0 +1 @@ +{$smarty.post.fooBar|strlen nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_variable.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_variable.tpl new file mode 100644 index 00000000..98388615 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_variable.tpl @@ -0,0 +1 @@ +{$smarty.post.$foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/SmartyTemplateObjectTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/SmartyTemplateObjectTest.php new file mode 100644 index 00000000..6f661b4d --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/SmartyTemplateObjectTest.php @@ -0,0 +1,34 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {$smarty.template_objects} + * + */ + public function testSmartyTempalteObject() { + $this->assertEquals('okay', $this->smarty->fetch('template_object.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates/template_object.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates/template_object.tpl new file mode 100644 index 00000000..08babe7e --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates/template_object.tpl @@ -0,0 +1 @@ +{if $smarty.template_object instanceof Smarty_Internal_Template}okay{/if} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php new file mode 100644 index 00000000..733609a3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php @@ -0,0 +1,34 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {$smarty.version} + * + */ + public function testSmartyVersion() { + $this->assertEquals(Smarty::SMARTY_VERSION, $this->smarty->fetch('version.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates/version.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates/version.tpl new file mode 100644 index 00000000..b78488a3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates/version.tpl @@ -0,0 +1 @@ +{$smarty.version} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php new file mode 100644 index 00000000..670324f1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php @@ -0,0 +1,137 @@ +setUpSmarty(dirname(__FILE__)); + + stream_wrapper_register("var", "VariableStream") + or die("Failed to register protocol"); + $fp = fopen("var://foo", "r+"); + fwrite($fp, 'hello world'); + fclose($fp); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function tearDown() + { + parent::tearDown(); + stream_wrapper_unregister("var"); + } + + /** + * test stream variable + */ + public function testStreamVariable1() + { + $tpl = $this->smarty->createTemplate('eval:{$var:foo}', null, null, $this->smarty); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + /* + public function testStreamVariable2() + { + $tpl = $this->smarty->createTemplate('eval:{var:\'foo\'}', null, null, $this->smarty); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + + public function testStreamVariable3() + { + $tpl = $this->smarty->createTemplate('eval:{var:"foo"}', null, null, $this->smarty); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + */ + /** + * test no existant stream variable + */ + // public function testStreamVariable2() + // { + // $tpl = $this->smarty->createTemplate('eval:{$var:bar}', null, null, $this->smarty); + // $this->assertEquals('', $this->smarty->fetch($tpl)); + // } +} + +class VariableStream +{ + private $position; + private $varname; + + public function stream_open($path, $mode, $options, &$opened_path) + { + $url = parse_url($path); + $this->varname = $url["host"]; + $this->position = 0; + + return true; + } + + public function stream_read($count) + { + $p = &$this->position; + $ret = substr($GLOBALS[$this->varname], $p, $count); + $p += strlen($ret); + + return $ret; + } + + public function stream_write($data) + { + $v = &$GLOBALS[$this->varname]; + $l = strlen($data); + $p = &$this->position; + $v = substr($v, 0, $p) . $data . substr($v, $p += $l); + + return $l; + } + + public function stream_tell() + { + return $this->position; + } + + public function stream_eof() + { + return $this->position >= strlen($GLOBALS[$this->varname]); + } + + public function stream_seek($offset, $whence) + { + $l = strlen($GLOBALS[$this->varname]); + $p = &$this->position; + switch ($whence) { + case SEEK_SET: + $newPos = $offset; + break; + case SEEK_CUR: + $newPos = $p + $offset; + break; + case SEEK_END: + $newPos = $l + $offset; + break; + default: + return false; + } + $ret = ($newPos >= 0 && $newPos <= $l); + if ($ret) { + $p = $newPos; + } + return $ret; + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/VariableVariableTest.php b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/VariableVariableTest.php new file mode 100644 index 00000000..cbd7c662 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/VariableVariableTest.php @@ -0,0 +1,63 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test variable name in variable + */ + public function testVariableVariable1() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'bar\'}{$bar=123}{${$foo}}'); + $this->assertEquals('123', $this->smarty->fetch($tpl)); + } + + /** + * test part of variable name in variable + */ + public function testVariableVariable2() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'a\'}{$bar=123}{$b{$foo}r}'); + $this->assertEquals('123', $this->smarty->fetch($tpl)); + } + + /** + * test several parts of variable name in variable + */ + public function testVariableVariable3() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'a\'}{$foo2=\'r\'}{$bar=123}{$b{$foo}{$foo2}}'); + $this->assertEquals('123', $this->smarty->fetch($tpl)); + } + + /** + * test nesed parts of variable name in variable + */ + public function testVariableVariable4() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'ar\'}{$foo2=\'oo\'}{$bar=123}{$b{$f{$foo2}}}'); + $this->assertEquals('123', $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php b/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php new file mode 100644 index 00000000..e546b670 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php @@ -0,0 +1,299 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test scope + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestAppendScope + */ + public function testAppendScope($code, $useSmarty, $result, $testName, $testNumber) + { + $file = "testAppendScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code . '{checkvar var=foo}'); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $data1 = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data = $this->smarty->createData($data1); + $data1->assign('foo', 'data1'); + $data->assign('foo', 'data'); + $this->assertEquals($result, $this->smarty->fetch('scope_tag.tpl', $data), + "test - {$code} - {$testName}"); + } + + /* + * Data provider für testAppendScope + */ + public function dataTestAppendScope() + { + $i = 0; + /* + * Code + * use Smarty object + * result + * test name + */ + return array(array('{$foo[] = \'newvar\' scope=tpl_root}', true, + '#testAppendScope_0.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), + array('{append var=foo value=\'newvar\' scope=tpl_root}', true, + '#testAppendScope_1.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), + array('{append var=foo value=\'newvar\' scope=global}', true, + '#testAppendScope_2.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =\'smarty\'#global:$foo =array(0=>\'data\',1=>\'newvar\',)', + '', $i ++,), + array('{append var=foo value=\'newvar\' scope=smarty}', true, + '#testAppendScope_3.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =array(0=>\'data\',1=>\'newvar\',)#global:$foo =\'global\'', + '', $i ++,),); + } + + /** + * Test scope + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestAssignScope + */ + public function testAssignScope($code, $useSmarty, $result, $testName, $testNumber) + { + $file = "testAssignScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code . '{checkvar var=foo}'); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $data = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data->assign('foo', 'data'); + $this->assertEquals('#' . $file . $result, + $this->smarty->fetch('scope_tag.tpl', $data), "test - {$code} - {$testName}"); + } + + /* + * Data provider für testAssignScope + */ + public function dataTestAssignScope() + { + $i = 0; + /* + * Code + * use Smarty object + * result + * test name + */ + return array(array('{$foo = \'newvar\'}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), array('{assign var=foo value=\'newvar\'}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), array('{$foo = \'newvar\' scope=local}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), + array('{assign var=foo value=\'newvar\' scope=local}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), array('{$foo = \'newvar\' scope=parent}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), array('{assign var=foo value=\'newvar\' scope=parent}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), + array('{$foo = \'newvar\' scope=tpl_root}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), array('{$foo = \'newvar\' scope=global}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'newvar\'', + '', $i ++,), array('{$foo = \'newvar\' scope=root}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), + array('{$foo = \'newvar\' scope=root}', false, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + 'no smarty', $i ++,), array('{$foo = \'newvar\' scope=smarty}', false, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'newvar\'#global:$foo =\'global\'', + 'no smarty', $i ++,),); + } + + /** + * Test scope nocache + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestScopeNocache + */ + public function testScopeNocache($var, $file, $result) + { + $this->smarty->setCaching(true); + $this->smarty->assign('bar', $var, true); + $this->smarty->assign('buh', $var); + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $this->assertEquals($result, $this->smarty->fetch($file), "test - {$file} {$var}"); + } + + /* + * Data provider für testscopenocache + */ + public function dataTestScopeNocache() + { + /* + * variable value + * result + */ + return array(array('b1', 'test_scope_assignbar.tpl', + '#test_scope_assignbar.tpl:$foo =\'b1\'#Smarty:$foo =\'smarty\'#global:$foo =\'b1\'',), + array('b2', 'test_scope_assignbar.tpl', + '#test_scope_assignbar.tpl:$foo =\'b2\'#Smarty:$foo =\'smarty\'#global:$foo =\'b2\'',), + array('b1', 'test_scope_assignnocache.tpl', + '#test_scope_assignnocache.tpl:$foo =\'b1\'#Smarty:$foo =\'smarty\'#global:$foo =\'b1\'',), + array('b2', 'test_scope_assignnocache.tpl', + '#test_scope_assignnocache.tpl:$foo =\'b2\'#Smarty:$foo =\'smarty\'#global:$foo =\'b2\'',),); + } + + /** + * Test scope + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestIncludeScope + */ + public function testIncludeScope($code, $useSmarty, $result, $testName, $testNumber = null) + { + $file = "testIncludeScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $data = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data->assign('foo', 'data'); + if (!$useSmarty) { + $testName .= 'no smarty'; + } + $this->assertEquals($result, $this->smarty->fetch('test_scope.tpl', $data), + "test - {$code} - {$testName}"); + } + + /* + * Data provider for testIncludeScope + */ + public function dataTestIncludeScope() + { + $i = 0; + return array(/* + * Code + * use Smarty object + * result + * test name + */ + array('{include \'test_scope_assign.tpl\'}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'data\'#test_scope.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++), array('{include \'test_scope_assign.tpl\' scope=parent}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++), + array('{include \'test_scope_assign.tpl\' scope=tpl_root}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++), array('{include \'test_scope_assign.tpl\' scope=root}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++), array('{include \'test_scope_assign.tpl\' scope=root}', false, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . + $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++), + array('{include \'test_scope_assign.tpl\' scope=smarty}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'newvar\'#global:$foo =\'global\'', + '', $i ++), array('{include \'test_scope_assign.tpl\' scope=global}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'newvar\'', + '', $i ++), + array('{include \'test_scope_pluginassign.tpl\' scope=global}', true, + '#test_scope_pluginassign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'newvar\'', + '', $i ++), array('{include \'test_scope_assign_noscope.tpl\' scope=root}', true, + '#test_scope_assign_noscope.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'data\'#test_scope.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++),); + } + + /** + * Test scope + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestConfigScope + */ + public function testConfigScope($code, $useSmarty, $result, $testName, $testNumber) + { + $file = "testConfigScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code . '{checkconfigvar var=foo}'); + $this->smarty->assignGlobal('file', $file); + $this->smarty->configLoad('smarty.conf'); + $data = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data->configLoad('data.conf'); + $this->assertEquals('#' . $file . $result, + $this->smarty->fetch('scope_tag.tpl', $data), "test - {$code} - {$testName}"); + } + + /* + * Data provider für testConfigScope + */ + public function dataTestConfigScope() + { + $i = 0; + /* + * Code + * use Smarty object + * result + * test name + */ + return array(array('{config_load \'template.conf\'}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'', + '', $i ++,), array('{config_load \'template.conf\' scope=local}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'', + '', $i ++,), array('{config_load \'template.conf\' scope=parent}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'', + '', $i ++,), + array('{config_load \'template.conf\' scope=tpl_root}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'', + '', $i ++,), array('{config_load \'template.conf\' scope=root}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'', + '', $i ++,), array('{config_load \'template.conf\' scope=root}', false, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'', + 'no smarty', $i ++,), + array('{config_load \'template.conf\' scope=smarty}', false, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'newvar\'', + 'no smarty', $i ++,),); + } + + public function testFunctionScope() + { + $this->smarty->assign('scope', 'none'); + $r = $this->smarty->fetch('test_function_scope.tpl'); + } +} diff --git a/tests/UnitTests/TemplateSource/X_Scopes/cache/.gitignore b/tests/UnitTests/TemplateSource/X_Scopes/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/X_Scopes/configs/data.conf b/tests/UnitTests/TemplateSource/X_Scopes/configs/data.conf new file mode 100644 index 00000000..c9349c71 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/configs/data.conf @@ -0,0 +1 @@ +foo = data diff --git a/tests/UnitTests/TemplateSource/X_Scopes/configs/smarty.conf b/tests/UnitTests/TemplateSource/X_Scopes/configs/smarty.conf new file mode 100644 index 00000000..d65d1fd0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/configs/smarty.conf @@ -0,0 +1 @@ +foo = smarty diff --git a/tests/UnitTests/TemplateSource/X_Scopes/configs/template.conf b/tests/UnitTests/TemplateSource/X_Scopes/configs/template.conf new file mode 100644 index 00000000..303000d4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/configs/template.conf @@ -0,0 +1 @@ +foo = newvar diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope.tpl new file mode 100644 index 00000000..3aad88bf --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope.tpl @@ -0,0 +1,35 @@ +{strip} + {function 'a'} + {call 'b'} + {/function} +{function 'b'} + {include 'test_function_scope_include.tpl'} +{/function} +{function c} + {call $scope} +{/function} +{function 'none'} + {$foo = 'newvar'} + {checkvar var=foo} +{/function} +{function 'local'} + {$foo = 'newvar' scope='local'} + {checkvar var=foo} +{/function} +{function 'parent'} + {$foo = 'newvar' scope='parent'} + {checkvar var=foo} +{/function} +{function 'tpl_root'} + {$foo = 'newvar' scope='tpl_root'} + {checkvar var=foo} +{/function} +{function 'smarty'} + {$foo = 'newvar' scope='smarty'} + {checkvar var=foo} +{/function} +{function 'global'} + {$foo = 'newvar' scope='global'} + {checkvar var=foo} +{/function} +{call 'a'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope_include.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope_include.tpl new file mode 100644 index 00000000..5428e13d --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope_include.tpl @@ -0,0 +1,2 @@ +{strip} + {call 'c'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope.tpl new file mode 100644 index 00000000..bfb1e6cb --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope.tpl @@ -0,0 +1 @@ +{include $file} diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign.tpl new file mode 100644 index 00000000..ae7268d8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign.tpl @@ -0,0 +1 @@ +{$foo = 'newvar'}{checkvar var=foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign_noscope.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign_noscope.tpl new file mode 100644 index 00000000..d3ff9f6a --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign_noscope.tpl @@ -0,0 +1 @@ +{$foo = 'newvar' noscope}{checkvar var=foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignbar.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignbar.tpl new file mode 100644 index 00000000..c0be3a40 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignbar.tpl @@ -0,0 +1 @@ +{$foo = $bar scope=global}{checkvar var=foo nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignnocache.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignnocache.tpl new file mode 100644 index 00000000..4bde90af --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignnocache.tpl @@ -0,0 +1 @@ +{$foo = $buh scope=global nocache}{checkvar var=foo nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_pluginassign.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_pluginassign.tpl new file mode 100644 index 00000000..e19a560a --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_pluginassign.tpl @@ -0,0 +1 @@ +{pluginassign var=foo value='newvar'}{checkvar var=foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates_c/.gitignore b/tests/UnitTests/TemplateSource/X_Scopes/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/X_Scopes/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Xml/XmlTest.php b/tests/UnitTests/TemplateSource/Xml/XmlTest.php new file mode 100644 index 00000000..9690a35c --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/XmlTest.php @@ -0,0 +1,137 @@ + tag handling + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class XmlTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->enableSecurity(); + $this->smarty->setForceCompile(true); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test standard xml + */ + public function testXml() + { + $tpl = $this->smarty->createTemplate('xml.tpl'); + $this->assertEquals('', $this->smarty->fetch($tpl)); + } + + /** + * test standard xml Smarty::PHP_QUOTE + */ + public function testXmlPhpQuote() + { + $this->smarty->compile_id = 'PHP_QUOTE'; + $this->smarty->security_policy->php_handling = Smarty::PHP_QUOTE; + $tpl = $this->smarty->createTemplate('xml.tpl'); + $this->assertEquals('', $this->smarty->fetch($tpl)); + } + + /** + * test standard xml Smarty::PHP_ALLOW + */ + public function testXmlPhpAllow() + { + $this->smarty->compile_id = 'PHP_ALLOW'; + $this->smarty->security_policy->php_handling = Smarty::PHP_ALLOW; + $tpl = $this->smarty->createTemplate('xml.tpl'); + $this->assertEquals('', $this->smarty->fetch($tpl)); + } + + /** + * test xml caching + */ + public function testXmlCaching() + { + $this->smarty->security_policy->php_handling = Smarty::PHP_PASSTHRU; + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $content = $this->smarty->fetch('xml.tpl'); + $this->assertEquals('', $content); + } + /** + * test subtemplate xml caching + */ + public function testXmlCaching2() + { + $this->smarty->security_policy->php_handling = Smarty::PHP_PASSTHRU; + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $content = $this->smarty->fetch('xml_main.tpl'); + $this->assertEquals('', $content); + } + + /** + * test xml caching PhpQuote + */ + public function testXmlCachingPhpQuote() + { + $this->smarty->compile_id = 'PHP_QUOTE'; + $this->smarty->security_policy->php_handling = Smarty::PHP_QUOTE; + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $content = $this->smarty->fetch('xml.tpl'); + $this->assertEquals('', $content); + } + + /** + * test xml caching PhpAllow + */ + public function testXmlCachingPhpAllow() + { + $this->smarty->compile_id = 'PHP_ALLOW'; + $this->smarty->security_policy->php_handling = Smarty::PHP_ALLOW; + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $content = $this->smarty->fetch('xml.tpl'); + $this->assertEquals('', $content); + } + /** + * test xml with variable + */ + public function testXmlVariable() + { + $this->smarty->assign('foo','bar'); + $content = $this->smarty->fetch('xmlvar.tpl'); + $this->assertEquals('', $content); + } + /** + * test xml with nocache variable + */ + public function testXmlVariableNocache1() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('foo','bar',true); + $content = $this->smarty->fetch('xmlvar.tpl'); + $this->assertEquals('', $content); + } + public function testXmlVariableNocache2() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('foo','foo',true); + $content = $this->smarty->fetch('xmlvar.tpl'); + $this->assertEquals('', $content); + } +} diff --git a/tests/UnitTests/TemplateSource/Xml/cache/.gitignore b/tests/UnitTests/TemplateSource/Xml/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Xml/templates/xml.tpl b/tests/UnitTests/TemplateSource/Xml/templates/xml.tpl new file mode 100644 index 00000000..b994f536 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/templates/xml.tpl @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/Xml/templates/xml_main.tpl b/tests/UnitTests/TemplateSource/Xml/templates/xml_main.tpl new file mode 100644 index 00000000..578dc4b8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/templates/xml_main.tpl @@ -0,0 +1 @@ +{include 'xml.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/Xml/templates/xmlvar.tpl b/tests/UnitTests/TemplateSource/Xml/templates/xmlvar.tpl new file mode 100644 index 00000000..254635ea --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/templates/xmlvar.tpl @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/Xml/templates_c/.gitignore b/tests/UnitTests/TemplateSource/Xml/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php new file mode 100644 index 00000000..ecbf045d --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php @@ -0,0 +1,33 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testModifier327() + { + $this->assertEquals('hello you', $this->smarty->fetch('string:{"hello world"|substr:0:-5|cat:"you"}')); + } + +} diff --git a/tests/UnitTests/TemplateSource/_Issues/327/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/327/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/327/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/327/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/327/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/327/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php b/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php new file mode 100644 index 00000000..1f969291 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php @@ -0,0 +1,35 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testextends419() + { + $this->smarty->left_delimiter = '{{'; + $this->smarty->right_delimiter = '}}'; + $this->assertEquals('child', $this->smarty->fetch('extends:001_parent.tpl|001_child.tpl')); + } + +} diff --git a/tests/UnitTests/TemplateSource/_Issues/419/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/419/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/419/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/419/templates/001_child.tpl b/tests/UnitTests/TemplateSource/_Issues/419/templates/001_child.tpl new file mode 100644 index 00000000..e9d4ff8f --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/419/templates/001_child.tpl @@ -0,0 +1 @@ +{{block name='b'}}child{{/block}} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/419/templates/001_parent.tpl b/tests/UnitTests/TemplateSource/_Issues/419/templates/001_parent.tpl new file mode 100644 index 00000000..15ddde25 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/419/templates/001_parent.tpl @@ -0,0 +1 @@ +{{block name='b'}}parent{{/block}} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/419/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/419/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/419/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php b/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php new file mode 100644 index 00000000..c541b3cb --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php @@ -0,0 +1,35 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testnested422() + { + $this->assertEquals('loop: 1inner: 0loop: 2inner: 1', $this->smarty->fetch('422_test.tpl')); + } + +} diff --git a/tests/UnitTests/TemplateSource/_Issues/422/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/422/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/422/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/422/templates/422_test.tpl b/tests/UnitTests/TemplateSource/_Issues/422/templates/422_test.tpl new file mode 100644 index 00000000..09fb9d41 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/422/templates/422_test.tpl @@ -0,0 +1,8 @@ +{strip} +{assign var=samplearr value=[["list" => []],["list" => ["item"]]]} +{foreach $samplearr as $v} + {section name=inner loop=$v.list} + {/section} + loop: {$v@iteration} + inner: {$smarty.section.inner.total} +{/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/422/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/422/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/422/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php b/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php new file mode 100644 index 00000000..7c900349 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php @@ -0,0 +1,42 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testSection_001() + { + $this->smarty->assign('foo', array('a', 'b', 'c')); + $this->assertEquals('abc', $this->smarty->fetch('001_section.tpl')); + } + public function testSection_002() + { + $this->smarty->assign('foo', array('a', 'b', 'c')); + $this->assertEquals('abc', $this->smarty->fetch('002_section.tpl')); + } + + +} diff --git a/tests/UnitTests/TemplateSource/_Issues/428/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/428/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/428/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/428/templates/001_section.tpl b/tests/UnitTests/TemplateSource/_Issues/428/templates/001_section.tpl new file mode 100644 index 00000000..ea6dc9ab --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/428/templates/001_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar.index]}{sectionelse} else {/section} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/428/templates/002_section.tpl b/tests/UnitTests/TemplateSource/_Issues/428/templates/002_section.tpl new file mode 100644 index 00000000..4a49fc9e --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/428/templates/002_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/428/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/428/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/428/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php b/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php new file mode 100644 index 00000000..6feac558 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php @@ -0,0 +1,69 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->template_dir = './templates_tmp'; + $this->smarty->assign('file', $file); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array("=====================\n{if true}\n{foreach from=array(1) item='i'}\n \n{/foreach}\n{/if}\n=====================", "=====================\n \n=====================", 'T1', $i++), + array("=====================\n{if true}\n{if true}\n \n{/if}\n{/if}\n=====================", "=====================\n \n=====================", 'T2', $i++), + array("=====================\n{* comment *}\n{* comment *}\n \n{* comment *}\n{* comment *}\n=====================", "=====================\n \n=====================", 'T3', $i++), + array("=====================\na\n{* comment 1 *}\n{* comment 2 *}\n{* comment 3 *}\nb\n=====================", "=====================\na\nb\n=====================", 'T4', $i++), + array("=====================\na\nb{if true}\nd\nf{/if}\nh\n=====================", "=====================\na\nbd\nfh\n=====================", 'T5', $i++), + ); + } + +} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/topic26878/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/topic26878/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/__shared/PHPunitplugins/block.dummyblock.php b/tests/UnitTests/__shared/PHPunitplugins/block.dummyblock.php new file mode 100644 index 00000000..7de4fa09 --- /dev/null +++ b/tests/UnitTests/__shared/PHPunitplugins/block.dummyblock.php @@ -0,0 +1,23 @@ +getAttributes($compiler, $args); + $output = ' $value) { + $output .= "'{$key}'=>\" . "; + $output .= is_string($value) ? "({$value})" : ("'" . var_export($value, true). "'"); + $output .= ' . ",'; + + } + + $output .= ")\";?>\n"; + return $output; + } +} diff --git a/tests/UnitTests/__shared/PHPunitplugins/function.checkconfigvar.php b/tests/UnitTests/__shared/PHPunitplugins/function.checkconfigvar.php new file mode 100644 index 00000000..c026793b --- /dev/null +++ b/tests/UnitTests/__shared/PHPunitplugins/function.checkconfigvar.php @@ -0,0 +1,45 @@ +source->name}:\${$var} ="; + $output .= isset($ptr->config_vars[$var]) ? preg_replace('/\s/', '', var_export($ptr->config_vars[$var], true)) : 'null'; + $ptr = $ptr->parent; + } elseif (in_array('data', $types) && $ptr instanceof Smarty_Data) { + $output .= "#data:\${$var} ="; + $output .= isset($ptr->config_vars[$var]) ? preg_replace('/\s/', '', var_export($ptr->config_vars[$var], true)) : 'null'; + $ptr = $ptr->parent; + } else { + $ptr = null; + } + } + if (in_array('smarty', $types)) { + $output .= "#Smarty:\${$var} ="; + $output .= isset($template->smarty->config_vars[ $var ]) ? + preg_replace('/\s/', '', var_export($template->smarty->config_vars[ $var ], true)) : 'null'; + } + return $output; +} diff --git a/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php b/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php new file mode 100644 index 00000000..5d549c8b --- /dev/null +++ b/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php @@ -0,0 +1,56 @@ +source->name}:\${$var} ="; + $output .= isset($ptr->tpl_vars[$var]) ? preg_replace('/\s/', '', var_export($ptr->tpl_vars[$var]->value, true)) : '>unassigned<'; + $i = 0; + while (isset($ptr->_cache[ 'varStack' ][ $i ])) { + $output .= "#{$ptr->_cache[ 'varStack' ][ $i ]['name']} = "; + $output .= isset($ptr->_cache[ 'varStack' ][ $i ][ 'tpl' ][$var]) ? preg_replace('/\s/', '', var_export($ptr->_cache[ 'varStack' ][ $i ][ 'tpl' ][$var]->value, true)) : '>unassigned<'; + $i ++; + } + $ptr = $ptr->parent; + } elseif (in_array('data', $types) && $ptr instanceof Smarty_Data) { + $output .= "#data:\${$var} ="; + $output .= isset($ptr->tpl_vars[$var]) ? preg_replace('/\s/', '', var_export($ptr->tpl_vars[$var]->value, true)) : '>unassigned<'; + $ptr = $ptr->parent; + } else { + $ptr = null; + } + } + if (in_array('smarty', $types)) { + $output .= "#Smarty:\${$var} ="; + $output .= isset($template->smarty->tpl_vars[ $var ]) ? + preg_replace('/\s/', '', var_export($template->smarty->tpl_vars[ $var ]->value, true)) : '>unassigned<'; + } + if (in_array('global', $types)) { + $output .= "#global:\${$var} ="; + $output .= isset(Smarty::$global_tpl_vars[ $var ]) ? + preg_replace('/\s/', '', var_export(Smarty::$global_tpl_vars[ $var ]->value, true)) : '>unassigned<'; + } + return $output; +} diff --git a/tests/UnitTests/__shared/PHPunitplugins/function.getparams.php b/tests/UnitTests/__shared/PHPunitplugins/function.getparams.php new file mode 100644 index 00000000..be1c26ab --- /dev/null +++ b/tests/UnitTests/__shared/PHPunitplugins/function.getparams.php @@ -0,0 +1,20 @@ +assign($params[ 'assign' ], $template->getTemplateVars($params[ 'var' ])); + } else { + return $template->getTemplateVars($params[ 'var' ]); + } +} diff --git a/tests/UnitTests/__shared/PHPunitplugins/function.pluginassign.php b/tests/UnitTests/__shared/PHPunitplugins/function.pluginassign.php new file mode 100644 index 00000000..111d9d05 --- /dev/null +++ b/tests/UnitTests/__shared/PHPunitplugins/function.pluginassign.php @@ -0,0 +1,21 @@ +assign($params[ 'var' ], $params[ 'value' ]); + return ''; +} diff --git a/tests/UnitTests/__shared/templates/run_code.tpl b/tests/UnitTests/__shared/templates/run_code.tpl new file mode 100644 index 00000000..f2db3620 --- /dev/null +++ b/tests/UnitTests/__shared/templates/run_code.tpl @@ -0,0 +1 @@ +{include $file} \ No newline at end of file diff --git a/tests/UnitTests/__shared/templates/run_code_caching.tpl b/tests/UnitTests/__shared/templates/run_code_caching.tpl new file mode 100644 index 00000000..421be584 --- /dev/null +++ b/tests/UnitTests/__shared/templates/run_code_caching.tpl @@ -0,0 +1 @@ +{include $file caching} \ No newline at end of file diff --git a/tests/UnitTests/__shared/templates/scope_include.tpl b/tests/UnitTests/__shared/templates/scope_include.tpl new file mode 100644 index 00000000..bfb1e6cb --- /dev/null +++ b/tests/UnitTests/__shared/templates/scope_include.tpl @@ -0,0 +1 @@ +{include $file} diff --git a/tests/UnitTests/__shared/templates/scope_tag.tpl b/tests/UnitTests/__shared/templates/scope_tag.tpl new file mode 100644 index 00000000..734ebb7b --- /dev/null +++ b/tests/UnitTests/__shared/templates/scope_tag.tpl @@ -0,0 +1 @@ +{include 'scope_include.tpl'} \ No newline at end of file diff --git a/tests/cache/.gitignore b/tests/cache/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file diff --git a/tests/templates_c/.gitignore b/tests/templates_c/.gitignore new file mode 100644 index 00000000..1d34e205 --- /dev/null +++ b/tests/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* \ No newline at end of file