wimartin Tue, 08 Dec 2009 19:51:56 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=291895
Log:
Backported 5.3 tests to 5.2 and added more RecursiveIteratorIterator tests
Changed paths:
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_056.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_057.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_058.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_059.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_060.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_061.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_062.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_063.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_064.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_065.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_066.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_067.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_069.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_070.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_071.phpt
A
php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt
A
php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt
A
php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt
A
php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt
A php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_069.phpt
A php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_070.phpt
A php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_071.phpt
A
php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt
A
php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt
A
php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt
A
php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt
A php/php-src/trunk/ext/spl/tests/iterator_069.phpt
A php/php-src/trunk/ext/spl/tests/iterator_070.phpt
A php/php-src/trunk/ext/spl/tests/iterator_071.phpt
A
php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt
A
php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt
A
php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt
A
php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_056.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_056.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_056.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,21 @@
+--TEST--
+SPL: FilterIterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myFilterIterator extends FilterIterator {
+ function accept() {
+
+ }
+}
+try {
+ $it = new myFilterIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_057.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_057.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_057.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,23 @@
+--TEST--
+SPL: ArrayIterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+/**
+ * From Docs: Construct a new array iterator from anything that has a hash table.
+ * NULL, NOTHING is not a hash table ;)
+ */
+class myArrayIterator extends ArrayIterator {
+}
+try {
+ $it = new myArrayIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+echo 'no Exception thrown'
+?>
+--EXPECT--
+no Exception thrown
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_058.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_058.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_058.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,26 @@
+--TEST--
+SPL: Iterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myIterator implements Iterator {
+
+ function current() {}
+ function next() {}
+ function key() {}
+ function valid() {}
+ function rewind() {}
+
+}
+try {
+ $it = new myIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+echo 'no Exception thrown';
+?>
+--EXPECT--
+no Exception thrown
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_059.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_059.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_059.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,19 @@
+--TEST--
+SPL: CachingIterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myCachingIterator extends CachingIterator {
+
+}
+try {
+ $it = new myCachingIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_060.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_060.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_060.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,19 @@
+--TEST--
+SPL: RecursiveCachingIterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myRecursiveCachingIterator extends RecursiveCachingIterator {
+
+}
+try {
+ $it = new myRecursiveCachingIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_061.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_061.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_061.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,19 @@
+--TEST--
+SPL: ParentIterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myParentIterator extends ParentIterator {
+
+}
+try {
+ $it = new myParentIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_062.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_062.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_062.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,20 @@
+--TEST--
+SPL: RecursiveIteratorIterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+}
+
+try {
+ $it = new myRecursiveIteratorIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
\ No newline at end of file
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_063.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_063.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_063.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,19 @@
+--TEST--
+SPL: LimitIterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myLimitIterator extends LimitIterator {
+
+}
+try {
+ $it = new myLimitIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
\ No newline at end of file
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_064.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_064.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_064.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,17 @@
+--TEST--
+SPL: CachingIterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myCachingIterator extends CachingIterator {}
+try {
+ $it = new myCachingIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_065.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_065.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_065.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,17 @@
+--TEST--
+SPL: RecursiveCachingIterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myRecursiveCachingIterator extends RecursiveCachingIterator {}
+try {
+ $it = new myRecursiveCachingIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_066.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_066.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_066.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,17 @@
+--TEST--
+SPL: NoRewindIterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myNoRewindIterator extends NoRewindIterator {}
+try {
+ $it = new myNoRewindIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_067.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_067.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_067.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,18 @@
+--TEST--
+SPL: AppendIterator::__construct(void)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myAppendIterator extends AppendIterator {}
+try {
+ $it = new myAppendIterator();
+ echo "no exception";
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+no exception
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_069.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_069.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_069.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,19 @@
+--TEST--
+SPL: RecursiveIteratorIterator cannot be used with foreach by reference
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$arr = array(array(1,2));
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+$recItIt = new RecursiveIteratorIterator($recArrIt);
+
+foreach ($recItIt as &$val) echo "$val\n";
+
+?>
+--EXPECTF--
+Fatal error: An iterator cannot be used with foreach by reference in %s on line %d
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_070.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_070.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_070.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,22 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Ensure that non-overriden methods execute problem free.
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$array = array();
+$recArrIt = new RecursiveArrayIterator($array);
+
+$recItIt = new RecursiveIteratorIterator($recArrIt);
+
+var_dump($recItIt->beginIteration());
+var_dump($recItIt->endIteration());
+var_dump($recItIt->nextElement());
+
+?>
+
+--EXPECTF--
+NULL
+NULL
+NULL
\ No newline at end of file
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_071.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_071.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/iterator_071.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,34 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Test where the case is RS_SELF and mode is CHILD_FIRST
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$arr = array(array(1,2),2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function nextelement() {
+ echo __METHOD__."\n";
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::CHILD_FIRST);
+
+foreach ($recItIt as $key => $val) echo "$key\n";
+
+?>
+--EXPECTF--
+MyRecursiveIteratorIterator::nextelement
+0
+MyRecursiveIteratorIterator::nextelement
+1
+MyRecursiveIteratorIterator::nextelement
+0
+MyRecursiveIteratorIterator::nextelement
+1
\ No newline at end of file
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,38 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in beginchildren which should be handled in next()
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$arr = array(array(1,2),2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function beginchildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt2->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->beginchildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,38 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in callHasChildren which should be handled in next()
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$arr = array(1,2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function callHasChildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt2->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->callHasChildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,44 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in endchildren which should be handled in next()
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$arr = array(array(1,2));
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function endchildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+foreach ($recItIt as $val) echo "$val\n";
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+echo "===NEXT LOOP===\n";
+
+foreach ($recItIt2 as $val) echo "$val\n";
+
+?>
+--EXPECTF--
+1
+2
+===NEXT LOOP===
+1
+2
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->endchildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,38 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in nextelement which should be handled in next()
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$arr = array(1,2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function nextelement() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->nextelement()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_069.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_069.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_069.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,17 @@
+--TEST--
+SPL: RecursiveIteratorIterator cannot be used with foreach by reference
+--FILE--
+<?php
+
+$arr = array(array(1,2));
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+$recItIt = new RecursiveIteratorIterator($recArrIt);
+
+foreach ($recItIt as &$val) echo "$val\n";
+
+?>
+--EXPECTF--
+Fatal error: An iterator cannot be used with foreach by reference in %s on line %d
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_070.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_070.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_070.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,20 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Ensure that non-overriden methods execute problem free.
+--FILE--
+<?php
+
+$array = array();
+$recArrIt = new RecursiveArrayIterator($array);
+
+$recItIt = new RecursiveIteratorIterator($recArrIt);
+
+var_dump($recItIt->beginIteration());
+var_dump($recItIt->endIteration());
+var_dump($recItIt->nextElement());
+
+?>
+
+--EXPECTF--
+NULL
+NULL
+NULL
\ No newline at end of file
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_071.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_071.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_071.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Test where the case is RS_SELF and mode is CHILD_FIRST
+--FILE--
+<?php
+
+$arr = array(array(1,2),2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function nextelement() {
+ echo __METHOD__."\n";
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::CHILD_FIRST);
+
+foreach ($recItIt as $key => $val) echo "$key\n";
+
+?>
+--EXPECTF--
+MyRecursiveIteratorIterator::nextelement
+0
+MyRecursiveIteratorIterator::nextelement
+1
+MyRecursiveIteratorIterator::nextelement
+0
+MyRecursiveIteratorIterator::nextelement
+1
\ No newline at end of file
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in beginchildren which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(array(1,2),2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function beginchildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt2->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->beginchildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in callHasChildren which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(1,2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function callHasChildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt2->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->callHasChildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,42 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in endchildren which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(array(1,2));
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function endchildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+foreach ($recItIt as $val) echo "$val\n";
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+echo "===NEXT LOOP===\n";
+
+foreach ($recItIt2 as $val) echo "$val\n";
+
+?>
+--EXPECTF--
+1
+2
+===NEXT LOOP===
+1
+2
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->endchildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in nextelement which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(1,2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function nextelement() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->nextelement()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
Added: php/php-src/trunk/ext/spl/tests/iterator_069.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/iterator_069.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/iterator_069.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,17 @@
+--TEST--
+SPL: RecursiveIteratorIterator cannot be used with foreach by reference
+--FILE--
+<?php
+
+$arr = array(array(1,2));
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+$recItIt = new RecursiveIteratorIterator($recArrIt);
+
+foreach ($recItIt as &$val) echo "$val\n";
+
+?>
+--EXPECTF--
+Fatal error: An iterator cannot be used with foreach by reference in %s on line %d
Added: php/php-src/trunk/ext/spl/tests/iterator_070.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/iterator_070.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/iterator_070.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,20 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Ensure that non-overriden methods execute problem free.
+--FILE--
+<?php
+
+$array = array();
+$recArrIt = new RecursiveArrayIterator($array);
+
+$recItIt = new RecursiveIteratorIterator($recArrIt);
+
+var_dump($recItIt->beginIteration());
+var_dump($recItIt->endIteration());
+var_dump($recItIt->nextElement());
+
+?>
+
+--EXPECTF--
+NULL
+NULL
+NULL
\ No newline at end of file
Added: php/php-src/trunk/ext/spl/tests/iterator_071.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/iterator_071.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/iterator_071.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Test where the case is RS_SELF and mode is CHILD_FIRST
+--FILE--
+<?php
+
+$arr = array(array(1,2),2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function nextelement() {
+ echo __METHOD__."\n";
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::CHILD_FIRST);
+
+foreach ($recItIt as $key => $val) echo "$key\n";
+
+?>
+--EXPECTF--
+MyRecursiveIteratorIterator::nextelement
+0
+MyRecursiveIteratorIterator::nextelement
+1
+MyRecursiveIteratorIterator::nextelement
+0
+MyRecursiveIteratorIterator::nextelement
+1
\ No newline at end of file
Added: php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in beginchildren which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(array(1,2),2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function beginchildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt2->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->beginchildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
Added: php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in callHasChildren which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(1,2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function callHasChildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt2->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->callHasChildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
Added: php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,42 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in endchildren which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(array(1,2));
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function endchildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+foreach ($recItIt as $val) echo "$val\n";
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+echo "===NEXT LOOP===\n";
+
+foreach ($recItIt2 as $val) echo "$val\n";
+
+?>
+--EXPECTF--
+1
+2
+===NEXT LOOP===
+1
+2
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->endchildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
Added: php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt 2009-12-08 19:51:56 UTC (rev 291895)
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in nextelement which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(1,2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function nextelement() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->nextelement()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php