From 9ef9398d5924d5f3158aec1be4007147202d9761 Mon Sep 17 00:00:00 2001 From: AnrDaemon Date: Mon, 22 Mar 2021 21:55:54 +0300 Subject: [PATCH] Added regression test for smarty-php/smarty#639 Modified include inline unit test to catch evaluation error. --- .../TagTests/Include/CompileIncludeTest.php | 2 +- .../templates/inline_string_include.tpl | 2 +- .../639/IncludeBlockToInlineIssue639Test.php | 38 +++++++++++++++++++ .../_Issues/639/cache/.gitignore | 2 + .../639/templates/001_inline_first.tpl | 2 + .../_Issues/639/templates/002_inline_last.tpl | 2 + .../_Issues/639/templates_c/.gitignore | 2 + 7 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 tests/UnitTests/TemplateSource/_Issues/639/IncludeBlockToInlineIssue639Test.php create mode 100644 tests/UnitTests/TemplateSource/_Issues/639/cache/.gitignore create mode 100644 tests/UnitTests/TemplateSource/_Issues/639/templates/001_inline_first.tpl create mode 100644 tests/UnitTests/TemplateSource/_Issues/639/templates/002_inline_last.tpl create mode 100644 tests/UnitTests/TemplateSource/_Issues/639/templates_c/.gitignore diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php index c07f11007..648920fe5 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php @@ -330,6 +330,6 @@ public function dataTestSpacing() */ public function testInlineStringInclude() { - $this->assertEquals('include-inline', $this->smarty->fetch('inline_string_include.tpl')); + $this->assertEquals("include-inline\n", $this->smarty->fetch('inline_string_include.tpl')); } } diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/inline_string_include.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/inline_string_include.tpl index 44d7eb3a6..efcd791af 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Include/templates/inline_string_include.tpl +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/inline_string_include.tpl @@ -1 +1 @@ -{include "string:include-inline" inline} \ No newline at end of file +{include "string:include-inline\n" inline} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/639/IncludeBlockToInlineIssue639Test.php b/tests/UnitTests/TemplateSource/_Issues/639/IncludeBlockToInlineIssue639Test.php new file mode 100644 index 000000000..12d7830c8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/639/IncludeBlockToInlineIssue639Test.php @@ -0,0 +1,38 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testInlineFirst() + { + $this->assertEquals("include-inline\ninclude-regular\n", $this->smarty->fetch('001_inline_first.tpl')); + } + public function testInlineLast() + { + $this->assertEquals("include-regular\ninclude-inline\n", $this->smarty->fetch('002_inline_last.tpl')); + } +} diff --git a/tests/UnitTests/TemplateSource/_Issues/639/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/639/cache/.gitignore new file mode 100644 index 000000000..d88cc1446 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/639/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/639/templates/001_inline_first.tpl b/tests/UnitTests/TemplateSource/_Issues/639/templates/001_inline_first.tpl new file mode 100644 index 000000000..ee8163eb1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/639/templates/001_inline_first.tpl @@ -0,0 +1,2 @@ +{include "string:include-inline\n" inline} +{include "string:include-regular\n"} diff --git a/tests/UnitTests/TemplateSource/_Issues/639/templates/002_inline_last.tpl b/tests/UnitTests/TemplateSource/_Issues/639/templates/002_inline_last.tpl new file mode 100644 index 000000000..208ee0f19 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/639/templates/002_inline_last.tpl @@ -0,0 +1,2 @@ +{include "string:include-regular\n"} +{include "string:include-inline\n" inline} diff --git a/tests/UnitTests/TemplateSource/_Issues/639/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/639/templates_c/.gitignore new file mode 100644 index 000000000..d88cc1446 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/639/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +*