From a1b4c9c551d01ff63220f053966c7aaa9053f89d Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Sun, 6 Oct 2024 22:01:17 +0200 Subject: [PATCH] Add unit tests for short hand template function definition and shorthand template function calls. --- .../TemplateFunction/CompileFunctionTest.php | 24 +++++++++++++++++++ .../TemplateFunction/templates/shorthand1.tpl | 2 ++ .../TemplateFunction/templates/shorthand2.tpl | 2 ++ .../TemplateFunction/templates/shorthand3.tpl | 2 ++ 4 files changed, 30 insertions(+) create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand1.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand2.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand3.tpl diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php index 863ca6c41..16892ed04 100644 --- a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php @@ -442,4 +442,28 @@ public function testIllegalFunctionName() { $this->smarty->fetch('string:{function name=\'rce(){};echo "hi";function \'}{/function}'); } + /** + * test shorthand function definition with regular call + */ + public function testShorthand1() + { + $this->assertEquals("gribus", $this->smarty->fetch('shorthand1.tpl')); + } + + /** + * test normal function definition with shorthand call + */ + public function testShorthand2() + { + $this->assertEquals("gribus", $this->smarty->fetch('shorthand2.tpl')); + } + + /** + * test shorthand function definition with shorthand call + */ + public function testShorthand3() + { + $this->assertEquals("gribus", $this->smarty->fetch('shorthand3.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand1.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand1.tpl new file mode 100644 index 000000000..1ca50d703 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand1.tpl @@ -0,0 +1,2 @@ +{function blah}gribus{/function} +{call name=blah} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand2.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand2.tpl new file mode 100644 index 000000000..2901a3d50 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand2.tpl @@ -0,0 +1,2 @@ +{function name=blah}gribus{/function} +{blah} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand3.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand3.tpl new file mode 100644 index 000000000..61be22559 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/shorthand3.tpl @@ -0,0 +1,2 @@ +{function blah}gribus{/function} +{blah} \ No newline at end of file