diff --git a/tests/UnitTests/TemplateSource/TagTests/_Print/PrintNocacheTest.php b/tests/UnitTests/TemplateSource/TagTests/_Print/PrintNocacheTest.php deleted file mode 100644 index 95bf5bee..00000000 --- a/tests/UnitTests/TemplateSource/TagTests/_Print/PrintNocacheTest.php +++ /dev/null @@ -1,69 +0,0 @@ -setUpSmarty(dirname(__FILE__)); - } - - - public function testInit() - { - $this->cleanDirs(); - } - /** - * test print nocache caching disabled - */ - public function testPrintNocacheCachingNo1() - { - $this->smarty->caching = 0; - $this->smarty->assign('foo', 0); - $this->smarty->assign('bar', 'A'); - $this->assertEquals("0A", $this->smarty->fetch('test_print_nocache.tpl')); - } - - public function testPrintNocacheCachingNo2() - { - $this->smarty->caching = 0; - $this->smarty->assign('foo', 2); - $this->smarty->assign('bar', 'B'); - $this->assertEquals("2B", $this->smarty->fetch('test_print_nocache.tpl')); - } - - /** - * test print nocache caching enabled - */ - public function testPrintNocacheCachingYes1() - { - $this->smarty->caching = 1; - $this->smarty->assign('foo', 0); - $this->smarty->assign('bar', 'A'); - $this->assertEquals("0A", $this->smarty->fetch('test_print_nocache.tpl')); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testPrintNocacheCachingYes2() - { - $this->smarty->caching = 1; - $this->smarty->assign('foo', 2); - $this->smarty->assign('bar', 'B'); - $this->assertEquals("2A", $this->smarty->fetch('test_print_nocache.tpl')); - } -} 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/templates/test_print_nocache.tpl b/tests/UnitTests/TemplateSource/TagTests/_Print/templates/test_print_nocache.tpl deleted file mode 100644 index 344da984..00000000 --- a/tests/UnitTests/TemplateSource/TagTests/_Print/templates/test_print_nocache.tpl +++ /dev/null @@ -1 +0,0 @@ -{$foo nocache=true}{$bar} \ No newline at end of file