Annotation of embedaddon/php/ext/simplexml/tests/sxe_004.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: SimpleXMLIterator and overridden iterator methods()
3: --SKIPIF--
4: <?php
5: if (!extension_loaded('simplexml')) print 'skip';
6: if (!extension_loaded("libxml")) print "skip LibXML not present";
7: ?>
8: --FILE--
9: <?php
10:
11: $xml =<<<EOF
12: <?xml version='1.0'?>
13: <!DOCTYPE sxe SYSTEM "notfound.dtd">
14: <sxe id="elem1">
15: Plain text.
16: <elem1 attr1='first'>
17: Bla bla 1.
18: <!-- comment -->
19: <elem2>
20: Here we have some text data.
21: <elem3>
22: And here some more.
23: <elem4>
24: Wow once again.
25: </elem4>
26: </elem3>
27: </elem2>
28: </elem1>
29: <elem11 attr2='second'>
30: Bla bla 2.
31: <elem111>
32: Foo Bar
33: </elem111>
34: </elem11>
35: </sxe>
36: EOF;
37:
38: class SXETest extends SimpleXMLIterator
39: {
40: function rewind()
41: {
42: echo __METHOD__ . "\n";
43: return parent::rewind();
44: }
45: function valid()
46: {
47: echo __METHOD__ . "\n";
48: return parent::valid();
49: }
50: function current()
51: {
52: echo __METHOD__ . "\n";
53: return parent::current();
54: }
55: function key()
56: {
57: echo __METHOD__ . "\n";
58: return parent::key();
59: }
60: function next()
61: {
62: echo __METHOD__ . "\n";
63: return parent::next();
64: }
65: function hasChildren()
66: {
67: echo __METHOD__ . "\n";
68: return parent::hasChildren();
69: }
70: function getChildren()
71: {
72: echo __METHOD__ . "\n";
73: return parent::getChildren();
74: }
75: }
76:
77: $sxe = new SXETest((binary)$xml);
78: $rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::SELF_FIRST);
79:
80: foreach($rit as $data) {
81: var_dump(get_class($data));
82: var_dump(trim($data));
83: }
84:
85: ?>
86: ===DONE===
87: --EXPECTF--
88: SXETest::rewind
89: SXETest::valid
90: SXETest::hasChildren
91: SXETest::valid
92: SXETest::current
93: string(7) "SXETest"
94: string(10) "Bla bla 1."
95: SXETest::getChildren
96: SXETest::rewind
97: SXETest::valid
98: SXETest::hasChildren
99: SXETest::valid
100: SXETest::current
101: string(7) "SXETest"
102: string(28) "Here we have some text data."
103: SXETest::getChildren
104: SXETest::rewind
105: SXETest::valid
106: SXETest::hasChildren
107: SXETest::valid
108: SXETest::current
109: string(7) "SXETest"
110: string(19) "And here some more."
111: SXETest::getChildren
112: SXETest::rewind
113: SXETest::valid
114: SXETest::hasChildren
115: SXETest::valid
116: SXETest::current
117: string(7) "SXETest"
118: string(15) "Wow once again."
119: SXETest::next
120: SXETest::valid
121: SXETest::next
122: SXETest::valid
123: SXETest::next
124: SXETest::valid
125: SXETest::next
126: SXETest::valid
127: SXETest::hasChildren
128: SXETest::valid
129: SXETest::current
130: string(7) "SXETest"
131: string(10) "Bla bla 2."
132: SXETest::getChildren
133: SXETest::rewind
134: SXETest::valid
135: SXETest::hasChildren
136: SXETest::valid
137: SXETest::current
138: string(7) "SXETest"
139: string(7) "Foo Bar"
140: SXETest::next
141: SXETest::valid
142: SXETest::next
143: SXETest::valid
144: SXETest::valid
145: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>