diff options
author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:39:08 -0400 |
---|---|---|
committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:39:08 -0400 |
commit | 993e1866df547532a05ab6db76c9ff5aefc9a3df (patch) | |
tree | 169d3bde0974235d3cde164786ef6f381a4749a7 /ext/standard/tests/array/sizeof_object1.phpt | |
parent | 1f589a2bd44ba835ad1b009a5d83abd453724829 (diff) | |
download | php-993e1866df547532a05ab6db76c9ff5aefc9a3df.tar.gz |
Imported Upstream version 5.2.6upstream/5.2.6
Diffstat (limited to 'ext/standard/tests/array/sizeof_object1.phpt')
-rw-r--r-- | ext/standard/tests/array/sizeof_object1.phpt | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/ext/standard/tests/array/sizeof_object1.phpt b/ext/standard/tests/array/sizeof_object1.phpt new file mode 100644 index 000000000..470599605 --- /dev/null +++ b/ext/standard/tests/array/sizeof_object1.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test sizeof() function : object functionality - object with Countable interface +--SKIPIF-- +<?php +// Skip the test case if Standard PHP Library(spl) is not installed + if( !extension_loaded('spl')) + { + die('skip spl is not installed'); + } +?> +--FILE-- +<?php +/* Prototype : int sizeof($mixed var[, int $mode]) + * Description: Counts an elements in an array. If Standard PHP library is installed, + * it will return the properties of an object. + * Source code: ext/standard/basic_functions.c + * Alias to functions: count() + */ + +echo "*** Testing sizeof() : object functionality ***\n"; + +echo "-- Testing sizeof() with an object which implements Countable interface --\n"; +class sizeof_class implements Countable +{ + public $member1; + private $member2; + protected $member3; + + public function count() + { + return 3; // return the count of member variables in the object + } +} + +$obj = new sizeof_class(); + +echo "-- Testing sizeof() in default mode --\n"; +var_dump( sizeof($obj) ); +echo "-- Testing sizeof() in COUNT_NORMAL mode --\n"; +var_dump( sizeof($obj, COUNT_NORMAL) ); +echo "-- Testing sizeof() in COUNT_RECURSIVE mode --\n"; +var_dump( sizeof($obj, COUNT_RECURSIVE) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing sizeof() : object functionality *** +-- Testing sizeof() with an object which implements Countable interface -- +-- Testing sizeof() in default mode -- +int(3) +-- Testing sizeof() in COUNT_NORMAL mode -- +int(3) +-- Testing sizeof() in COUNT_RECURSIVE mode -- +int(3) +Done |