Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 8c6955e

Browse files
committed
Added unit test for issue 28 and 29
1 parent 455f520 commit 8c6955e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

UnitTests/ConfigFileTests/ConfigVarTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,4 +376,19 @@ public function testConfigResourceDb4()
376376
$this->smarty->configLoad('db4:foo.conf');
377377
$this->assertEquals("bar", $this->smarty->fetch('eval:{#foo#}'));
378378
}
379+
public function testConfigUndefinedSilent()
380+
{
381+
$this->assertEquals("", $this->smarty->fetch('eval:{#foo#}'));
382+
}
383+
384+
public function testConfigUndefinedNotice()
385+
{
386+
$this->smarty->error_unassigned = true;
387+
try {
388+
$this->assertEquals("", $this->smarty->fetch('eval:{#foo#}'));
389+
}
390+
catch (Exception $e) {
391+
$this->assertEquals('Undefined variable: foo', $e->getMessage());
392+
}
393+
}
379394
}

UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,14 @@ public function testConstants7()
7474
$tpl->assign('obj', new TestConst());
7575
$this->assertEquals("yes", $this->smarty->fetch($tpl));
7676
}
77+
public function testConstantsUndefined()
78+
{
79+
$tpl = $this->smarty->createTemplate('string:{$smarty.const.MYCONSTANT2}');
80+
$this->assertEquals("", $this->smarty->fetch($tpl));
81+
}
82+
public function testConstantsUndefined2()
83+
{
84+
$tpl = $this->smarty->createTemplate('eval:{$foo = MYCONSTANT2}{$foo}');
85+
$this->assertEquals("MYCONSTANT2", $this->smarty->fetch($tpl));
86+
}
7787
}

0 commit comments

Comments
 (0)