diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/spl/tests/arrayObject_count_basic1.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/spl/tests/arrayObject_count_basic1.phpt')
-rw-r--r-- | ext/spl/tests/arrayObject_count_basic1.phpt | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/ext/spl/tests/arrayObject_count_basic1.phpt b/ext/spl/tests/arrayObject_count_basic1.phpt new file mode 100644 index 0000000..a003c2c --- /dev/null +++ b/ext/spl/tests/arrayObject_count_basic1.phpt @@ -0,0 +1,84 @@ +--TEST-- +SPL: ArrayObject::count() and ArrayIterator::count() basic functionality. +--FILE-- +==ArrayObject== +<?php +class C extends ArrayObject { + function count() { + return 99; + } +} + +$c = new C; +$ao = new ArrayObject; + +var_dump(count($c), count($ao)); + +$c[] = 'a'; +$ao[] = 'a'; +var_dump(count($c), count($ao)); + +$c[] = 'b'; +$ao[] = 'b'; +var_dump(count($c), count($ao)); + +unset($c[0]); +unset($ao[0]); +var_dump($c->count(), $ao->count()); + +//Extra args are ignored. +var_dump($ao->count('blah')); +?> +==ArrayIterator== +<?php +class D extends ArrayIterator { + function count() { + return 99; + } +} + +$c = new D; +$ao = new ArrayIterator; + +var_dump(count($c), count($ao)); + +$c[] = 'a'; +$ao[] = 'a'; +var_dump(count($c), count($ao)); + +$c[] = 'b'; +$ao[] = 'b'; +var_dump(count($c), count($ao)); + +unset($c[0]); +unset($ao[0]); +var_dump($c->count(), $ao->count()); + +//Extra args are ignored. +var_dump($ao->count('blah')); +?> +--EXPECTF-- +==ArrayObject== +int(99) +int(0) +int(99) +int(1) +int(99) +int(2) +int(99) +int(1) + +Warning: ArrayObject::count() expects exactly 0 parameters, 1 given in %s on line %d +NULL +==ArrayIterator== +int(99) +int(0) +int(99) +int(1) +int(99) +int(2) +int(99) +int(1) + +Warning: ArrayIterator::count() expects exactly 0 parameters, 1 given in %s on line %d +NULL
\ No newline at end of file |