summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2009-05-17 15:21:45 +0000
committerFelipe Pena <felipe@php.net>2009-05-17 15:21:45 +0000
commit05b9feb85f391e8e6a6e8a1ad74364965e83da01 (patch)
tree312747f0f2da2b19413ba5c7750046ee6733d33a /ext
parent0e4de79b40219e3ababd5aa723ed071a75ed2503 (diff)
downloadphp-git-05b9feb85f391e8e6a6e8a1ad74364965e83da01.tar.gz
- New tests (testfest LondonUG)
Diffstat (limited to 'ext')
-rw-r--r--ext/spl/tests/heap_corruption.phpt62
-rw-r--r--ext/spl/tests/heap_current_variation_001.phpt22
-rw-r--r--ext/spl/tests/heap_isempty_variation_001.phpt16
-rw-r--r--ext/spl/tests/heap_it_current_empty.phpt12
-rw-r--r--ext/spl/tests/heap_top_variation_001.phpt14
-rw-r--r--ext/spl/tests/heap_top_variation_002.phpt31
-rw-r--r--ext/spl/tests/heap_top_variation_003.phpt16
-rw-r--r--ext/spl/tests/iterator_count.phpt26
-rw-r--r--ext/spl/tests/iterator_to_array.phpt25
-rw-r--r--ext/spl/tests/limititerator_seek.phpt18
-rw-r--r--ext/spl/tests/pqueue_compare_basic.phpt19
-rw-r--r--ext/spl/tests/pqueue_compare_error.phpt19
-rw-r--r--ext/spl/tests/pqueue_current_error.phpt12
-rw-r--r--ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt32
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_beginiteration_basic.phpt32
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_enditeration_basic.phpt32
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_getsubiterator_basic.phpt20
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt15
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation.phpt42
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_002.phpt20
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_003.phpt42
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_nextelement_basic.phpt39
-rw-r--r--ext/spl/tests/regexiterator_getpregflags.phpt33
-rw-r--r--ext/spl/tests/regexiterator_setflags_exception.phpt35
-rw-r--r--ext/spl/tests/regexiterator_setpregflags.phpt34
-rw-r--r--ext/spl/tests/regexiterator_setpregflags_exception.phpt36
-rw-r--r--ext/spl/tests/spl_caching_iterator_constructor_flags.phpt25
-rw-r--r--ext/spl/tests/spl_cachingiterator___toString_basic.phpt16
-rw-r--r--ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt16
-rwxr-xr-xext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt22
-rw-r--r--ext/spl/tests/spl_heap_count_basic.phpt35
-rw-r--r--ext/spl/tests/spl_heap_count_error.phpt12
-rw-r--r--ext/spl/tests/spl_heap_extract_parameter_error.phpt27
-rw-r--r--ext/spl/tests/spl_heap_insert_basic.phpt20
-rw-r--r--ext/spl/tests/spl_heap_is_empty_basic.phpt31
-rw-r--r--ext/spl/tests/spl_heap_isempty.phpt21
-rw-r--r--ext/spl/tests/spl_heap_iteration_error.phpt53
-rw-r--r--ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt15
-rwxr-xr-xext/spl/tests/spl_iterator_apply_error.phpt26
-rwxr-xr-xext/spl/tests/spl_iterator_apply_error_001.phpt20
-rw-r--r--ext/spl/tests/spl_iterator_caching_count_basic.phpt21
-rw-r--r--ext/spl/tests/spl_iterator_caching_count_error.phpt21
-rw-r--r--ext/spl/tests/spl_iterator_caching_getcache_error.phpt21
-rw-r--r--ext/spl/tests/spl_iterator_getcallchildren.phpt39
-rw-r--r--ext/spl/tests/spl_iterator_iterator_constructor.phpt30
-rw-r--r--ext/spl/tests/spl_iterator_recursive_getiterator_error.phpt16
-rw-r--r--ext/spl/tests/spl_iterator_to_array_basic.phpt13
-rwxr-xr-xext/spl/tests/spl_iterator_to_array_error.phpt33
-rw-r--r--ext/spl/tests/spl_limit_iterator_check_limits.phpt37
-rw-r--r--ext/spl/tests/spl_maxheap_compare_basic.phpt22
-rw-r--r--ext/spl/tests/spl_minheap_compare_error.phpt31
-rw-r--r--ext/spl/tests/spl_pq_top_basic.phpt42
-rw-r--r--ext/spl/tests/spl_pq_top_error_args.phpt12
-rw-r--r--ext/spl/tests/spl_pq_top_error_corrupt.phpt38
-rw-r--r--ext/spl/tests/spl_pq_top_error_empty.phpt19
-rw-r--r--ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt31
-rw-r--r--ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt28
-rw-r--r--ext/spl/tests/spl_recursive_iterator_iterator_key_case.phpt33
-rw-r--r--ext/spl/tests/splpriorityqueue_extract.phpt19
-rw-r--r--ext/spl/tests/splpriorityqueue_setextractflags.phpt17
60 files changed, 1566 insertions, 0 deletions
diff --git a/ext/spl/tests/heap_corruption.phpt b/ext/spl/tests/heap_corruption.phpt
new file mode 100644
index 0000000000..284ee1db81
--- /dev/null
+++ b/ext/spl/tests/heap_corruption.phpt
@@ -0,0 +1,62 @@
+--TEST--
+SPL: SplHeap - heap corruption via compare exception (with top element deletion)
+--CREDITS--
+Mike Sullivan <mikesul@php.net>
+#TestFest 2009 (London)
+--FILE--
+<?php
+
+class myHeap extends SplHeap
+{
+ public $allow_compare = true;
+
+ public function compare($v1, $v2)
+ {
+ if ($this->allow_compare == true)
+ {
+ if ($v1 > $v2)
+ {
+ return 1;
+ }
+ else if ($v1 < $v2)
+ {
+ return -1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ throw new Exception('Compare exception');
+ }
+ }
+}
+
+$heap = new myHeap();
+$heap->insert(1);
+$heap->insert(2);
+$heap->insert(3);
+$heap->insert(4);
+
+$heap->allow_compare = false;
+
+try {
+ $heap->extract();
+}
+catch (Exception $e) {
+ echo "Compare Exception: " . $e->getMessage() . PHP_EOL;
+}
+
+try {
+ $heap->top();
+}
+catch (Exception $e) {
+ echo "Corruption Exception: " . $e->getMessage() . PHP_EOL;
+}
+
+?>
+--EXPECT--
+Compare Exception: Compare exception
+Corruption Exception: Heap is corrupted, heap properties are no longer ensured. \ No newline at end of file
diff --git a/ext/spl/tests/heap_current_variation_001.phpt b/ext/spl/tests/heap_current_variation_001.phpt
new file mode 100644
index 0000000000..eb6df2b88e
--- /dev/null
+++ b/ext/spl/tests/heap_current_variation_001.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplHeap::current - get current value from empty heap
+--CREDITS--
+Mike Sullivan <mikesul@php.net>
+#TestFest 2009 (London)
+--FILE--
+<?php
+
+class myHeap extends SplHeap
+{
+ public function compare($v1, $v2)
+ {
+ throw new Exception('');
+ }
+}
+
+$heap = new myHeap();
+var_dump($heap->current());
+
+?>
+--EXPECT--
+NULL \ No newline at end of file
diff --git a/ext/spl/tests/heap_isempty_variation_001.phpt b/ext/spl/tests/heap_isempty_variation_001.phpt
new file mode 100644
index 0000000000..dac470fccf
--- /dev/null
+++ b/ext/spl/tests/heap_isempty_variation_001.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: SplHeap: isEmpty argument variation.
+--FILE--
+<?php
+class SplHeap2 extends SplHeap{
+
+ public function compare() {
+ return -parent::compare();
+ }
+}
+
+$h = new SplHeap2;
+$h->isEmpty(1);
+?>
+--EXPECTF--
+Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/heap_it_current_empty.phpt b/ext/spl/tests/heap_it_current_empty.phpt
new file mode 100644
index 0000000000..24230dbeeb
--- /dev/null
+++ b/ext/spl/tests/heap_it_current_empty.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplHeap current, check looping through an empty heap gives you no values
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplMinHeap();
+
+foreach ($h as $val) { echo 'FAIL'; }
+?>
+--EXPECT--
diff --git a/ext/spl/tests/heap_top_variation_001.phpt b/ext/spl/tests/heap_top_variation_001.phpt
new file mode 100644
index 0000000000..9953cf9ade
--- /dev/null
+++ b/ext/spl/tests/heap_top_variation_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SPL: SplHeap top, illegal number of args
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplMinHeap();
+$h->insert(5);
+// top doesn't take any args, lets see what happens if we give it one
+$h->top('bogus');
+?>
+--EXPECTF--
+Warning: SplHeap::top() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/heap_top_variation_002.phpt b/ext/spl/tests/heap_top_variation_002.phpt
new file mode 100644
index 0000000000..cd6a8d0ad9
--- /dev/null
+++ b/ext/spl/tests/heap_top_variation_002.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: SplHeap top, corrupted heap
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+// override heap to force corruption by throwing exception in compare
+class SplMinHeap2 extends SplMinHeap {
+ public function compare($a, $b) {
+ throw new Exception('Corrupt heap');
+ }
+}
+
+$h = new SplMinHeap2();
+
+// insert 2 elements to hit our overridden compare
+$h->insert(4);
+try {
+ $h->insert(5);
+} catch (Exception $e) {}
+
+// call top, should fail with corrupted heap
+try {
+ $h->top();
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+?>
+--EXPECTF--
+Heap is corrupted, heap properties are no longer ensured.
diff --git a/ext/spl/tests/heap_top_variation_003.phpt b/ext/spl/tests/heap_top_variation_003.phpt
new file mode 100644
index 0000000000..7a91a9c000
--- /dev/null
+++ b/ext/spl/tests/heap_top_variation_003.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: SplHeap top of empty heap
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplMinHeap();
+try {
+ $h->top();
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+?>
+--EXPECTF--
+Can't peek at an empty heap
diff --git a/ext/spl/tests/iterator_count.phpt b/ext/spl/tests/iterator_count.phpt
new file mode 100644
index 0000000000..9aa4e1197c
--- /dev/null
+++ b/ext/spl/tests/iterator_count.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SPL: iterator_count() exceptions test
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$array=array('a','b');
+
+$iterator = new ArrayIterator($array);
+
+iterator_count();
+
+
+iterator_count($iterator,'1');
+
+iterator_count('1');
+
+
+?>
+--EXPECTF--
+Warning: iterator_count() expects exactly 1 parameter, 0 given in %s
+
+Warning: iterator_count() expects exactly 1 parameter, 2 given in %s
+
+Catchable fatal error: Argument 1 passed to iterator_count() must implement interface Traversable, %unicode_string_optional% given %s
diff --git a/ext/spl/tests/iterator_to_array.phpt b/ext/spl/tests/iterator_to_array.phpt
new file mode 100644
index 0000000000..958d370cca
--- /dev/null
+++ b/ext/spl/tests/iterator_to_array.phpt
@@ -0,0 +1,25 @@
+--TEST--
+SPL: iterator_to_array() exceptions test
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$array=array('a','b');
+
+$iterator = new ArrayIterator($array);
+
+iterator_to_array();
+
+
+iterator_to_array($iterator,'test','test');
+
+iterator_to_array('test','test');
+
+?>
+--EXPECTF--
+Warning: iterator_to_array() expects at least 1 parameter, 0 given in %s
+
+Warning: iterator_to_array() expects at most 2 parameters, 3 given in %s
+
+Catchable fatal error: Argument 1 passed to iterator_to_array() must implement interface Traversable, %unicode_string_optional% given %s
diff --git a/ext/spl/tests/limititerator_seek.phpt b/ext/spl/tests/limititerator_seek.phpt
new file mode 100644
index 0000000000..a59a49bee8
--- /dev/null
+++ b/ext/spl/tests/limititerator_seek.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SPL: LimitIterator seek() arguments
+--CREDITS--
+Roshan Abraham (roshanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+
+$a = array(1,2,3);
+$lt = new LimitIterator(new ArrayIterator($a));
+
+$lt->seek(1,1); // Should throw a warning as seek expects only 1 argument
+
+?>
+--EXPECTF--
+
+Warning: LimitIterator::seek() expects exactly 1 parameter, 2 given in %s on line %d
+
diff --git a/ext/spl/tests/pqueue_compare_basic.phpt b/ext/spl/tests/pqueue_compare_basic.phpt
new file mode 100644
index 0000000000..1544add469
--- /dev/null
+++ b/ext/spl/tests/pqueue_compare_basic.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: SplPriorityQueue: test compare
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplPriorityQueue();
+var_dump($h->compare(4, 5) < 0);
+var_dump($h->compare(5, 5) == 0);
+var_dump($h->compare(5, 4) > 0);
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/pqueue_compare_error.phpt b/ext/spl/tests/pqueue_compare_error.phpt
new file mode 100644
index 0000000000..610be2a569
--- /dev/null
+++ b/ext/spl/tests/pqueue_compare_error.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: Priority queue compare, illegal number of args
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplPriorityQueue();
+$h->compare();
+$h->compare(1);
+$h->compare(1, 2, 3);
+?>
+--EXPECTF--
+Warning: SplPriorityQueue::compare() expects exactly 2 parameters, 0 given in %s
+
+Warning: SplPriorityQueue::compare() expects exactly 2 parameters, 1 given in %s
+
+Warning: SplPriorityQueue::compare() expects exactly 2 parameters, 3 given in %s
+
diff --git a/ext/spl/tests/pqueue_current_error.phpt b/ext/spl/tests/pqueue_current_error.phpt
new file mode 100644
index 0000000000..7fdf0af5e4
--- /dev/null
+++ b/ext/spl/tests/pqueue_current_error.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplPriorityQueue current on empty queue should give null
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplPriorityQueue();
+var_dump($h->current());
+?>
+--EXPECT--
+NULL
diff --git a/ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt b/ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt
new file mode 100644
index 0000000000..81c853f307
--- /dev/null
+++ b/ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RecursiveTreeIterator::setPrefixPart() Test arguments
+--CREDITS--
+Roshan Abraham (roshanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+
+$arr = array(
+ "a" => array("b")
+);
+
+$it = new RecursiveArrayIterator($arr);
+$it = new RecursiveTreeIterator($it);
+
+$it->setPrefixPart(1); // Should throw a warning as setPrefixPart expects 2 arguments
+
+$a = new stdClass();
+$it->setPrefixPart($a, 1); // Should throw a warning as setPrefixPart expects argument 1 to be long integer
+
+$it->setPrefixPart(1, $a); // Should throw a warning as setPrefixPart expects argument 2 to be a string
+
+
+?>
+===DONE===
+--EXPECTF--
+Warning: RecursiveTreeIterator::setPrefixPart() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: RecursiveTreeIterator::setPrefixPart() expects parameter 1 to be long, object given in %s on line %d
+
+Warning: RecursiveTreeIterator::setPrefixPart() expects parameter 2 to be %binary_string_optional%, object given in %s on line %d
+===DONE===
diff --git a/ext/spl/tests/recursiveiteratoriterator_beginiteration_basic.phpt b/ext/spl/tests/recursiveiteratoriterator_beginiteration_basic.phpt
new file mode 100644
index 0000000000..c9476e0e56
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_beginiteration_basic.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RecursiveIteratorIterator::beginIteration() is called by RecursiveIteratorIterator::rewind()
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2);
+$sub_iterator = new RecursiveArrayIterator($sample_array);
+
+$iterator = new RecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+
+class SkipsFirstElementRecursiveIteratorIterator extends RecursiveIteratorIterator {
+ public function beginIteration() {
+ echo "::beginIteration() was invoked\n";
+ $this->next();
+ }
+}
+$iterator = new SkipsFirstElementRecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+?>
+--EXPECT--
+int(1)
+int(2)
+::beginIteration() was invoked
+int(2)
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_enditeration_basic.phpt b/ext/spl/tests/recursiveiteratoriterator_enditeration_basic.phpt
new file mode 100644
index 0000000000..0355401f27
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_enditeration_basic.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RecursiveIteratorIterator::endIteration() is called when ::valid() first returns false
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2);
+$sub_iterator = new RecursiveArrayIterator($sample_array);
+
+$iterator = new RecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+
+class EndIterationRecursiveIteratorIterator extends RecursiveIteratorIterator {
+ public function endIteration() {
+ echo "::endIteration() was invoked\n";
+ }
+}
+$iterator = new EndIterationRecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+?>
+--EXPECT--
+int(1)
+int(2)
+int(1)
+int(2)
+::endIteration() was invoked
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_basic.phpt b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_basic.phpt
new file mode 100644
index 0000000000..5d1c958d92
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_basic.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SPL: RecursiveIteratorIterator::getSubIterator() returns iterator passed in constructor
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2, array(3, 4));
+
+$sub_iterator = new RecursiveArrayIterator($sample_array);
+$not_sub_iterator = new RecursiveArrayIterator($sample_array);
+$iterator = new RecursiveIteratorIterator($sub_iterator);
+
+var_dump($iterator->getSubIterator() === $sub_iterator);
+var_dump($iterator->getSubIterator() === $not_sub_iterator);
+?>
+--EXPECT--
+bool(true)
+bool(false)
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt
new file mode 100644
index 0000000000..760082f6bd
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: RecursiveIteratorIterator::getSubIterator() expects at most 1 parameter
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator(array()));
+$iterator->getSubIterator();
+$iterator->getSubIterator(0);
+$iterator->getSubIterator(0, 0);
+?>
+--EXPECTF--
+Warning: RecursiveIteratorIterator::getSubIterator() expects at most 1 parameter, 2 given in %s on line 5
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation.phpt b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation.phpt
new file mode 100644
index 0000000000..a7b84c4bcc
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation.phpt
@@ -0,0 +1,42 @@
+--TEST--
+SPL: RecursiveIteratorIterator::getSubIterator() returns different iterators depending on the current element
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2, array(3, 4));
+
+$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($sample_array));
+
+$iterator->next();
+$iterator->next();
+var_dump(get_class($iterator->getSubIterator()));
+var_dump($iterator->getSubIterator()->getArrayCopy());
+$iterator->next();
+var_dump(get_class($iterator->getSubIterator()));
+var_dump($iterator->getSubIterator()->getArrayCopy());
+?>
+--EXPECTF--
+%unicode|string%(22) "RecursiveArrayIterator"
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+ }
+}
+%unicode|string%(22) "RecursiveArrayIterator"
+array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+}
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_002.phpt b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_002.phpt
new file mode 100644
index 0000000000..aac4e65bb8
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_002.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SPL: RecursiveIteratorIterator::getSubIterator() returns NULL if there's no current element
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1);
+
+$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($sample_array));
+
+$iterator->next();
+var_dump(is_null($iterator->getSubIterator()));
+$iterator->next();
+var_dump(is_null($iterator->getSubIterator()));
+?>
+--EXPECT--
+bool(false)
+bool(false)
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_003.phpt b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_003.phpt
new file mode 100644
index 0000000000..ff18840391
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_003.phpt
@@ -0,0 +1,42 @@
+--TEST--
+SPL: RecursiveIteratorIterator::getSubIterator() with explicit level parameter
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2, array(3, 4));
+
+$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($sample_array));
+
+$iterator->next();
+$iterator->next();
+$iterator->next();
+var_dump($iterator->getSubIterator(-1));
+var_dump($iterator->getSubIterator(0)->getArrayCopy());
+var_dump($iterator->getSubIterator(1)->getArrayCopy());
+var_dump($iterator->getSubIterator(2));
+?>
+--EXPECT--
+NULL
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+ }
+}
+array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+}
+NULL
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_nextelement_basic.phpt b/ext/spl/tests/recursiveiteratoriterator_nextelement_basic.phpt
new file mode 100644
index 0000000000..0bf4f198f3
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_nextelement_basic.phpt
@@ -0,0 +1,39 @@
+--TEST--
+SPL: RecursiveIteratorIterator::nextElement() is called when the next element is ready
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2, array(3, 4));
+$sub_iterator = new RecursiveArrayIterator($sample_array);
+
+$iterator = new RecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+
+class NextElementRecursiveIteratorIterator extends RecursiveIteratorIterator {
+ public function nextElement() {
+ echo "::nextElement() was invoked\n";
+ }
+}
+$iterator = new NextElementRecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+?>
+--EXPECT--
+int(1)
+int(2)
+int(3)
+int(4)
+::nextElement() was invoked
+int(1)
+::nextElement() was invoked
+int(2)
+::nextElement() was invoked
+int(3)
+::nextElement() was invoked
+int(4)
+
diff --git a/ext/spl/tests/regexiterator_getpregflags.phpt b/ext/spl/tests/regexiterator_getpregflags.phpt
new file mode 100644
index 0000000000..58a4dc4a3b
--- /dev/null
+++ b/ext/spl/tests/regexiterator_getpregflags.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: RegexIterator::getPregFlags()
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class myIterator implements Iterator {
+
+function current (){}
+function key ( ){}
+function next ( ){}
+function rewind ( ){}
+function valid ( ){}
+
+
+}
+
+class TestRegexIterator extends RegexIterator{}
+
+$rege = '/^a/';
+
+
+$r = new TestRegexIterator(new myIterator, $rege);
+
+$r->setPregFlags(PREG_OFFSET_CAPTURE);
+
+echo is_long($r->getPregFlags());
+
+?>
+--EXPECTF--
+1 \ No newline at end of file
diff --git a/ext/spl/tests/regexiterator_setflags_exception.phpt b/ext/spl/tests/regexiterator_setflags_exception.phpt
new file mode 100644
index 0000000000..fdc8bca649
--- /dev/null
+++ b/ext/spl/tests/regexiterator_setflags_exception.phpt
@@ -0,0 +1,35 @@
+--TEST--
+SPL: RegexIterator::setFlags() exceptions test
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class myIterator implements Iterator {
+
+function current (){}
+function key ( ){}
+function next ( ){}
+function rewind ( ){}
+function valid ( ){}
+
+
+}
+
+class TestRegexIterator extends RegexIterator{}
+
+$rege = '/^a/';
+
+
+$r = new TestRegexIterator(new myIterator, $rege);
+
+try{
+ $r->setFlags();
+}catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECTF--
+Warning: RegexIterator::setFlags() expects exactly 1 parameter, 0 given in %s \ No newline at end of file
diff --git a/ext/spl/tests/regexiterator_setpregflags.phpt b/ext/spl/tests/regexiterator_setpregflags.phpt
new file mode 100644
index 0000000000..ea1b455488
--- /dev/null
+++ b/ext/spl/tests/regexiterator_setpregflags.phpt
@@ -0,0 +1,34 @@
+--TEST--
+SPL: RegexIterator::setPregFlags()
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class myIterator implements Iterator {
+
+function current (){}
+function key ( ){}
+function next ( ){}
+function rewind ( ){}
+function valid ( ){}
+
+
+}
+
+class TestRegexIterator extends RegexIterator{}
+
+$rege = '/^a/';
+
+
+$r = new TestRegexIterator(new myIterator, $rege);
+
+$r->setPregFlags(PREG_OFFSET_CAPTURE);
+
+echo $r->getPregFlags();
+
+
+?>
+--EXPECTF--
+256 \ No newline at end of file
diff --git a/ext/spl/tests/regexiterator_setpregflags_exception.phpt b/ext/spl/tests/regexiterator_setpregflags_exception.phpt
new file mode 100644
index 0000000000..cc7c17c272
--- /dev/null
+++ b/ext/spl/tests/regexiterator_setpregflags_exception.phpt
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RegexIterator::getPregFlags() exception test
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class myIterator implements Iterator {
+
+function current (){}
+function key ( ){}
+function next ( ){}
+function rewind ( ){}
+function valid ( ){}
+
+
+}
+
+class TestRegexIterator extends RegexIterator{}
+
+$rege = '/^a/';
+
+
+$r = new TestRegexIterator(new myIterator, $rege);
+
+
+try{
+ $r->setPregFlags();
+}catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECTF--
+Warning: RegexIterator::setPregFlags() expects exactly 1 parameter, 0 given in %s \ No newline at end of file
diff --git a/ext/spl/tests/spl_caching_iterator_constructor_flags.phpt b/ext/spl/tests/spl_caching_iterator_constructor_flags.phpt
new file mode 100644
index 0000000000..499cd67559
--- /dev/null
+++ b/ext/spl/tests/spl_caching_iterator_constructor_flags.phpt
@@ -0,0 +1,25 @@
+--TEST--
+SPL: CachingInterator constructor flag checks
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+ //line 681 ...
+ $array = array(array(7,8,9),1,2,3,array(4,5,6));
+$arrayIterator = new ArrayIterator($array);
+try {
+$test = new CachingIterator($arrayIterator, 0);
+$test = new CachingIterator($arrayIterator, 1);
+$test = new CachingIterator($arrayIterator, 2);
+$test = new CachingIterator($arrayIterator, 3); // this throws an exception
+} catch (InvalidArgumentException $e){
+ print $e->getMessage() . "\n";
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_CURRENT
+===DONE===
diff --git a/ext/spl/tests/spl_cachingiterator___toString_basic.phpt b/ext/spl/tests/spl_cachingiterator___toString_basic.phpt
new file mode 100644
index 0000000000..0395b3794d
--- /dev/null
+++ b/ext/spl/tests/spl_cachingiterator___toString_basic.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: SplCachingIterator, Test method to convert current element to string
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+$ai = new ArrayIterator(array(new stdClass(), new stdClass()));
+$ci = new CachingIterator($ai);
+var_dump(
+$ci->__toString() // if conversion to string is done by echo, for example, an exeption is thrown. Invoking __toString explicitly covers different code.
+);
+?>
+--EXPECTF--
+NULL
diff --git a/ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt b/ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt
new file mode 100644
index 0000000000..126586bcc7
--- /dev/null
+++ b/ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: SplCachingIterator, Test method to set flags for caching iterator
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+$ai = new ArrayIterator(array('foo', 'bar'));
+
+$ci = new CachingIterator($ai);
+$ci->setFlags(); //expects arg
+
+?>
+--EXPECTF--
+Warning: CachingIterator::setFlags() expects exactly 1 parameter, %s
diff --git a/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt b/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt
new file mode 100755
index 0000000000..399d9a31aa
--- /dev/null
+++ b/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: Spl File Info test getLinkTarget
+--CREDITS--
+Nataniel McHugh nat@fishtrap.co.uk
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+$link = 'test_link';
+symlink(__FILE__, $link );
+$fileInfo = new SplFileInfo($link);
+
+if ($fileInfo->isLink()) {
+ echo $fileInfo->getLinkTarget() == __FILE__ ? 'same' : 'different',PHP_EOL;
+}
+var_dump(unlink($link));
+?>
+--EXPECT--
+same
+bool(true)
diff --git a/ext/spl/tests/spl_heap_count_basic.phpt b/ext/spl/tests/spl_heap_count_basic.phpt
new file mode 100644
index 0000000000..6e6baf6c9b
--- /dev/null
+++ b/ext/spl/tests/spl_heap_count_basic.phpt
@@ -0,0 +1,35 @@
+--TEST--
+SPL: SplHeap, Test spl_heap_object_count_elements (spl_heap.c:490) for returning count() failure for Heaps
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class MyHeap extends SplHeap
+{
+ public function compare($a,$b)
+ {
+ return ($a < $b);
+ }
+
+ public function count() // override count to force failure
+ {
+ throw new Exception('Cause count to fail');
+ return parent::count();
+ }
+}
+
+
+$heap = new MyHeap();
+$heap->insert(1);
+count($heap);// refers to MyHeap->count() method
+
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'Exception' with message 'Cause count to fail' in %s
+Stack trace:
+#0 [internal function]: MyHeap->count()
+#1 %s count(Object(MyHeap))
+#2 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/spl_heap_count_error.phpt b/ext/spl/tests/spl_heap_count_error.phpt
new file mode 100644
index 0000000000..6bed4cfa60
--- /dev/null
+++ b/ext/spl/tests/spl_heap_count_error.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: Priority queue count, illegal number of args
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplPriorityQueue();
+$h->count(1);
+?>
+--EXPECTF--
+Warning: SplPriorityQueue::count() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/spl_heap_extract_parameter_error.phpt b/ext/spl/tests/spl_heap_extract_parameter_error.phpt
new file mode 100644
index 0000000000..aecd03dfa1
--- /dev/null
+++ b/ext/spl/tests/spl_heap_extract_parameter_error.phpt
@@ -0,0 +1,27 @@
+--TEST--
+SPL: Heap and extract with parameter
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+
+class TestHeap extends SplHeap {
+
+ function compare() {
+ print "This shouldn't be printed";
+ }
+}
+
+$testHeap = new TestHeap();
+
+
+
+var_dump($testHeap->extract('test'));
+
+?>
+===DONE===
+--EXPECTF--
+Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line 14
+NULL
+===DONE===
diff --git a/ext/spl/tests/spl_heap_insert_basic.phpt b/ext/spl/tests/spl_heap_insert_basic.phpt
new file mode 100644
index 0000000000..76a34b292b
--- /dev/null
+++ b/ext/spl/tests/spl_heap_insert_basic.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SPL: SplHeap, Test method to insert into heap
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+class MyHeap extends SplHeap
+{
+ public function compare($a, $b)
+ {
+ return $a < $b;
+ }
+}
+
+$heap = new MyHeap();
+$heap->insert(1,2);
+?>
+--EXPECTF--
+Warning: SplHeap::insert() expects exactly 1 parameter, %s
diff --git a/ext/spl/tests/spl_heap_is_empty_basic.phpt b/ext/spl/tests/spl_heap_is_empty_basic.phpt
new file mode 100644
index 0000000000..47d7ccce9a
--- /dev/null
+++ b/ext/spl/tests/spl_heap_is_empty_basic.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: SplHeap, test trivial method to find if a heap is empty
+--CREDITS--
+Nathaniel McHugh nat@fishtrap.co.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class MyHeap extends SplHeap{
+
+public function compare($a, $b){
+return $a < $b;
+}
+
+}
+
+
+$heap = new MyHeap();
+var_dump($heap->isEmpty());
+$heap->insert(1);
+var_dump($heap->isEmpty());
+$heap->extract();
+var_dump($heap->isEmpty());
+$heap->isEmpty('var');
+?>
+--EXPECTF--
+bool(true)
+bool(false)
+bool(true)
+
+Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/spl_heap_isempty.phpt b/ext/spl/tests/spl_heap_isempty.phpt
new file mode 100644
index 0000000000..2729c7fa87
--- /dev/null
+++ b/ext/spl/tests/spl_heap_isempty.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: Test of isEmpty for SPL Max Heap
+--CREDITS--
+Rohan Abraham (rohanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+ $h = new SplMaxHeap();
+ echo "Checking a new heap is empty: ";
+ var_dump($h->isEmpty())."\n";
+ $h->insert(2);
+ echo "Checking after insert: ";
+ var_dump($h->isEmpty())."\n";
+ $h->extract();
+ echo "Checking after extract: ";
+ var_dump($h->isEmpty())."\n";
+?>
+--EXPECT--
+Checking a new heap is empty: bool(true)
+Checking after insert: bool(false)
+Checking after extract: bool(true) \ No newline at end of file
diff --git a/ext/spl/tests/spl_heap_iteration_error.phpt b/ext/spl/tests/spl_heap_iteration_error.phpt
new file mode 100644
index 0000000000..62e462f553
--- /dev/null
+++ b/ext/spl/tests/spl_heap_iteration_error.phpt
@@ -0,0 +1,53 @@
+--TEST--
+SPL: Attempt to corrupt the heap while iterating
+--CREDITS--
+Lukasz Andrzejak meltir@meltir.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+class ext_heap extends SplMaxHeap {
+ public $fail = false;
+ public function compare($val1,$val2) {
+ if ($this->fail)
+ throw new Exception('Corrupting heap',99);
+ return 0;
+ }
+}
+
+$h = new ext_heap();
+$h->insert(array('foobar'));
+$h->insert(array('foobar1'));
+$h->insert(array('foobar2'));
+
+try {
+ $h->fail=true;
+ foreach ($h as $value) {};
+ echo "I should have raised an exception here";
+} catch (Exception $e) {
+ if ($e->getCode()!=99) echo "Unexpected exception";
+}
+
+var_dump($h);
+?>
+--EXPECTF--
+object(ext_heap)#%d (4) {
+ [%u|b%"fail"]=>
+ bool(true)
+ [%u|b%"flags":%u|b%"SplHeap":private]=>
+ int(0)
+ [%u|b%"isCorrupted":%u|b%"SplHeap":private]=>
+ bool(true)
+ [%u|b%"heap":%u|b%"SplHeap":private]=>
+ array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ %unicode|string%(7) "foobar2"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ %unicode|string%(7) "foobar1"
+ }
+ }
+}
diff --git a/ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt b/ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt
new file mode 100644
index 0000000000..8726f4b32a
--- /dev/null
+++ b/ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: SplHeap check no arguments to be accepted on recoverFromCorruption
+--CREDITS--
+Rohan Abraham (rohanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+ $h = new SplMaxHeap();
+ //Line below should throw a warning as no args are expected
+ $h->recoverFromCorruption("no args");
+?>
+--EXPECTF--
+
+Warning: SplHeap::recoverFromCorruption() expects exactly 0 parameters, 1 given in %s on line %d
+
diff --git a/ext/spl/tests/spl_iterator_apply_error.phpt b/ext/spl/tests/spl_iterator_apply_error.phpt
new file mode 100755
index 0000000000..8e7cba483a
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_apply_error.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SPL: Error: iterator_apply when an iterator method (eg rewind) throws exception
+--FILE--
+<?php
+
+class MyArrayIterator extends ArrayIterator {
+ public function rewind() {
+ throw new Exception('Make the iterator break');
+ }
+}
+
+function test() {}
+
+$it = new MyArrayIterator(array(1, 21, 22));
+
+try {
+ $res = iterator_apply($it, 'test');
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+
+<?php exit(0); ?>
+--EXPECT--
+Make the iterator break
diff --git a/ext/spl/tests/spl_iterator_apply_error_001.phpt b/ext/spl/tests/spl_iterator_apply_error_001.phpt
new file mode 100755
index 0000000000..54663c0da8
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_apply_error_001.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SPL: Error: iterator_apply when the callback throws an exception
+--FILE--
+<?php
+
+function test() {
+ throw new Exception('Broken callback');
+}
+
+$it = new RecursiveArrayIterator(array(1, 21, 22));
+
+try {
+ iterator_apply($it, 'test');
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECT--
+Broken callback
diff --git a/ext/spl/tests/spl_iterator_caching_count_basic.phpt b/ext/spl/tests/spl_iterator_caching_count_basic.phpt
new file mode 100644
index 0000000000..b11eb7b540
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_caching_count_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: Caching iterator count() cache contents
+--CREDITS--
+Lukasz Andrzejak meltir@meltir.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$i = new ArrayIterator(array(1,1,1,1,1));
+$i = new CachingIterator($i,CachingIterator::FULL_CACHE);
+foreach ($i as $value) {
+ echo $i->count()."\n";
+}
+?>
+===DONE===
+--EXPECT--
+1
+2
+3
+4
+5
+===DONE=== \ No newline at end of file
diff --git a/ext/spl/tests/spl_iterator_caching_count_error.phpt b/ext/spl/tests/spl_iterator_caching_count_error.phpt
new file mode 100644
index 0000000000..70aa2be30b
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_caching_count_error.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: Caching iterator count() cache failure
+--CREDITS--
+Lukasz Andrzejak meltir@meltir.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$i = new ArrayIterator(array(1,1,1,1,1));
+$i = new CachingIterator($i);
+try {
+ $i->count();
+ echo "Should have caused an exception";
+} catch (BadMethodCallException $e) {
+ echo "Exception raised\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+Exception raised
+===DONE=== \ No newline at end of file
diff --git a/ext/spl/tests/spl_iterator_caching_getcache_error.phpt b/ext/spl/tests/spl_iterator_caching_getcache_error.phpt
new file mode 100644
index 0000000000..2ea4bd819b
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_caching_getcache_error.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: Caching iterator getCache failure
+--CREDITS--
+Lukasz Andrzejak meltir@meltir.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$i = new ArrayIterator(array(1,1,1,1,1));
+$i = new CachingIterator($i);
+try {
+ $i->getCache();
+ echo "Should have caused an exception";
+} catch (BadMethodCallException $e) {
+ echo "Exception raised\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+Exception raised
+===DONE=== \ No newline at end of file
diff --git a/ext/spl/tests/spl_iterator_getcallchildren.phpt b/ext/spl/tests/spl_iterator_getcallchildren.phpt
new file mode 100644
index 0000000000..77b03b6b7f
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_getcallchildren.phpt
@@ -0,0 +1,39 @@
+--TEST--
+SPL: RecursiveIteratorIterator, getCallChildren
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+ //line 681 ...
+ $array = array(array(7,8,9),1,2,3,array(4,5,6));
+$recursiveArrayIterator = new RecursiveArrayIterator($array);
+$test = new RecursiveIteratorIterator($recursiveArrayIterator);
+
+var_dump($test->current());
+$test->next();
+var_dump($test->current());
+try {
+ $output = $test->callGetChildren();
+} catch (InvalidArgumentException $ilae){
+ $output = null;
+ print "invalid argument exception\n";
+}
+var_dump($output);
+
+
+?>
+===DONE===
+--EXPECTF--
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+}
+int(7)
+invalid argument exception
+NULL
+===DONE===
diff --git a/ext/spl/tests/spl_iterator_iterator_constructor.phpt b/ext/spl/tests/spl_iterator_iterator_constructor.phpt
new file mode 100644
index 0000000000..d4fdb14c13
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_iterator_constructor.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: IteratorInterator constructor checks
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+
+ //I think this is testing line 1297 of spl_iterators.c
+
+ $array = array(array(7,8,9),1,2,3,array(4,5,6));
+$arrayIterator = new ArrayIterator($array);
+try {
+$test = new IteratorIterator($arrayIterator);
+
+$test = new IteratorIterator($arrayIterator, 1);
+$test = new IteratorIterator($arrayIterator, 1, 1);
+$test = new IteratorIterator($arrayIterator, 1, 1, 1);
+$test = new IteratorIterator($arrayIterator, 1, 1, 1, 1);
+
+} catch (InvalidArgumentException $e){
+ print $e->getMessage() . "\n";
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+IteratorIterator::__construct() expects at most 2 parameters, 3 given
+===DONE===
diff --git a/ext/spl/tests/spl_iterator_recursive_getiterator_error.phpt b/ext/spl/tests/spl_iterator_recursive_getiterator_error.phpt
new file mode 100644
index 0000000000..0d45c31513
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_recursive_getiterator_error.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: IteratorIterator foreach by reference failure
+--CREDITS--
+Lukasz Andrzejak meltir@meltir.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$i = new ArrayIterator(array(1,1,1,1,1));
+$iii = new IteratorIterator($i);
+p($iii);
+function p ($i) {
+ foreach ($i as &$value) {}
+}
+?>
+--EXPECTF--
+Fatal error: An iterator cannot be used with foreach by reference in %s \ No newline at end of file
diff --git a/ext/spl/tests/spl_iterator_to_array_basic.phpt b/ext/spl/tests/spl_iterator_to_array_basic.phpt
new file mode 100644
index 0000000000..68cb8792a9
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_to_array_basic.phpt
@@ -0,0 +1,13 @@
+--TEST--
+SPL: iterator_to_array, Test function to convert iterator to array
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+iterator_to_array();//requires iterator as arg
+
+?>
+--EXPECTF--
+Warning: iterator_to_array() expects at least 1 parameter, %s
diff --git a/ext/spl/tests/spl_iterator_to_array_error.phpt b/ext/spl/tests/spl_iterator_to_array_error.phpt
new file mode 100755
index 0000000000..755ef7b990
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_to_array_error.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: Error: iterator_to_array when the current operation throws an exception
+--FILE--
+<?php
+
+class MyArrayIterator extends ArrayIterator {
+ public function current() {
+ throw new Exception('Make the iterator break');
+ }
+}
+
+$it = new MyArrayIterator(array(4, 6, 2));
+
+try {
+ // get keys
+ $ar = iterator_to_array($it);
+} catch (Exception $e) {
+ echo $e->getMessage() . PHP_EOL;
+}
+
+try {
+ // get values
+ $ar = iterator_to_array($it, false);
+} catch (Exception $e) {
+ echo $e->getMessage() . PHP_EOL;
+}
+
+?>
+
+<?php exit(0); ?>
+--EXPECT--
+Make the iterator break
+Make the iterator break
diff --git a/ext/spl/tests/spl_limit_iterator_check_limits.phpt b/ext/spl/tests/spl_limit_iterator_check_limits.phpt
new file mode 100644
index 0000000000..01436a8fbe
--- /dev/null
+++ b/ext/spl/tests/spl_limit_iterator_check_limits.phpt
@@ -0,0 +1,37 @@
+--TEST--
+SPL: LimitIterator check limits are valid
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+ $array = array(array(7,8,9),1,2,3,array(4,5,6));
+$arrayIterator = new ArrayIterator($array);
+
+try {
+ $limitIterator = new LimitIterator($arrayIterator, -1);
+} catch (OutOfRangeException $e){
+ print $e->getMessage(). "\n";
+}
+
+
+try {
+ $limitIterator = new LimitIterator($arrayIterator, 0, -2);
+} catch (OutOfRangeException $e){
+ print $e->getMessage() . "\n";
+}
+
+try {
+ $limitIterator = new LimitIterator($arrayIterator, 0, -1);
+} catch (OutOfRangeException $e){
+ print $e->getMessage() . "\n";
+}
+
+
+
+?>
+===DONE===
+--EXPECTF--
+Parameter offset must be > 0
+Parameter count must either be -1 or a value greater than or equal 0
+===DONE===
diff --git a/ext/spl/tests/spl_maxheap_compare_basic.phpt b/ext/spl/tests/spl_maxheap_compare_basic.phpt
new file mode 100644
index 0000000000..3705b3fd0b
--- /dev/null
+++ b/ext/spl/tests/spl_maxheap_compare_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplMaxHeap, Test method to comare elements
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class MyHeap extends SplMaxHeap
+{
+ public function testCompare()
+ {
+ return parent::compare(1);
+ }
+}
+
+$heap = new MyHeap();
+$heap->testCompare();
+
+?>
+--EXPECTF--
+Warning: SplMaxHeap::compare() expects exactly 2 parameters, %s
diff --git a/ext/spl/tests/spl_minheap_compare_error.phpt b/ext/spl/tests/spl_minheap_compare_error.phpt
new file mode 100644
index 0000000000..7120a6cd11
--- /dev/null
+++ b/ext/spl/tests/spl_minheap_compare_error.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: SplMinHeap compare, illegal number of args
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+class SplMinHeap2 extends SplMinHeap {
+ public function testCompare1() {
+ return parent::compare();
+ }
+ public function testCompare2() {
+ return parent::compare(1);
+ }
+ public function testCompare3() {
+ return parent::compare(1, 2, 3);
+ }
+}
+
+$h = new SplMinHeap2();
+$h->testCompare1();
+$h->testCompare2();
+$h->testCompare3();
+?>
+--EXPECTF--
+Warning: SplMinHeap::compare() expects exactly 2 parameters, 0 given in %s
+
+Warning: SplMinHeap::compare() expects exactly 2 parameters, 1 given in %s
+
+Warning: SplMinHeap::compare() expects exactly 2 parameters, 3 given in %s
+
diff --git a/ext/spl/tests/spl_pq_top_basic.phpt b/ext/spl/tests/spl_pq_top_basic.phpt
new file mode 100644
index 0000000000..dcc1cbe4c0
--- /dev/null
+++ b/ext/spl/tests/spl_pq_top_basic.phpt
@@ -0,0 +1,42 @@
+--TEST--
+SPL: SplPriorityQueue: top and extract flags
+--CREDITS--
+Nathaniel McHugh nat@fishtrap.co.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+$priorityQueue = new SplPriorityQueue();
+
+$priorityQueue->insert("a", 1);
+$priorityQueue->insert("b", 2);
+$priorityQueue->insert("c", 0);
+
+echo "EXTR DEFAULT",PHP_EOL;
+echo "value: ",$priorityQueue->top(),PHP_EOL;
+
+$priorityQueue->setExtractFlags(SplPriorityQueue::EXTR_PRIORITY);
+echo "EXTR_PRIORITY",PHP_EOL;
+echo "priority: ",$priorityQueue->top(),PHP_EOL;
+
+$priorityQueue->setExtractFlags(SplPriorityQueue::EXTR_BOTH);
+echo "EXTR_BOTH",PHP_EOL;
+print_r($priorityQueue->top());
+
+echo "EXTR_DATA",PHP_EOL;
+$priorityQueue->setExtractFlags(SplPriorityQueue::EXTR_DATA);
+echo "value: ",$priorityQueue->top(),PHP_EOL;
+?>
+--EXPECT--
+EXTR DEFAULT
+value: b
+EXTR_PRIORITY
+priority: 2
+EXTR_BOTH
+Array
+(
+ [data] => b
+ [priority] => 2
+)
+EXTR_DATA
+value: b \ No newline at end of file
diff --git a/ext/spl/tests/spl_pq_top_error_args.phpt b/ext/spl/tests/spl_pq_top_error_args.phpt
new file mode 100644
index 0000000000..a0e5969034
--- /dev/null
+++ b/ext/spl/tests/spl_pq_top_error_args.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplPriorityQueue: top too many arguments exception
+--CREDITS--
+Nathaniel McHugh nat@fishtrap.co.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$priorityQueue = new SplPriorityQueue();
+$priorityQueue->top('var');
+?>
+--EXPECTF--
+Warning: SplPriorityQueue::top() expects exactly 0 parameters, 1 given in %s \ No newline at end of file
diff --git a/ext/spl/tests/spl_pq_top_error_corrupt.phpt b/ext/spl/tests/spl_pq_top_error_corrupt.phpt
new file mode 100644
index 0000000000..30b6fde5a1
--- /dev/null
+++ b/ext/spl/tests/spl_pq_top_error_corrupt.phpt
@@ -0,0 +1,38 @@
+--TEST--
+SPL: SplPriorityQueue: top and extract flags
+--CREDITS--
+Nathaniel McHugh nat@fishtrap.co.uk
+#testfest 2009-05-09
+--FILE--
+<?php
+
+class myPriorityQueue extends SplPriorityQueue{
+
+ public function compare($a, $b){
+ if ($b == 2) {
+ throw new Exception('ignore me');
+ } else {
+ return parent::compare($a, $b);
+ }
+ }
+}
+
+$priorityQueue = new myPriorityQueue();
+$priorityQueue->insert("a", 1);
+
+try {
+ //corrupt heap
+ $priorityQueue->insert("b", 2);
+ // ignore exception tested elsewhere
+} catch (Exception $e) {
+}
+
+try {
+ $priorityQueue->top();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage().PHP_EOL;
+}
+
+?>
+--EXPECT--
+Exception: Heap is corrupted, heap properties are no longer ensured.
diff --git a/ext/spl/tests/spl_pq_top_error_empty.phpt b/ext/spl/tests/spl_pq_top_error_empty.phpt
new file mode 100644
index 0000000000..9e2a31bbc0
--- /dev/null
+++ b/ext/spl/tests/spl_pq_top_error_empty.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: SplPriorityQueue: top exception on empty heap
+--CREDITS--
+Nathaniel McHugh nat@fishtrap.co.uk
+#testfest 2009-05-09
+--FILE--
+<?php
+
+$priorityQueue = new SplPriorityQueue();
+
+try {
+ $priorityQueue->top();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage().PHP_EOL;
+}
+
+?>
+--EXPECT--
+Exception: Can't peek at an empty heap
diff --git a/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt b/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt
new file mode 100644
index 0000000000..659ffb4bc0
--- /dev/null
+++ b/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: priorityQueue paramter test on insert method
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+
+
+$testHeap = new SplPriorityQueue();
+
+
+var_dump($testHeap->insert());
+var_dump($testHeap->insert('test'));
+var_dump($testHeap->insert('test', 'test'));
+var_dump($testHeap->insert('test', 'test', 'test'));
+
+
+?>
+===DONE===
+--EXPECTF--
+Warning: SplPriorityQueue::insert() expects exactly 2 parameters, 0 given in %s on line 7
+NULL
+
+Warning: SplPriorityQueue::insert() expects exactly 2 parameters, 1 given in %s on line 8
+NULL
+bool(true)
+
+Warning: SplPriorityQueue::insert() expects exactly 2 parameters, 3 given in %s on line 10
+NULL
+===DONE===
diff --git a/ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt b/ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt
new file mode 100644
index 0000000000..d52a3208ec
--- /dev/null
+++ b/ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt
@@ -0,0 +1,28 @@
+--TEST--
+SPL: RecursiveIteratorIterator, setMaxDepth check parameter count
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+ //line 681 ...
+ $array = array(array(7,8,9),1,2,3,array(4,5,6));
+$recursiveArrayIterator = new RecursiveArrayIterator($array);
+$test = new RecursiveIteratorIterator($recursiveArrayIterator);
+
+//var_dump($test->current());
+$test->setMaxDepth();
+$test->setMaxDepth(1);
+$test->setMaxDepth(1,2);
+$test->setMaxDepth(1,2,3);
+
+//var_dump($test->current());
+
+
+?>
+===DONE===
+--EXPECTF--
+Warning: RecursiveIteratorIterator::setMaxDepth() expects at most 1 parameter, 2 given in %s on line 10
+
+Warning: RecursiveIteratorIterator::setMaxDepth() expects at most 1 parameter, 3 given in %s on line 11
+===DONE===
diff --git a/ext/spl/tests/spl_recursive_iterator_iterator_key_case.phpt b/ext/spl/tests/spl_recursive_iterator_iterator_key_case.phpt
new file mode 100644
index 0000000000..1262ec0d65
--- /dev/null
+++ b/ext/spl/tests/spl_recursive_iterator_iterator_key_case.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: Test on RecursiveIteratorIterator key function checking switch statements
+--CREDITS--
+Rohan Abraham (rohanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+ $ar = array("one"=>1, "two"=>2, "three"=>array("four"=>4, "five"=>5, "six"=>array("seven"=>7)), "eight"=>8, -100 => 10, NULL => "null");
+ $it = new RecursiveArrayIterator($ar);
+ $it = new RecursiveIteratorIterator($it);
+ foreach($it as $k=>$v)
+ {
+ echo "$k=>$v\n";
+ var_dump($k);
+ }
+?>
+--EXPECTF--
+one=>1
+%unicode|string%(3) "one"
+two=>2
+%unicode|string%(3) "two"
+four=>4
+%unicode|string%(4) "four"
+five=>5
+%unicode|string%(4) "five"
+seven=>7
+%unicode|string%(5) "seven"
+eight=>8
+%unicode|string%(5) "eight"
+-100=>10
+int(-100)
+=>null
+%unicode|string%(0) ""
diff --git a/ext/spl/tests/splpriorityqueue_extract.phpt b/ext/spl/tests/splpriorityqueue_extract.phpt
new file mode 100644
index 0000000000..eee7bb2f73
--- /dev/null
+++ b/ext/spl/tests/splpriorityqueue_extract.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: splpriorityqueue extract() Test arguments
+--CREDITS--
+Roshan Abraham (roshanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+
+$sp = new SplPriorityQueue();
+
+$sp->insert("1",1);
+
+$sp->extract(1); // Should throw a warning as extract expects NO arguments
+
+?>
+--EXPECTF--
+
+Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
+
diff --git a/ext/spl/tests/splpriorityqueue_setextractflags.phpt b/ext/spl/tests/splpriorityqueue_setextractflags.phpt
new file mode 100644
index 0000000000..97d86f375e
--- /dev/null
+++ b/ext/spl/tests/splpriorityqueue_setextractflags.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: splpriorityqueue setExtractFlags() Test arguments
+--CREDITS--
+Roshan Abraham (roshanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+
+$sp = new SplPriorityQueue();
+
+$sp->setExtractFlags(1,1); // Should throw a warning as setExtractFlags expects only 1 argument
+
+?>
+--EXPECTF--
+
+Warning: SplPriorityQueue::setExtractFlags() expects exactly 1 parameter, 2 given in %s on line %d
+