summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Wisselink <s.wisselink@iwink.nl>2023-02-23 22:06:37 +0100
committerSimon Wisselink <s.wisselink@iwink.nl>2023-02-23 22:06:37 +0100
commit09d26579ceae6c5e2431a5aa2cee6fee6ab92aac (patch)
treed16a15be7a5570b4b1996bc79421e68e53a2dc8b /tests
parentbadcae6e0c6aa92f5ec4929446d97e06104f73d4 (diff)
downloadsmarty-09d26579ceae6c5e2431a5aa2cee6fee6ab92aac.tar.gz
smarty-09d26579ceae6c5e2431a5aa2cee6fee6ab92aac.tar.bz2
smarty-09d26579ceae6c5e2431a5aa2cee6fee6ab92aac.zip
Some additional unit tests
Diffstat (limited to 'tests')
-rw-r--r--tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php2
-rw-r--r--tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php4
-rw-r--r--tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/038_child.tpl2
-rw-r--r--tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/038_parent.tpl1
-rw-r--r--tests/UnitTests/TemplateSource/ValueTests/Operators/OperatorsTest.php23
5 files changed, 31 insertions, 1 deletions
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 @@
+<?php
+
+class OperatorsTest extends PHPUnit_Smarty {
+ public function setUp(): void
+ {
+ $this->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