mohrt Wed Sep 15 11:05:31 2004 EDT
Added files:
/smarty/unit_test/templates parse_math.tpl parse_obj_meth.tpl
Removed files:
/smarty/unit_test/templates assign_obj.tpl
Modified files:
/smarty/unit_test test_cases.php
Log:
add method test cases
http://cvs.php.net/diff.php/smarty/unit_test/test_cases.php?r1=1.10&r2=1.11&ty=u
Index: smarty/unit_test/test_cases.php
diff -u smarty/unit_test/test_cases.php:1.10
smarty/unit_test/test_cases.php:1.11
--- smarty/unit_test/test_cases.php:1.10 Tue Sep 14 03:22:51 2004
+++ smarty/unit_test/test_cases.php Wed Sep 15 11:05:30 2004
@@ -6,11 +6,16 @@
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 @@
$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 */
http://cvs.php.net/co.php/smarty/unit_test/templates/parse_math.tpl?r=1.1&p=1
Index: smarty/unit_test/templates/parse_math.tpl
+++ smarty/unit_test/templates/parse_math.tpl
{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}
http://cvs.php.net/co.php/smarty/unit_test/templates/parse_obj_meth.tpl?r=1.1&p=1
Index: smarty/unit_test/templates/parse_obj_meth.tpl
+++ smarty/unit_test/templates/parse_obj_meth.tpl
{$obj->meth($foo, 2.5)}
{$obj->meth(2.5, $foo)}
{$obj->meth(2.5)}
{$obj->meth($obj->val, "foo")}
{$obj->meth("foo", $obj->val)}
{$obj->meth("foo", $foo)}
{$obj->meth($obj->arr.one, 2)}
{$obj->meth($obj->meth("foo", $foo))}
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|