--- /dev/null
+--TEST--\r
+SPL: RecursiveIteratorIterator cannot be used with foreach by reference\r
+--FILE--\r
+<?php \r
+\r
+$arr = array(array(1,2));\r
+$arrOb = new ArrayObject($arr);\r
+\r
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());\r
+\r
+$recItIt = new RecursiveIteratorIterator($recArrIt);\r
+\r
+foreach ($recItIt as &$val) echo "$val\n";\r
+\r
+?>\r
+--EXPECTF--\r
+Fatal error: An iterator cannot be used with foreach by reference in %s on line %d\r
--- /dev/null
+--TEST--\r
+SPL: RecursiveIteratorIterator - Ensure that non-overriden methods execute problem free.\r
+--FILE--\r
+<?php\r
+\r
+$array = array();\r
+$recArrIt = new RecursiveArrayIterator($array);\r
+\r
+$recItIt = new RecursiveIteratorIterator($recArrIt);\r
+\r
+var_dump($recItIt->beginIteration());\r
+var_dump($recItIt->endIteration());\r
+var_dump($recItIt->nextElement());\r
+\r
+?>\r
+\r
+--EXPECTF--\r
+NULL\r
+NULL\r
+NULL
\ No newline at end of file
--- /dev/null
+--TEST--\r
+SPL: RecursiveIteratorIterator - Test where the case is RS_SELF and mode is CHILD_FIRST\r
+--FILE--\r
+<?php \r
+\r
+$arr = array(array(1,2),2);\r
+$arrOb = new ArrayObject($arr);\r
+\r
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());\r
+\r
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {\r
+ \r
+ function nextelement() {\r
+ echo __METHOD__."\n";\r
+ }\r
+}\r
+\r
+\r
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::CHILD_FIRST);\r
+\r
+foreach ($recItIt as $key => $val) echo "$key\n";\r
+\r
+?>\r
+--EXPECTF--\r
+MyRecursiveIteratorIterator::nextelement\r
+0\r
+MyRecursiveIteratorIterator::nextelement\r
+1\r
+MyRecursiveIteratorIterator::nextelement\r
+0\r
+MyRecursiveIteratorIterator::nextelement\r
+1
\ No newline at end of file
--- /dev/null
+--TEST--\r
+SPL: RecursiveIteratorIterator - Exception thrown in beginchildren which should be handled in next()\r
+--FILE--\r
+<?php \r
+\r
+$arr = array(array(1,2),2);\r
+$arrOb = new ArrayObject($arr);\r
+\r
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());\r
+\r
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {\r
+ \r
+ function beginchildren() {\r
+ throw new Exception;\r
+ }\r
+}\r
+\r
+\r
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);\r
+\r
+var_dump($recItIt->next());\r
+\r
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);\r
+\r
+var_dump($recItIt2->next());\r
+\r
+?>\r
+--EXPECTF--\r
+NULL\r
+\r
+Fatal error: Uncaught exception 'Exception' in %s\r
+Stack trace:\r
+#0 [internal function]: MyRecursiveIteratorIterator->beginchildren()\r
+#1 %s: RecursiveIteratorIterator->next()\r
+#2 {main}\r
+ thrown in %s on line %d\r
--- /dev/null
+--TEST--\r
+SPL: RecursiveIteratorIterator - Exception thrown in callHasChildren which should be handled in next()\r
+--FILE--\r
+<?php \r
+\r
+$arr = array(1,2);\r
+$arrOb = new ArrayObject($arr);\r
+\r
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());\r
+\r
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {\r
+ \r
+ function callHasChildren() {\r
+ throw new Exception;\r
+ }\r
+}\r
+\r
+\r
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);\r
+\r
+var_dump($recItIt->next());\r
+\r
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);\r
+\r
+var_dump($recItIt2->next());\r
+\r
+?>\r
+--EXPECTF--\r
+NULL\r
+\r
+Fatal error: Uncaught exception 'Exception' in %s\r
+Stack trace:\r
+#0 [internal function]: MyRecursiveIteratorIterator->callHasChildren()\r
+#1 %s: RecursiveIteratorIterator->next()\r
+#2 {main}\r
+ thrown in %s on line %d\r
--- /dev/null
+--TEST--\r
+SPL: RecursiveIteratorIterator - Exception thrown in endchildren which should be handled in next()\r
+--FILE--\r
+<?php \r
+\r
+$arr = array(array(1,2));\r
+$arrOb = new ArrayObject($arr);\r
+\r
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());\r
+\r
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {\r
+ \r
+ function endchildren() {\r
+ throw new Exception;\r
+ }\r
+}\r
+\r
+\r
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);\r
+\r
+foreach ($recItIt as $val) echo "$val\n";\r
+\r
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);\r
+\r
+echo "===NEXT LOOP===\n";\r
+\r
+foreach ($recItIt2 as $val) echo "$val\n";\r
+\r
+?>\r
+--EXPECTF--\r
+1\r
+2\r
+===NEXT LOOP===\r
+1\r
+2\r
+\r
+Fatal error: Uncaught exception 'Exception' in %s\r
+Stack trace:\r
+#0 [internal function]: MyRecursiveIteratorIterator->endchildren()\r
+#1 %s: RecursiveIteratorIterator->next()\r
+#2 {main}\r
+ thrown in %s on line %d\r
--- /dev/null
+--TEST--\r
+SPL: RecursiveIteratorIterator - Exception thrown in nextelement which should be handled in next()\r
+--FILE--\r
+<?php \r
+\r
+$arr = array(1,2);\r
+$arrOb = new ArrayObject($arr);\r
+\r
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());\r
+\r
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {\r
+ \r
+ function nextelement() {\r
+ throw new Exception;\r
+ }\r
+}\r
+\r
+\r
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);\r
+\r
+var_dump($recItIt->next());\r
+\r
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);\r
+\r
+var_dump($recItIt->next());\r
+\r
+?>\r
+--EXPECTF--\r
+NULL\r
+\r
+Fatal error: Uncaught exception 'Exception' in %s\r
+Stack trace:\r
+#0 [internal function]: MyRecursiveIteratorIterator->nextelement()\r
+#1 %s: RecursiveIteratorIterator->next()\r
+#2 {main}\r
+ thrown in %s on line %d\r