--- /dev/null
+--TEST--\r
+SPL: FilterIterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+class myFilterIterator extends FilterIterator {\r
+ function accept() {\r
+ \r
+ }\r
+}\r
+try {\r
+ $it = new myFilterIterator(); \r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+?>\r
+--EXPECT--\r
+InvalidArgumentException thrown\r
--- /dev/null
+--TEST--\r
+SPL: ArrayIterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+/**\r
+ * From Docs: Construct a new array iterator from anything that has a hash table. \r
+ * NULL, NOTHING is not a hash table ;) \r
+ */\r
+class myArrayIterator extends ArrayIterator {\r
+}\r
+try {\r
+ $it = new myArrayIterator();\r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+echo 'no Exception thrown'\r
+?>\r
+--EXPECT--\r
+no Exception thrown\r
--- /dev/null
+--TEST--\r
+SPL: Iterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+class myIterator implements Iterator {\r
+ \r
+ function current() {}\r
+ function next() {}\r
+ function key() {} \r
+ function valid() {}\r
+ function rewind() {}\r
+ \r
+}\r
+try {\r
+ $it = new myIterator(); \r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+echo 'no Exception thrown';\r
+?>\r
+--EXPECT--\r
+no Exception thrown\r
--- /dev/null
+--TEST--\r
+SPL: CachingIterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+class myCachingIterator extends CachingIterator {\r
+ \r
+}\r
+try {\r
+ $it = new myCachingIterator(); \r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+?>\r
+--EXPECT--\r
+InvalidArgumentException thrown\r
--- /dev/null
+--TEST--\r
+SPL: RecursiveCachingIterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+class myRecursiveCachingIterator extends RecursiveCachingIterator {\r
+ \r
+}\r
+try {\r
+ $it = new myRecursiveCachingIterator(); \r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+?>\r
+--EXPECT--\r
+InvalidArgumentException thrown\r
--- /dev/null
+--TEST--\r
+SPL: ParentIterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+class myParentIterator extends ParentIterator {\r
+ \r
+}\r
+try {\r
+ $it = new myParentIterator(); \r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+?>\r
+--EXPECT--\r
+InvalidArgumentException thrown\r
--- /dev/null
+--TEST--\r
+SPL: RecursiveIteratorIterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+class myRecursiveIteratorIterator extends RecursiveIteratorIterator {\r
+ \r
+}\r
+\r
+try {\r
+ $it = new myRecursiveIteratorIterator();\r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+?>\r
+--EXPECT--\r
+InvalidArgumentException thrown
\ No newline at end of file
--- /dev/null
+--TEST--\r
+SPL: LimitIterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+class myLimitIterator extends LimitIterator {\r
+ \r
+}\r
+try {\r
+ $it = new myLimitIterator();\r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+?>\r
+--EXPECT--\r
+InvalidArgumentException thrown
\ No newline at end of file
--- /dev/null
+--TEST--\r
+SPL: CachingIterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+class myCachingIterator extends CachingIterator {}\r
+try {\r
+ $it = new myCachingIterator();\r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+?>\r
+--EXPECT--\r
+InvalidArgumentException thrown\r
--- /dev/null
+--TEST--\r
+SPL: RecursiveCachingIterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+class myRecursiveCachingIterator extends RecursiveCachingIterator {}\r
+try {\r
+ $it = new myRecursiveCachingIterator();\r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+?>\r
+--EXPECT--\r
+InvalidArgumentException thrown\r
--- /dev/null
+--TEST--\r
+SPL: NoRewindIterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+class myNoRewindIterator extends NoRewindIterator {}\r
+try {\r
+ $it = new myNoRewindIterator();\r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+?>\r
+--EXPECT--\r
+InvalidArgumentException thrown\r
--- /dev/null
+--TEST--\r
+SPL: AppendIterator::__construct(void)\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\r
+--CREDITS--\r
+Sebastian Schürmann\r
+--FILE--\r
+<?php\r
+class myAppendIterator extends AppendIterator {}\r
+try {\r
+ $it = new myAppendIterator();\r
+ echo "no exception";\r
+} catch (InvalidArgumentException $e) {\r
+ echo 'InvalidArgumentException thrown';\r
+}\r
+?>\r
+--EXPECT--\r
+no exception\r
--- /dev/null
+--TEST--\r
+SPL: RecursiveIteratorIterator cannot be used with foreach by reference\r
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\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
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\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
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\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
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\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
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\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
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\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
+--SKIPIF--\r
+<?php if (!extension_loaded("spl")) print "skip"; ?>\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