summaryrefslogtreecommitdiff
path: root/ext/spl/tests/iterator_015.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/spl/tests/iterator_015.phpt
downloadphp2-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/iterator_015.phpt')
-rw-r--r--ext/spl/tests/iterator_015.phpt62
1 files changed, 62 insertions, 0 deletions
diff --git a/ext/spl/tests/iterator_015.phpt b/ext/spl/tests/iterator_015.phpt
new file mode 100644
index 0000000..aa30f79
--- /dev/null
+++ b/ext/spl/tests/iterator_015.phpt
@@ -0,0 +1,62 @@
+--TEST--
+SPL: RecursiveIteratorIterator and beginChildren/endChildren
+--FILE--
+<?php
+
+class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
+{
+ function rewind()
+ {
+ echo "<ul>\n";
+ parent::rewind();
+ }
+ function beginChildren()
+ {
+ echo str_repeat(' ',$this->getDepth())."<ul>\n";
+ }
+
+ function endChildren()
+ {
+ echo str_repeat(' ',$this->getDepth())."</ul>\n";
+ }
+ function valid()
+ {
+ if (!parent::valid()) {
+ echo "<ul>\n";
+ return false;
+ }
+ return true;
+ }
+}
+
+$arr = array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d");
+$obj = new RecursiveArrayIterator($arr);
+$rit = new RecursiveArrayIteratorIterator($obj);
+foreach($rit as $k=>$v)
+{
+ echo str_repeat(' ',$rit->getDepth()+1)."$k=>$v\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+<ul>
+ 0=>a
+ <ul>
+ 0=>ba
+ <ul>
+ 0=>bba
+ 1=>bbb
+ </ul>
+ <ul>
+ <ul>
+ 0=>bcaa
+ </ul>
+ </ul>
+ </ul>
+ <ul>
+ 0=>ca
+ </ul>
+ 3=>d
+<ul>
+===DONE===