Annotation of embedaddon/php/ext/spl/tests/arrayObject_count_basic1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: ArrayObject::count() and ArrayIterator::count() basic functionality.
3: --FILE--
4: ==ArrayObject==
5: <?php
6: class C extends ArrayObject {
7: function count() {
8: return 99;
9: }
10: }
11:
12: $c = new C;
13: $ao = new ArrayObject;
14:
15: var_dump(count($c), count($ao));
16:
17: $c[] = 'a';
18: $ao[] = 'a';
19: var_dump(count($c), count($ao));
20:
21: $c[] = 'b';
22: $ao[] = 'b';
23: var_dump(count($c), count($ao));
24:
25: unset($c[0]);
26: unset($ao[0]);
27: var_dump($c->count(), $ao->count());
28:
29: //Extra args are ignored.
30: var_dump($ao->count('blah'));
31: ?>
32: ==ArrayIterator==
33: <?php
34: class D extends ArrayIterator {
35: function count() {
36: return 99;
37: }
38: }
39:
40: $c = new D;
41: $ao = new ArrayIterator;
42:
43: var_dump(count($c), count($ao));
44:
45: $c[] = 'a';
46: $ao[] = 'a';
47: var_dump(count($c), count($ao));
48:
49: $c[] = 'b';
50: $ao[] = 'b';
51: var_dump(count($c), count($ao));
52:
53: unset($c[0]);
54: unset($ao[0]);
55: var_dump($c->count(), $ao->count());
56:
57: //Extra args are ignored.
58: var_dump($ao->count('blah'));
59: ?>
60: --EXPECTF--
61: ==ArrayObject==
62: int(99)
63: int(0)
64: int(99)
65: int(1)
66: int(99)
67: int(2)
68: int(99)
69: int(1)
70:
71: Warning: ArrayObject::count() expects exactly 0 parameters, 1 given in %s on line %d
72: NULL
73: ==ArrayIterator==
74: int(99)
75: int(0)
76: int(99)
77: int(1)
78: int(99)
79: int(2)
80: int(99)
81: int(1)
82:
83: Warning: ArrayIterator::count() expects exactly 0 parameters, 1 given in %s on line %d
84: NULL
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>