diff --git a/tests/Include_Path/Tpl/include/include_test2.tpl b/tests/Include_Path/Tpl/include/include_test2.tpl new file mode 100644 index 00000000..bf555e12 --- /dev/null +++ b/tests/Include_Path/Tpl/include/include_test2.tpl @@ -0,0 +1 @@ +include_test2 diff --git a/tests/Include_Path/Tpl/include/include_test4.tpl b/tests/Include_Path/Tpl/include/include_test4.tpl new file mode 100644 index 00000000..191aaa1b --- /dev/null +++ b/tests/Include_Path/Tpl/include/include_test4.tpl @@ -0,0 +1 @@ +include_test4 diff --git a/tests/Include_Path/Tpl/templates_2/test4.tpl b/tests/Include_Path/Tpl/templates_2/test4.tpl new file mode 100644 index 00000000..047efaee --- /dev/null +++ b/tests/Include_Path/Tpl/templates_2/test4.tpl @@ -0,0 +1 @@ +{include 'include_test4.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php b/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php new file mode 100644 index 00000000..34f1a78b --- /dev/null +++ b/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php @@ -0,0 +1,64 @@ +setUpSmarty(__DIR__); + $this->smarty->use_include_path = true; + $this->smarty->setTemplateDir(array('./templates', './templates_2', './include')); + $this->smarty->enableSecurity(); + $ds = DS; + set_include_path($this->smarty->_realpath(__DIR__ . "{$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() + { + 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->assertContains('include_test4', $this->smarty->fetch('test5.tpl')); + } + + } 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/FileIndexed/FileResourceIndexedTest.php b/tests/UnitTests/ResourceTests/FileIndexed/FileResourceIndexedTest.php index 18067bcb..74ed9782 100644 --- a/tests/UnitTests/ResourceTests/FileIndexed/FileResourceIndexedTest.php +++ b/tests/UnitTests/ResourceTests/FileIndexed/FileResourceIndexedTest.php @@ -64,12 +64,37 @@ class FileResourceIndexedTest extends PHPUnit_Smarty $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() { 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/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_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