From 09d26579ceae6c5e2431a5aa2cee6fee6ab92aac Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Thu, 23 Feb 2023 22:06:37 +0100 Subject: [PATCH] Some additional unit tests --- .../File/CacheResourceFileTest.php | 2 +- .../BockExtend/CompileBlockExtendsTest.php | 4 ++++ .../BockExtend/templates/038_child.tpl | 2 ++ .../BockExtend/templates/038_parent.tpl | 1 + .../ValueTests/Operators/OperatorsTest.php | 23 +++++++++++++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/038_child.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/038_parent.tpl create mode 100644 tests/UnitTests/TemplateSource/ValueTests/Operators/OperatorsTest.php diff --git a/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php b/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php index 56a1a49c..0205edbb 100644 --- a/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php +++ b/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php @@ -107,7 +107,7 @@ class CacheResourceFileTest extends CacheResourceTestCommon $this->smarty->caching = true; $this->smarty->cache_lifetime = 1000; $this->cleanCacheDir(); - $this->smarty->setUseSubDirs(false); + $this->smarty->setUseSubDirs(true); $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); $this->writeCachedContent($tpl); $tpl2 = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar2', 'blar'); diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php index 99711a77..b14eab67 100644 --- a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php @@ -1371,4 +1371,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty ); } + public function testBlockWithAssign() { + $this->assertEquals('Captured content is: Content with lots of html here', $this->smarty->fetch('038_child.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/038_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/038_child.tpl new file mode 100644 index 00000000..86132ef2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/038_child.tpl @@ -0,0 +1,2 @@ +{extends file='038_parent.tpl'} +{block name=content assign=content}Content with lots of html here{/block} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/038_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/038_parent.tpl new file mode 100644 index 00000000..f00073af --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/038_parent.tpl @@ -0,0 +1 @@ +{block name=content}{/block}Captured content is: {$content} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/Operators/OperatorsTest.php b/tests/UnitTests/TemplateSource/ValueTests/Operators/OperatorsTest.php new file mode 100644 index 00000000..ea88e4bd --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Operators/OperatorsTest.php @@ -0,0 +1,23 @@ +setUpSmarty(__DIR__); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * @group issue861 + */ + public function testTernaries() { + $this->assertEquals('2 equals 2', $this->smarty->fetch("string:{(2 === 2) ? '2 equals 2' : '2 ain\'t 2'}")); + $this->assertEquals('3 equals 3', $this->smarty->fetch("string:{(3 == 3) ? '3 equals 3' : '3 ain\'t 3'}")); + $this->assertEquals('4 equals 4', $this->smarty->fetch("string:{(4 !== 4) ? '4 ain\'t 4' : '4 equals 4'}")); + } + +} \ No newline at end of file