add method test cases

This commit is contained in:
mohrt
2004-09-15 15:05:31 +00:00
parent 1bb41c2a9b
commit 867c47e9ec
3 changed files with 45 additions and 5 deletions

View File

@@ -0,0 +1,12 @@
{foreach name=loop from=$items item=i}
{$smarty.foreach.loop.iteration+2}
{$smarty.foreach.loop.iteration+$flt}
{$smarty.foreach.loop.iteration+$obj->six()}
{$smarty.foreach.loop.iteration+$obj->ten}
{/foreach}
{$obj->ten+$flt}
{$obj->ten*$flt}
{$obj->six()+$obj->ten}
{$obj->ten+$obj->ten}
{$obj->six()+$flt}
{$obj->six()+$items.0}

View File

@@ -6,11 +6,16 @@ require_once 'PHPUnit.php';
class Obj {
var $val = 'val';
var $arr = array('one' => 'one');
var $arr = array('one' => 'one', 'two' => 2);
var $ten = 10;
function meth($a="a", $b="b") {
return "$a:$b";
}
function six() {
return 6;
}
}
@@ -255,20 +260,43 @@ class SmartyTest extends PHPUnit_TestCase {
$this->assertEquals($this->smarty->fetch('assign_var.tpl'), 'bar');
}
/* PARSING TESTS */
// test assigning and calling an object
function test_obj_meth() {
function test_parse_obj_meth() {
$obj = new Obj();
$this->smarty->assign('obj', $obj);
$this->smarty->assign('foo', 'foo');
$this->assertEquals(
'foo:2.5
$this->assertEquals('foo:2.5
2.5:foo
2.5:b
val:foo
foo:val
foo:foo
one:2
foo:foo:b', $this->smarty->fetch('assign_obj.tpl'));
foo:foo:b', $this->smarty->fetch('parse_obj_meth.tpl'));
}
// test assigning and calling an object
function test_parse_math() {
$obj = new Obj();
$this->smarty->assign('obj', $obj);
$this->smarty->assign('flt', 2.5);
$this->smarty->assign('items', array(1, 2));
$this->assertEquals('3
3.5
7
11
4
4.5
8
12
12.5
25
16
20
8.5
7', $this->smarty->fetch('parse_math.tpl'));
}
/* CONFIG FILE TESTS */