Added unit test for issue 28 and 29

This commit is contained in:
Uwe Tews
2015-05-12 20:44:52 +02:00
parent 4a09745c41
commit 5bef25a262
2 changed files with 25 additions and 0 deletions

View File

@@ -376,4 +376,19 @@ class ConfigVarTest extends PHPUnit_Smarty
$this->smarty->configLoad('db4:foo.conf'); $this->smarty->configLoad('db4:foo.conf');
$this->assertEquals("bar", $this->smarty->fetch('eval:{#foo#}')); $this->assertEquals("bar", $this->smarty->fetch('eval:{#foo#}'));
} }
public function testConfigUndefinedSilent()
{
$this->assertEquals("", $this->smarty->fetch('eval:{#foo#}'));
}
public function testConfigUndefinedNotice()
{
$this->smarty->error_unassigned = true;
try {
$this->assertEquals("", $this->smarty->fetch('eval:{#foo#}'));
}
catch (Exception $e) {
$this->assertEquals('Undefined variable: foo', $e->getMessage());
}
}
} }

View File

@@ -74,4 +74,14 @@ 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()
{
$tpl = $this->smarty->createTemplate('string:{$smarty.const.MYCONSTANT2}');
$this->assertEquals("", $this->smarty->fetch($tpl));
}
public function testConstantsUndefined2()
{
$tpl = $this->smarty->createTemplate('eval:{$foo = MYCONSTANT2}{$foo}');
$this->assertEquals("MYCONSTANT2", $this->smarty->fetch($tpl));
}
} }