Added unit test to confirm #605 was actually fixed

This commit is contained in:
Simon Wisselink
2021-01-08 11:57:32 +01:00
parent e71481a2ce
commit d01f9cd5e3

View File

@@ -76,16 +76,22 @@ class ConstantsTest extends PHPUnit_Smarty
$tpl->assign('obj', new TestConst()); $tpl->assign('obj', new TestConst());
$this->assertEquals("yes", $this->smarty->fetch($tpl)); $this->assertEquals("yes", $this->smarty->fetch($tpl));
} }
public function testConstantsUndefined() public function testConstantsUndefined()
{ {
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
$tpl = $this->smarty->createTemplate('string:{$smarty.const.MYCONSTANT2}'); $tpl = $this->smarty->createTemplate('string:{$smarty.const.MYCONSTANT2}');
$this->assertEquals("", $this->smarty->fetch($tpl)); $this->assertEquals("", $this->smarty->fetch($tpl));
} }
public function testConstantsUndefined2() public function testConstantsUndefined2()
{ {
$this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE);
$tpl = $this->smarty->createTemplate('eval:{$foo = MYCONSTANT2}{$foo}'); $tpl = $this->smarty->createTemplate('eval:{$foo = MYCONSTANT2}{$foo}');
$this->assertEquals("MYCONSTANT2", $this->smarty->fetch($tpl)); $this->assertEquals("MYCONSTANT2", $this->smarty->fetch($tpl));
} }
public function testConstantsUndefined3()
{
$tpl = $this->smarty->createTemplate('eval:{if $smarty.const.MYCONSTANT2}{$smarty.const.MYCONSTANT2}{/if}');
$this->assertEquals("", $this->smarty->fetch($tpl));
}
} }