Some additional unit tests

This commit is contained in:
Simon Wisselink
2023-02-23 22:06:37 +01:00
parent badcae6e0c
commit 09d26579ce
5 changed files with 31 additions and 1 deletions

View File

@@ -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');

View File

@@ -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'));
}
}

View File

@@ -0,0 +1,2 @@
{extends file='038_parent.tpl'}
{block name=content assign=content}Content with lots of html here{/block}

View File

@@ -0,0 +1 @@
{block name=content}{/block}Captured content is: {$content}

View File

@@ -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'}"));
}
}