From fd8f010b05d2b0e57a2104859ba6fb297e8c60fe Mon Sep 17 00:00:00 2001 From: uwetews Date: Sun, 7 Aug 2016 12:57:48 +0200 Subject: [PATCH] update config tests --- .../DefaultConfigHandlerTest.php | 6 +-- .../{ => defaultHandler}/configs/test.conf | 0 .../defaultHandler/templates/foo.tpl | 1 + .../defaultHandler/templates/number.tpl | 1 + .../templates_c}/dummy.txt | 0 .../{ => file}/ConfigVarTest.php | 40 +++++++------- .../PHPunitplugins/resource.db4.php | 0 .../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/dummy.txt | 0 .../ConfigLoad/CompileConfigLoadTest.php | 54 +++++++++++++------ .../TagTests/ConfigLoad/cache/dummy.txt | 0 .../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/006_overwrite.tpl | 1 + .../ConfigLoad/templates/007_overwrite.tpl | 1 + .../ConfigLoad/templates/008_booleanize.tpl | 1 + .../ConfigLoad/templates/009_error.tpl | 1 + 25 files changed, 127 insertions(+), 38 deletions(-) rename tests/UnitTests/ConfigFileTests/{ => defaultHandler}/DefaultConfigHandlerTest.php (95%) rename tests/UnitTests/ConfigFileTests/{ => defaultHandler}/configs/test.conf (100%) create mode 100644 tests/UnitTests/ConfigFileTests/defaultHandler/templates/foo.tpl create mode 100644 tests/UnitTests/ConfigFileTests/defaultHandler/templates/number.tpl rename tests/UnitTests/ConfigFileTests/{cache => defaultHandler/templates_c}/dummy.txt (100%) rename tests/UnitTests/ConfigFileTests/{ => file}/ConfigVarTest.php (88%) rename tests/UnitTests/ConfigFileTests/{ => file}/PHPunitplugins/resource.db4.php (100%) 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 rename tests/UnitTests/ConfigFileTests/{ => file}/templates_c/dummy.txt (100%) create mode 100644 tests/UnitTests/TemplateSource/TagTests/ConfigLoad/cache/dummy.txt 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/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 diff --git a/tests/UnitTests/ConfigFileTests/DefaultConfigHandlerTest.php b/tests/UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php similarity index 95% rename from tests/UnitTests/ConfigFileTests/DefaultConfigHandlerTest.php rename to tests/UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php index 3dfa34a1..458c4d9e 100644 --- a/tests/UnitTests/ConfigFileTests/DefaultConfigHandlerTest.php +++ b/tests/UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php @@ -61,7 +61,7 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty { $this->smarty->registerDefaultConfigHandler('configHandlerData'); $this->smarty->configLoad('foo.conf'); - $this->assertEquals("bar", $this->smarty->fetch('eval:{#foo#}')); + $this->assertEquals("bar", $this->smarty->fetch('foo.tpl')); } /** @@ -74,7 +74,7 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty { $this->smarty->registerDefaultConfigHandler('configHandlerFile'); $this->smarty->configLoad('foo.conf'); - $this->assertEquals("123.4", $this->smarty->fetch('eval:{#Number#}')); + $this->assertEquals("123.4", $this->smarty->fetch('number.tpl')); } /** @@ -87,7 +87,7 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty { $this->smarty->registerDefaultConfigHandler('configHandlerFile'); $this->smarty->configLoad('fo.conf'); - $this->assertEquals("123.4", $this->smarty->fetch('eval:{#Number#}')); + $this->assertEquals("123.4", $this->smarty->fetch('number.tpl')); } /** diff --git a/tests/UnitTests/ConfigFileTests/configs/test.conf b/tests/UnitTests/ConfigFileTests/defaultHandler/configs/test.conf similarity index 100% rename from tests/UnitTests/ConfigFileTests/configs/test.conf rename to tests/UnitTests/ConfigFileTests/defaultHandler/configs/test.conf 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/cache/dummy.txt b/tests/UnitTests/ConfigFileTests/defaultHandler/templates_c/dummy.txt similarity index 100% rename from tests/UnitTests/ConfigFileTests/cache/dummy.txt rename to tests/UnitTests/ConfigFileTests/defaultHandler/templates_c/dummy.txt diff --git a/tests/UnitTests/ConfigFileTests/ConfigVarTest.php b/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php similarity index 88% rename from tests/UnitTests/ConfigFileTests/ConfigVarTest.php rename to tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php index e722ad68..f3261c67 100644 --- a/tests/UnitTests/ConfigFileTests/ConfigVarTest.php +++ b/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php @@ -39,7 +39,7 @@ class ConfigVarTest extends PHPUnit_Smarty public function testConfigNumber() { $this->smarty->configLoad('test.conf'); - $this->assertEquals("123.4", $this->smarty->fetch('eval:{#Number#}')); + $this->assertEquals("123.4", $this->smarty->fetch('number.tpl')); } /** @@ -51,7 +51,7 @@ class ConfigVarTest extends PHPUnit_Smarty public function testConfigText() { $this->smarty->configLoad('test.conf'); - $this->assertEquals("123bvc", $this->smarty->fetch('eval:{#text#}')); + $this->assertEquals("123bvc", $this->smarty->fetch('text.tpl')); } /** @@ -75,7 +75,7 @@ class ConfigVarTest extends PHPUnit_Smarty public function testConfigVariableGlobalSections() { $this->smarty->configLoad('test.conf'); - $this->assertEquals("Welcome to Smarty! Global Section1 Global Section2", $this->smarty->fetch('eval:{#title#} {#sec1#} {#sec2#}')); + $this->assertEquals("Welcome to Smarty! Global Section1 Global Section2", $this->smarty->fetch('sec1sec2.tpl')); } /** @@ -87,7 +87,7 @@ class ConfigVarTest extends PHPUnit_Smarty public function testConfigVariableSection2() { $this->smarty->configLoad('test.conf', 'section2'); - $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('eval:{#title#} {#sec1#} {#sec2#}')); + $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('sec1sec2.tpl')); } /** @@ -99,7 +99,7 @@ class ConfigVarTest extends PHPUnit_Smarty public function testConfigVariableSectionSpecialChar() { $this->smarty->configLoad('test.conf', '/'); - $this->assertEquals("Welcome to Smarty! special char", $this->smarty->fetch('eval:{#title#} {#sec#}')); + $this->assertEquals("Welcome to Smarty! special char", $this->smarty->fetch('sec.tpl')); } /** @@ -111,7 +111,7 @@ class ConfigVarTest extends PHPUnit_Smarty public function testConfigVariableSectionFooBar() { $this->smarty->configLoad('test.conf', 'foo/bar'); - $this->assertEquals("Welcome to Smarty! section foo/bar", $this->smarty->fetch('eval:{#title#} {#sec#}')); + $this->assertEquals("Welcome to Smarty! section foo/bar", $this->smarty->fetch('sec.tpl')); } /** @@ -123,9 +123,9 @@ class ConfigVarTest extends PHPUnit_Smarty public function testConfigDifferentScope() { $this->smarty->configLoad('test.conf', 'section2'); - $tpl = $this->smarty->createTemplate('eval:{#title#} {#sec1#} {#sec2#}'); + $tpl = $this->smarty->createTemplate('sec1sec2.tpl'); $tpl->configLoad('test.conf', 'section1'); - $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('eval:{#title#} {#sec1#} {#sec2#}')); + $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)); } @@ -140,7 +140,7 @@ class ConfigVarTest extends PHPUnit_Smarty { $this->smarty->config_read_hidden = true; $this->smarty->configLoad('test.conf', 'hidden'); - $this->assertEquals("Welcome to Smarty!Hidden Section", $this->smarty->fetch('eval:{#title#}{#hiddentext#}')); + $this->assertEquals("Welcome to Smarty!Hidden Section", $this->smarty->fetch('hidden.tpl')); } /** @@ -155,7 +155,7 @@ class ConfigVarTest extends PHPUnit_Smarty $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('eval:{#title#}{#hiddentext#}')); + $this->assertEquals("Welcome to Smarty!", $this->smarty->fetch('hidden.tpl')); } /** @@ -223,7 +223,7 @@ class ConfigVarTest extends PHPUnit_Smarty { $data = $this->smarty->createData(); $data->configLoad('test.conf'); - $this->assertEquals("123bvc", $this->smarty->fetch('eval:{#text#}', $data)); + $this->assertEquals("123bvc", $this->smarty->fetch('text.tpl', $data)); } /** @@ -294,7 +294,7 @@ class ConfigVarTest extends PHPUnit_Smarty */ public function testConfigTextTemplate() { - $tpl = $this->smarty->createTemplate('eval:{#text#}'); + $tpl = $this->smarty->createTemplate('text.tpl'); $tpl->configLoad('test.conf'); $this->assertEquals("123bvc", $this->smarty->fetch($tpl)); } @@ -307,7 +307,7 @@ class ConfigVarTest extends PHPUnit_Smarty */ public function testConfigGetSingleConfigVarTemplate() { - $tpl = $this->smarty->createTemplate('eval:{#text#}'); + $tpl = $this->smarty->createTemplate('text.tpl'); $tpl->configLoad('test.conf'); $this->assertEquals("Welcome to Smarty!", $tpl->getConfigVars('title')); } @@ -320,7 +320,7 @@ class ConfigVarTest extends PHPUnit_Smarty */ public function testConfigGetAllConfigVarsTemplate() { - $tpl = $this->smarty->createTemplate('eval:{#text#}'); + $tpl = $this->smarty->createTemplate('text.tpl'); $tpl->configLoad('test.conf'); $vars = $tpl->getConfigVars(); $this->assertTrue(is_array($vars)); @@ -336,7 +336,7 @@ class ConfigVarTest extends PHPUnit_Smarty */ public function testConfigClearSingleConfigVarTemplate() { - $tpl = $this->smarty->createTemplate('eval:{#text#}'); + $tpl = $this->smarty->createTemplate('text.tpl'); $tpl->configLoad('test.conf'); $tpl->clearConfig('title'); $this->assertEquals("", $tpl->getConfigVars('title')); @@ -351,7 +351,7 @@ class ConfigVarTest extends PHPUnit_Smarty */ public function testConfigClearConfigAllTemplate() { - $tpl = $this->smarty->createTemplate('eval:{#text#}'); + $tpl = $this->smarty->createTemplate('text.tpl'); $tpl->configLoad('test.conf'); $tpl->clearConfig(); $vars = $tpl->getConfigVars(); @@ -369,25 +369,25 @@ class ConfigVarTest extends PHPUnit_Smarty { $file = realpath($this->smarty->getConfigDir(0) . 'test.conf'); $this->smarty->configLoad($file); - $this->assertEquals("123.4", $this->smarty->fetch('eval:{#Number#}')); + $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('eval:{#foo#}')); + $this->assertEquals("bar", $this->smarty->fetch('foo.tpl')); } public function testConfigUndefinedSilent() { - $this->assertEquals("", $this->smarty->fetch('eval:{#foo#}')); + $this->assertEquals("", $this->smarty->fetch('foo.tpl')); } public function testConfigUndefinedNotice() { $this->smarty->error_unassigned = true; try { - $this->assertEquals("", $this->smarty->fetch('eval:{#foo#}')); + $this->assertEquals("", $this->smarty->fetch('foo.tpl')); } catch (Exception $e) { $this->assertEquals('Undefined variable: foo', $e->getMessage()); diff --git a/tests/UnitTests/ConfigFileTests/PHPunitplugins/resource.db4.php b/tests/UnitTests/ConfigFileTests/file/PHPunitplugins/resource.db4.php similarity index 100% rename from tests/UnitTests/ConfigFileTests/PHPunitplugins/resource.db4.php rename to tests/UnitTests/ConfigFileTests/file/PHPunitplugins/resource.db4.php 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/templates_c/dummy.txt b/tests/UnitTests/ConfigFileTests/file/templates_c/dummy.txt similarity index 100% rename from tests/UnitTests/ConfigFileTests/templates_c/dummy.txt rename to tests/UnitTests/ConfigFileTests/file/templates_c/dummy.txt diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php index ceb633eb..18176705 100644 --- a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php @@ -37,7 +37,7 @@ class CompileConfigLoadTest extends PHPUnit_Smarty } /** - * @runInSeparateProcess + * @run InSeparateProcess * @preserveGlobalState disabled * * test {load_config} loading section2 @@ -46,6 +46,28 @@ class CompileConfigLoadTest extends PHPUnit_Smarty { $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('001_section2.tpl')); } + /** + * @run InSeparateProcess + * @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')); + } + + /** + * @run InSeparateProcess + * @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 @@ -64,10 +86,10 @@ class CompileConfigLoadTest extends PHPUnit_Smarty * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testConfigVariableAllSectionsTemplate() + public function testConfigVariableAllSectionsTemplate_004() { $this->smarty->setConfigOverwrite(true); - $this->assertEquals("Welcome to Smarty! Global Section1 Global Section2", $this->smarty->fetch('eval:{config_load file=\'test.conf\'}{#title#} {#sec1#} {#sec2#}')); + $this->assertEquals("Welcome to Smarty! Global Section1 Global Section2", $this->smarty->fetch('004_allsection.tpl')); } /** @@ -76,18 +98,18 @@ class CompileConfigLoadTest extends PHPUnit_Smarty * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testConfigVariableOverwrite() + public function testConfigVariableOverwrite_005() { - $this->assertEquals("Overwrite2", $this->smarty->fetch('eval:{config_load file=\'test.conf\'}{#overwrite#}')); + $this->assertEquals("Overwrite2", $this->smarty->fetch('005_overwrite.tpl')); } /** * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testConfigVariableOverwrite2() + public function testConfigVariableOverwrite_006() { - $this->assertEquals("Overwrite3", $this->smarty->fetch('eval:{config_load file=\'test.conf\'}{config_load file=\'test2.conf\'}{#overwrite#}')); + $this->assertEquals("Overwrite3", $this->smarty->fetch('006_overwrite.tpl')); } /** @@ -96,10 +118,10 @@ class CompileConfigLoadTest extends PHPUnit_Smarty * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testConfigVariableOverwriteFalse() + public function testConfigVariableOverwrite_007() { $this->smarty->setConfigOverwrite(false); - $this->assertEquals("Overwrite1Overwrite2Overwrite3Welcome to Smarty! Global Section1 Global Section2", $this->smarty->fetch('eval:{config_load file=\'test.conf\'}{config_load file=\'test2.conf\'}{foreach #overwrite# as $over}{$over}{/foreach}{#title#} {#sec1#} {#sec2#}')); + $this->assertEquals("Overwrite1 Overwrite2 Overwrite3 ", $this->smarty->fetch('007_overwrite.tpl')); } /** @@ -108,10 +130,11 @@ class CompileConfigLoadTest extends PHPUnit_Smarty * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testConfigVariableBooleanizeOn() + public function testConfigVariableBooleanizeOn_008() { $this->smarty->setConfigBooleanize(true); - $this->assertEquals("passed", $this->smarty->fetch('eval:{config_load file=\'test.conf\'}{if #booleanon# === true}passed{/if}')); + $this->smarty->assign('expected', true); + $this->assertEquals("passed", $this->smarty->fetch('008_booleanize.tpl')); } /** @@ -120,10 +143,11 @@ class CompileConfigLoadTest extends PHPUnit_Smarty * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testConfigVariableBooleanizeOff() + public function testConfigVariableBooleanizeOff_008() { $this->smarty->setConfigBooleanize(false); - $this->assertEquals("passed", $this->smarty->fetch('eval:{config_load file=\'test.conf\'}{if #booleanon# == \'on\'}passed{/if}')); + $this->smarty->assign('expected', 'on'); + $this->assertEquals("passed", $this->smarty->fetch('008_booleanize.tpl')); } /** @@ -131,8 +155,8 @@ class CompileConfigLoadTest extends PHPUnit_Smarty * @expectedExceptionMessage Syntax error in config file * test config file syntax error */ - public function testConfigSyntaxError() + public function testConfigSyntaxError_009() { - $this->smarty->fetch('eval:{config_load file=\'test_error.conf\'}'); + $this->smarty->fetch('009_error.tpl'); } } diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/cache/dummy.txt b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/cache/dummy.txt new file mode 100644 index 00000000..e69de29b 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/006_overwrite.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/006_overwrite.tpl new file mode 100644 index 00000000..106037dd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/006_overwrite.tpl @@ -0,0 +1 @@ +{config_load 'test.conf'}{config_load 'test2.conf'}{#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