summaryrefslogtreecommitdiff
path: root/ext/spl/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/spl/tests')
-rw-r--r--ext/spl/tests/ArrayObject_get_object_vars.phpt30
-rw-r--r--ext/spl/tests/DirectoryIterator_getExtension_basic.phpt27
-rw-r--r--ext/spl/tests/DirectoryIterator_getGroup_basic.phpt3
-rw-r--r--ext/spl/tests/DirectoryIterator_getInode_basic.phpt2
-rw-r--r--ext/spl/tests/DirectoryIterator_getInode_error.phpt2
-rw-r--r--ext/spl/tests/DirectoryIterator_getOwner_basic.phpt3
-rw-r--r--ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt26
-rw-r--r--ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt2
-rw-r--r--ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_escape_empty.phpt31
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation15.phpt22
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_basic.phpt6
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_error001.phpt6
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_error002.phpt6
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_error003.phpt8
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt6
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_variation002.phpt19
-rw-r--r--ext/spl/tests/SplFixedArray_fromarray_indexes.phpt2
-rw-r--r--ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt2
-rw-r--r--ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt2
-rw-r--r--ext/spl/tests/SplFixedArray_offsetUnset_string.phpt2
-rw-r--r--ext/spl/tests/SplFixedArray_setsize_001.phpt2
-rw-r--r--ext/spl/tests/SplPriorityQueue_setExtractFlags_zero.phpt15
-rw-r--r--ext/spl/tests/array_017.phpt72
-rw-r--r--ext/spl/tests/bug38618.phpt2
-rw-r--r--ext/spl/tests/bug42364.phpt8
-rw-r--r--ext/spl/tests/bug68825.phpt12
-rw-r--r--ext/spl/tests/class_implements_variation2.phpt259
-rw-r--r--ext/spl/tests/class_uses_variation2.phpt261
-rw-r--r--ext/spl/tests/dualiterator.inc210
-rw-r--r--ext/spl/tests/dualiterator_001.phpt46
-rw-r--r--ext/spl/tests/fileobject_001.phpt6
-rw-r--r--[-rwxr-xr-x]ext/spl/tests/fileobject_001a.txt0
-rw-r--r--[-rwxr-xr-x]ext/spl/tests/fileobject_001b.txt0
-rw-r--r--ext/spl/tests/fileobject_002.phpt4
-rw-r--r--ext/spl/tests/iterator_035.phpt2
-rw-r--r--ext/spl/tests/recursivecomparedualiterator.inc69
-rw-r--r--ext/spl/tests/recursivedualiterator.inc72
-rw-r--r--[-rwxr-xr-x]ext/spl/tests/testclass0
40 files changed, 647 insertions, 604 deletions
diff --git a/ext/spl/tests/ArrayObject_get_object_vars.phpt b/ext/spl/tests/ArrayObject_get_object_vars.phpt
new file mode 100644
index 0000000000..a80add6b95
--- /dev/null
+++ b/ext/spl/tests/ArrayObject_get_object_vars.phpt
@@ -0,0 +1,30 @@
+--TEST--
+get_object_vars() on ArrayObject works on the properties of the ArrayObject itself
+--FILE--
+<?php
+
+class Test {
+ public $test;
+ public $test2;
+}
+
+class AO extends ArrayObject {
+ private $test;
+
+ public function getObjectVars() {
+ return get_object_vars($this);
+ }
+}
+
+$ao = new AO(new Test);
+var_dump(get_object_vars($ao));
+var_dump($ao->getObjectVars());
+
+?>
+--EXPECT--
+array(0) {
+}
+array(1) {
+ ["test"]=>
+ NULL
+}
diff --git a/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt b/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
index 176b73d803..157449c5cd 100644
--- a/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
@@ -1,29 +1,26 @@
--TEST--
SPL: DirectoryIterator::getExtension() basic test
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip.. only for Unix');
-}
-?>
--FILE--
<?php
$dir = __DIR__ . DIRECTORY_SEPARATOR . md5('DirectoryIterator::getExtension') . DIRECTORY_SEPARATOR;
-mkdir($dir);
-$files = array('test.txt', 'test.extension', 'test..', 'test.', 'test');
+if (!mkdir($dir)) {
+ die('Failed to create test directory');
+}
+
+$files = array('test.txt', 'test.extension', 'test');
foreach ($files as $file) {
touch($dir . $file);
}
$dit_exts = array();
$nfo_exts = array();
-$skip = array('.', '..');
foreach (new DirectoryIterator($dir) as $file) {
- if (in_array($file->getFilename(), $skip)) {
+ if ($file->isDot()) {
continue;
}
+
$dit_exts[] = $file->getExtension();
$nfo_exts[] = pathinfo($file->getFilename(), PATHINFO_EXTENSION);
}
@@ -34,7 +31,7 @@ var_dump($dit_exts);
--CLEAN--
<?php
$dir = __DIR__ . DIRECTORY_SEPARATOR . md5('DirectoryIterator::getExtension') . DIRECTORY_SEPARATOR;
-$files = array('test.txt', 'test.extension', 'test..', 'test.', 'test');
+$files = array('test.txt', 'test.extension', 'test');
foreach ($files as $file) {
unlink($dir . $file);
}
@@ -42,15 +39,11 @@ rmdir($dir);
?>
--EXPECT--
bool(true)
-array(5) {
+array(3) {
[0]=>
string(0) ""
[1]=>
- string(0) ""
- [2]=>
- string(0) ""
- [3]=>
string(9) "extension"
- [4]=>
+ [2]=>
string(3) "txt"
}
diff --git a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
index 81ab6c0921..74586b7e0f 100644
--- a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
@@ -2,7 +2,8 @@
SPL: DirectoryIterator test getGroup
--SKIPIF--
<?php
-if (posix_geteuid() == 0) die('SKIP Cannot run test as root.');
+if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file groups, not available for Windows'); }
+if (!extension_loaded('posix') || posix_geteuid() == 0) { die('SKIP Cannot run test as root.'); }
--CREDITS--
Cesare D'Amico <cesare.damico@gruppovolta.it>
Andrea Giorgini <agiorg@gmail.com>
diff --git a/ext/spl/tests/DirectoryIterator_getInode_basic.phpt b/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
index a6b128a222..95d20881bc 100644
--- a/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
@@ -10,7 +10,7 @@ Jacopo Romei <jacopo@sviluppoagile.it>
#Test Fest Cesena (Italy) on 2009-06-20
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file inodes, not available for Windows'); }
?>
--FILE--
<?php
diff --git a/ext/spl/tests/DirectoryIterator_getInode_error.phpt b/ext/spl/tests/DirectoryIterator_getInode_error.phpt
index fd89ecd1ca..42bfa35847 100644
--- a/ext/spl/tests/DirectoryIterator_getInode_error.phpt
+++ b/ext/spl/tests/DirectoryIterator_getInode_error.phpt
@@ -10,7 +10,7 @@ Jacopo Romei <jacopo@sviluppoagile.it>
#Test Fest Cesena (Italy) on 2009-06-20
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file inodes, not available for Windows'); }
?>
--FILE--
<?php
diff --git a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
index 709510d7cf..0981a7d286 100644
--- a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
@@ -2,7 +2,8 @@
SPL: DirectoryIterator test getOwner
--SKIPIF--
<?php
-if (posix_geteuid() == 0) die('SKIP Cannot run test as root.');
+if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file ownership, not available for Windows'); }
+if (!extension_loaded('posix') || posix_geteuid() == 0) die('SKIP Cannot run test as root.');
--CREDITS--
Cesare D'Amico <cesare.damico@gruppovolta.it>
Andrea Giorgini <agiorg@gmail.com>
diff --git a/ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt b/ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt
new file mode 100644
index 0000000000..8c3aad3ef7
--- /dev/null
+++ b/ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SplDoublyLinkedList Iterating a DLL by reference shouldn't be permitted
+--CREDITS--
+Mark Baker mark@lange.demon.co.uk at the PHPNW2017 Conference for PHP Testfest 2017
+--FILE--
+<?php
+
+$dll = new SplDoublyLinkedList();
+
+$dll->push(2);
+$dll->push(3);
+
+try {
+ foreach($dll as $key => &$value) {
+ // We should never see this output, because the "by reference" exception should be thrown in the previous line
+ echo $value, PHP_EOL;
+ $value *= $value;
+ echo $value, PHP_EOL;
+ }
+} catch (Exception $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+
+?>
+--EXPECT--
+An iterator cannot be used with foreach by reference
diff --git a/ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt b/ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt
index 7d8aa7e621..51882c46ce 100644
--- a/ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt
+++ b/ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt
@@ -11,7 +11,7 @@ $list->push('thar');
$list->offsetUnset(0);
var_dump($list);
?>
---EXPECTF--
+--EXPECT--
object(SplDoublyLinkedList)#1 (2) {
["flags":"SplDoublyLinkedList":private]=>
int(0)
diff --git a/ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt b/ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt
index ac3cade344..f6dba97cfd 100644
--- a/ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt
+++ b/ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt
@@ -11,7 +11,7 @@ $list->push('thar');
$list->offsetUnset(2);
var_dump($list);
?>
---EXPECTF--
+--EXPECT--
object(SplDoublyLinkedList)#1 (2) {
["flags":"SplDoublyLinkedList":private]=>
int(0)
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_empty.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_empty.phpt
new file mode 100644
index 0000000000..cbc539c323
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_empty.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SplFileObject::fgetcsv() with empty $escape
+--FILE--
+<?php
+$contents = <<<EOS
+"cell1","cell2\\","cell3","cell4"
+"\\\\\\line1
+line2\\\\\\"
+EOS;
+$file = new SplTempFileObject;
+$file->fwrite($contents);
+$file->rewind();
+while (($data = $file->fgetcsv(',', '"', ''))) {
+ print_r($data);
+}
+?>
+===DONE===
+--EXPECT--
+Array
+(
+ [0] => cell1
+ [1] => cell2\
+ [2] => cell3
+ [3] => cell4
+)
+Array
+(
+ [0] => \\\line1
+line2\\\
+)
+===DONE===
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt
index b49bcdd13c..4873341e5a 100644
--- a/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt
+++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt
@@ -14,5 +14,5 @@ var_dump($fo->fgetcsv(',', '"', 'invalid'));
unlink('SplFileObject__fgetcsv8.csv');
?>
--EXPECTF--
-Warning: SplFileObject::fgetcsv(): escape must be a character in %s on line %d
+Warning: SplFileObject::fgetcsv(): escape must be empty or a single character in %s on line %d
bool(false)
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation15.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation15.phpt
new file mode 100644
index 0000000000..1cde292e28
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation15.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SplFileObject::fputcsv() with empty $escape
+--FILE--
+<?php
+$data = array(
+ ['\\'],
+ ['\\"']
+);
+$file = new SplTempFileObject;
+foreach ($data as $record) {
+ $file->fputcsv($record, ',', '"', '');
+}
+$file->rewind();
+foreach ($file as $line) {
+ echo $line;
+}
+?>
+===DONE===
+--EXPECT--
+\
+"\"""
+===DONE===
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt
index c7f4710868..c2eb623be9 100644
--- a/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt
+++ b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt
@@ -4,14 +4,14 @@ SPL: SplFileObject::setCsvControl basic
Erwin Poeze <erwin.poeze at gmail.com>
--FILE--
<?php
-file_put_contents('csv_control_data.csv',
+file_put_contents('csv_control_data_basic.csv',
<<<CDATA
'groene appelen'|10
'gele bananen'|20
'rode kersen'|30
CDATA
);
-$s = new SplFileObject('csv_control_data.csv');
+$s = new SplFileObject('csv_control_data_basic.csv');
$s->setFlags(SplFileObject::READ_CSV);
$s->setCsvControl('|', '\'', '/');
foreach ($s as $row) {
@@ -21,7 +21,7 @@ foreach ($s as $row) {
?>
--CLEAN--
<?php
-unlink('csv_control_data.csv');
+unlink('csv_control_data_basic.csv');
?>
--EXPECT--
groene appelen : 10
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt
index 384fed5d23..296c4a1aa0 100644
--- a/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt
+++ b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt
@@ -4,20 +4,20 @@ SPL: SplFileObject::setCsvControl error 001
Erwin Poeze <erwin.poeze at gmail.com>
--FILE--
<?php
-file_put_contents('csv_control_data.csv',
+file_put_contents('csv_control_data_error001.csv',
<<<CDATA
'groene appelen'|10
'gele bananen'|20
'rode kersen'|30
CDATA
);
-$s = new SplFileObject('csv_control_data.csv');
+$s = new SplFileObject('csv_control_data_error001.csv');
$s->setFlags(SplFileObject::READ_CSV);
$s->setCsvControl('||');
?>
--CLEAN--
<?php
-unlink('csv_control_data.csv');
+unlink('csv_control_data_error001.csv');
?>
--EXPECTF--
Warning: SplFileObject::setCsvControl(): delimiter must be a character in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt
index 6452212ee7..885d600225 100644
--- a/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt
+++ b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt
@@ -4,20 +4,20 @@ SPL: SplFileObject::setCsvControl error 002
Erwin Poeze <erwin.poeze at gmail.com>
--FILE--
<?php
-file_put_contents('csv_control_data.csv',
+file_put_contents('csv_control_data_error002.csv',
<<<CDATA
'groene appelen'|10
'gele bananen'|20
'rode kersen'|30
CDATA
);
-$s = new SplFileObject('csv_control_data.csv');
+$s = new SplFileObject('csv_control_data_error002.csv');
$s->setFlags(SplFileObject::READ_CSV);
$s->setCsvControl('|', 'two');
?>
--CLEAN--
<?php
-unlink('csv_control_data.csv');
+unlink('csv_control_data_error002.csv');
?>
--EXPECTF--
Warning: SplFileObject::setCsvControl(): enclosure must be a character in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt
index 927172a8dc..9e885cbbe3 100644
--- a/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt
+++ b/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt
@@ -6,20 +6,20 @@ Erwin Poeze <erwin.poeze at gmail.com>
include_path=.
--FILE--
<?php
-file_put_contents('csv_control_data.csv',
+file_put_contents('csv_control_data_error003.csv',
<<<CDATA
'groene appelen'|10
'gele bananen'|20
'rode kersen'|30
CDATA
);
-$s = new SplFileObject('csv_control_data.csv');
+$s = new SplFileObject('csv_control_data_error003.csv');
$s->setFlags(SplFileObject::READ_CSV);
$s->setCsvControl('|', '\'', 'three');
?>
--CLEAN--
<?php
-unlink('csv_control_data.csv');
+unlink('csv_control_data_error003.csv');
?>
--EXPECTF--
-Warning: SplFileObject::setCsvControl(): escape must be a character in %s on line %d
+Warning: SplFileObject::setCsvControl(): escape must be empty or a single character in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt
index c6da6b3d48..f54f8eeabd 100644
--- a/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt
+++ b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt
@@ -4,14 +4,14 @@ SPL: SplFileObject::setCsvControl variation 001
Erwin Poeze <erwin.poeze at gmail.com>
--FILE--
<?php
-file_put_contents('csv_control_data.csv',
+file_put_contents('csv_control_data_variation001.csv',
<<<CDATA
"groene appelen",10
"gele bananen",20
"rode kersen",30
CDATA
);
-$s = new SplFileObject('csv_control_data.csv');
+$s = new SplFileObject('csv_control_data_variation001.csv');
$s->setFlags(SplFileObject::READ_CSV);
$s->setCsvControl();
foreach ($s as $row) {
@@ -21,7 +21,7 @@ foreach ($s as $row) {
?>
--CLEAN--
<?php
-unlink('csv_control_data.csv');
+unlink('csv_control_data_variation001.csv');
?>
--EXPECT--
groene appelen : 10
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_variation002.phpt b/ext/spl/tests/SplFileObject_setCsvControl_variation002.phpt
new file mode 100644
index 0000000000..6d3a76ce94
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_setCsvControl_variation002.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SplFileObject::setCsvControl() and ::getCsvControl() with empty $escape
+--FILE--
+<?php
+$file = new SplTempFileObject;
+$file->setCsvControl(',', '"', '');
+var_dump($file->getCsvControl());
+?>
+===DONE===
+--EXPECT--
+array(3) {
+ [0]=>
+ string(1) ","
+ [1]=>
+ string(1) """
+ [2]=>
+ string(0) ""
+}
+===DONE===
diff --git a/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt b/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt
index ea7022419c..c649e3b6c3 100644
--- a/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt
+++ b/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt
@@ -9,7 +9,7 @@ $array = SplFixedArray::fromArray(array(1 => 1,
3 => false));
var_dump($array);
?>
---EXPECTF--
+--EXPECT--
object(SplFixedArray)#1 (4) {
[0]=>
NULL
diff --git a/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt b/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt
index 10985bbeab..b3e7497397 100644
--- a/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt
+++ b/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt
@@ -10,7 +10,7 @@ $array = SplFixedArray::fromArray(array(1 => 1,
false);
var_dump($array);
?>
---EXPECTF--
+--EXPECT--
object(SplFixedArray)#1 (3) {
[0]=>
int(1)
diff --git a/ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt b/ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt
index b669563db4..e5329e03fc 100644
--- a/ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt
+++ b/ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt
@@ -7,7 +7,7 @@ Philip Norton philipnorton42@gmail.com
$array = SplFixedArray::fromArray(array(array('1')));
var_dump($array);
?>
---EXPECTF--
+--EXPECT--
object(SplFixedArray)#1 (1) {
[0]=>
array(1) {
diff --git a/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt b/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt
index cc054dff3c..3b0e6bb222 100644
--- a/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt
+++ b/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt
@@ -18,7 +18,7 @@ PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
var_dump($fixedArray);
?>
---EXPECTF--
+--EXPECT--
object(SplFixedArray)#1 (5) {
[0]=>
string(14) "PHPNW Testfest"
diff --git a/ext/spl/tests/SplFixedArray_setsize_001.phpt b/ext/spl/tests/SplFixedArray_setsize_001.phpt
index d9c1469ee2..b6fd2f1e4e 100644
--- a/ext/spl/tests/SplFixedArray_setsize_001.phpt
+++ b/ext/spl/tests/SplFixedArray_setsize_001.phpt
@@ -13,7 +13,7 @@ $array[4] = 'five';
$array->setSize(2);
var_dump($array);
?>
---EXPECTF--
+--EXPECT--
object(SplFixedArray)#1 (2) {
[0]=>
string(3) "one"
diff --git a/ext/spl/tests/SplPriorityQueue_setExtractFlags_zero.phpt b/ext/spl/tests/SplPriorityQueue_setExtractFlags_zero.phpt
new file mode 100644
index 0000000000..cf2d339914
--- /dev/null
+++ b/ext/spl/tests/SplPriorityQueue_setExtractFlags_zero.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Setting SplPriorityQueue extract flags to zero generates an exception
+--FILE--
+<?php
+
+$queue = new SplPriorityQueue();
+$queue->setExtractFlags(0);
+
+?>
+--EXPECTF--
+Fatal error: Uncaught RuntimeException: Must specify at least one extract flag in %s:%d
+Stack trace:
+#0 %s(%d): SplPriorityQueue->setExtractFlags(0)
+#1 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/array_017.phpt b/ext/spl/tests/array_017.phpt
index 30d2b70915..3074a76417 100644
--- a/ext/spl/tests/array_017.phpt
+++ b/ext/spl/tests/array_017.phpt
@@ -139,13 +139,17 @@ array(3) {
["Flags"]=>
int(0)
["OVars"]=>
- array(3) {
- [0]=>
- int(1)
- ["a"]=>
- int(25)
+ array(5) {
["pub1"]=>
- int(42)
+ int(1)
+ ["pro1"]=>
+ int(2)
+ ["pri1"]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
}
["$this"]=>
object(ArrayObjectEx)#%d (6) {
@@ -178,13 +182,17 @@ array(3) {
["Flags"]=>
int(0)
["OVars"]=>
- array(3) {
- [0]=>
+ array(5) {
+ ["pub2"]=>
int(1)
- ["a"]=>
- int(25)
- ["pub1"]=>
- int(42)
+ ["pro2"]=>
+ int(2)
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
}
["$this"]=>
object(ArrayIteratorEx)#%d (6) {
@@ -242,13 +250,17 @@ array(3) {
["Flags"]=>
int(0)
["OVars"]=>
- array(3) {
- [0]=>
+ array(5) {
+ ["pub2"]=>
int(1)
- ["a"]=>
- int(25)
- ["pub1"]=>
- int(42)
+ ["pro2"]=>
+ int(2)
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
}
["$this"]=>
object(ArrayIteratorEx)#%d (6) {
@@ -541,14 +553,16 @@ array(3) {
["Flags"]=>
int(0)
["OVars"]=>
- array(4) {
- ["pub1"]=>
+ array(5) {
+ ["pub2"]=>
int(1)
- ["pro1"]=>
+ ["pro2"]=>
int(2)
- ["imp1"]=>
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
int(4)
- ["dyn1"]=>
+ ["dyn2"]=>
int(5)
}
["$this"]=>
@@ -598,14 +612,16 @@ array(3) {
["Flags"]=>
int(0)
["OVars"]=>
- array(4) {
- ["pub1"]=>
+ array(5) {
+ ["pub2"]=>
int(1)
- ["pro1"]=>
+ ["pro2"]=>
int(2)
- ["imp1"]=>
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
int(4)
- ["dyn1"]=>
+ ["dyn2"]=>
int(5)
}
["$this"]=>
diff --git a/ext/spl/tests/bug38618.phpt b/ext/spl/tests/bug38618.phpt
index 95a3da83cc..097d169a98 100644
--- a/ext/spl/tests/bug38618.phpt
+++ b/ext/spl/tests/bug38618.phpt
@@ -1,7 +1,7 @@
--TEST--
Bug #38618 (RecursiveArrayIterator::hasChildren() follows objects)
--FILE--
-<?php # vim:ft=php
+<?php
class FruitPublic
{
diff --git a/ext/spl/tests/bug42364.phpt b/ext/spl/tests/bug42364.phpt
index 971fcc5ebb..139af6113d 100644
--- a/ext/spl/tests/bug42364.phpt
+++ b/ext/spl/tests/bug42364.phpt
@@ -2,10 +2,12 @@
Bug #42364 (Crash when using getRealPath with DirectoryIterator)
--FILE--
<?php
-$it = new DirectoryIterator(dirname(__FILE__));
+$dir = __DIR__ . '/bug42364';
+@mkdir($dir);
+touch($dir . '/test');
$count = 0;
-
+$it = new DirectoryIterator($dir);
foreach ($it as $e) {
$count++;
$type = gettype($e->getRealPath());
@@ -19,6 +21,8 @@ if ($count > 0) {
}
?>
===DONE===
+--CLEAN--
+<?php rmdir(__DIR__ . '/bug42364'); ?>
--EXPECTF--
Found %i entries!
===DONE===
diff --git a/ext/spl/tests/bug68825.phpt b/ext/spl/tests/bug68825.phpt
index b1ed5fb60f..e662503611 100644
--- a/ext/spl/tests/bug68825.phpt
+++ b/ext/spl/tests/bug68825.phpt
@@ -3,12 +3,16 @@ Bug #68825 (Exception in DirectoryIterator::getLinkTarget())
--FILE--
<?php
$dir = __DIR__ . '/bug68825';
-mkdir($dir);
-symlink(__FILE__, "$dir/foo");
+
+if (!mkdir($dir)) {
+ die('Failed to create temporary directory for testing');
+} else if (!symlink(__FILE__, $dir . '/bug')) {
+ die('Failed to create symbolic link');
+}
$di = new \DirectoryIterator($dir);
foreach ($di as $entry) {
- if ('foo' === $entry->getFilename()) {
+ if ('bug' === $entry->getFilename()) {
var_dump($entry->getLinkTarget());
}
}
@@ -20,6 +24,6 @@ string(%d) "%s%eext%espl%etests%ebug68825.php"
--CLEAN--
<?php
$dir = __DIR__ . '/bug68825';
-unlink("$dir/foo");
+unlink($dir . '/bug');
rmdir($dir);
?>
diff --git a/ext/spl/tests/class_implements_variation2.phpt b/ext/spl/tests/class_implements_variation2.phpt
deleted file mode 100644
index d63669fbec..0000000000
--- a/ext/spl/tests/class_implements_variation2.phpt
+++ /dev/null
@@ -1,259 +0,0 @@
---TEST--
-SPL: Test class_implements() function : variation
---FILE--
-<?php
-/* Prototype : array class_implements(mixed what [, bool autoload ])
- * Description: Return all classes and interfaces implemented by SPL
- * Source code: ext/spl/php_spl.c
- * Alias to functions:
- */
-
-echo "*** Testing class_implements() : variation ***\n";
-
-
-// Define error handler
-function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
- if (error_reporting() != 0) {
- // report non-silenced errors
- echo "Error: $err_no - $err_msg, $filename($linenum)\n";
- }
-}
-set_error_handler('test_error_handler');
-
-// Initialise function arguments not being substituted (if any)
-$class = 'Iterator';
-
-//resource
-$res = fopen(__FILE__,'r');
-
-//get an unset variable
-$unset_var = 10;
-unset ($unset_var);
-
-// define some classes
-class classWithToString
-{
- public function __toString() {
- return "Class A object";
- }
-}
-
-class classWithoutToString
-{
-}
-
-// heredoc string
-$heredoc = <<<EOT
-hello world
-EOT;
-
-// add arrays
-$index_array = array (1, 2, 3);
-$assoc_array = array ('one' => 1, 'two' => 2);
-
-//array of values to iterate over
-$inputs = array(
-
- // int data
- 'int 0' => 0,
- 'int 1' => 1,
- 'int 12345' => 12345,
- 'int -12345' => -2345,
-
- // float data
- 'float 10.5' => 10.5,
- 'float -10.5' => -10.5,
- 'float 12.3456789000e10' => 12.3456789000e10,
- 'float -12.3456789000e10' => -12.3456789000e10,
- 'float .5' => .5,
-
- // array data
- 'empty array' => array(),
- 'int indexed array' => $index_array,
- 'associative array' => $assoc_array,
- 'nested arrays' => array('foo', $index_array, $assoc_array),
-
- // null data
- 'uppercase NULL' => NULL,
- 'lowercase null' => null,
-
- // boolean data
- 'lowercase true' => true,
- 'lowercase false' =>false,
- 'uppercase TRUE' =>TRUE,
- 'uppercase FALSE' =>FALSE,
-
- // empty data
- 'empty string DQ' => "",
- 'empty string SQ' => '',
-
- // object data
- 'instance of classWithToString' => new classWithToString(),
- 'instance of classWithoutToString' => new classWithoutToString(),
-
- // undefined data
- 'undefined var' => @$undefined_var,
-
- // unset data
- 'unset var' => @$unset_var,
-
- //resource
- 'resource' => $res,
-);
-
-// loop through each element of the array for pattern
-
-foreach($inputs as $key =>$value) {
- echo "\n--$key--\n";
- var_dump( class_implements($class, $value) );
-};
-
-fclose($res);
-
-?>
-===DONE===
---EXPECTF--
-*** Testing class_implements() : variation ***
-
---int 0--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---int 1--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---int 12345--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---int -12345--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---float 10.5--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---float -10.5--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---float 12.3456789000e10--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---float -12.3456789000e10--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---float .5--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---empty array--
-Error: 2 - class_implements() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---int indexed array--
-Error: 2 - class_implements() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---associative array--
-Error: 2 - class_implements() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---nested arrays--
-Error: 2 - class_implements() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---uppercase NULL--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---lowercase null--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---lowercase true--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---lowercase false--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---uppercase TRUE--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---uppercase FALSE--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---empty string DQ--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---empty string SQ--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---instance of classWithToString--
-Error: 2 - class_implements() expects parameter 2 to be bool, object given, %s(%d)
-bool(false)
-
---instance of classWithoutToString--
-Error: 2 - class_implements() expects parameter 2 to be bool, object given, %s(%d)
-bool(false)
-
---undefined var--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---unset var--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---resource--
-Error: 2 - class_implements() expects parameter 2 to be bool, resource given, %s(%d)
-bool(false)
-===DONE===
diff --git a/ext/spl/tests/class_uses_variation2.phpt b/ext/spl/tests/class_uses_variation2.phpt
deleted file mode 100644
index 6458bd178c..0000000000
--- a/ext/spl/tests/class_uses_variation2.phpt
+++ /dev/null
@@ -1,261 +0,0 @@
---TEST--
-SPL: Test class_uses() function : variation
---FILE--
-<?php
-/* Prototype : array class_uses(mixed what [, bool autoload ])
- * Description: Return all traits used by a class
- * Source code: ext/spl/php_spl.c
- * Alias to functions:
- */
-
-echo "*** Testing class_uses() : variation ***\n";
-
-trait foo {}
-class fooUser { use foo; }
-
-// Define error handler
-function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
- if (error_reporting() != 0) {
- // report non-silenced errors
- echo "Error: $err_no - $err_msg, $filename($linenum)\n";
- }
-}
-set_error_handler('test_error_handler');
-
-// Initialise function arguments not being substituted (if any)
-$class = 'fooUser';
-
-//resource
-$res = fopen(__FILE__,'r');
-
-//get an unset variable
-$unset_var = 10;
-unset ($unset_var);
-
-// define some classes
-class classWithToString
-{
- public function __toString() {
- return "Class A object";
- }
-}
-
-class classWithoutToString
-{
-}
-
-// heredoc string
-$heredoc = <<<EOT
-hello world
-EOT;
-
-// add arrays
-$index_array = array (1, 2, 3);
-$assoc_array = array ('one' => 1, 'two' => 2);
-
-//array of values to iterate over
-$inputs = array(
-
- // int data
- 'int 0' => 0,
- 'int 1' => 1,
- 'int 12345' => 12345,
- 'int -12345' => -2345,
-
- // float data
- 'float 10.5' => 10.5,
- 'float -10.5' => -10.5,
- 'float 12.3456789000e10' => 12.3456789000e10,
- 'float -12.3456789000e10' => -12.3456789000e10,
- 'float .5' => .5,
-
- // array data
- 'empty array' => array(),
- 'int indexed array' => $index_array,
- 'associative array' => $assoc_array,
- 'nested arrays' => array('foo', $index_array, $assoc_array),
-
- // null data
- 'uppercase NULL' => NULL,
- 'lowercase null' => null,
-
- // boolean data
- 'lowercase true' => true,
- 'lowercase false' =>false,
- 'uppercase TRUE' =>TRUE,
- 'uppercase FALSE' =>FALSE,
-
- // empty data
- 'empty string DQ' => "",
- 'empty string SQ' => '',
-
- // object data
- 'instance of classWithToString' => new classWithToString(),
- 'instance of classWithoutToString' => new classWithoutToString(),
-
- // undefined data
- 'undefined var' => @$undefined_var,
-
- // unset data
- 'unset var' => @$unset_var,
-
- //resource
- 'resource' => $res,
-);
-
-// loop through each element of the array for pattern
-
-foreach($inputs as $key =>$value) {
- echo "\n--$key--\n";
- var_dump( class_uses($class, $value) );
-};
-
-fclose($res);
-
-?>
-===DONE===
---EXPECTF--
-*** Testing class_uses() : variation ***
-
---int 0--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---int 1--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---int 12345--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---int -12345--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---float 10.5--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---float -10.5--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---float 12.3456789000e10--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---float -12.3456789000e10--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---float .5--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---empty array--
-Error: 2 - class_uses() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---int indexed array--
-Error: 2 - class_uses() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---associative array--
-Error: 2 - class_uses() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---nested arrays--
-Error: 2 - class_uses() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---uppercase NULL--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---lowercase null--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---lowercase true--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---lowercase false--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---uppercase TRUE--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---uppercase FALSE--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---empty string DQ--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---empty string SQ--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---instance of classWithToString--
-Error: 2 - class_uses() expects parameter 2 to be bool, object given, %s(%d)
-bool(false)
-
---instance of classWithoutToString--
-Error: 2 - class_uses() expects parameter 2 to be bool, object given, %s(%d)
-bool(false)
-
---undefined var--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---unset var--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---resource--
-Error: 2 - class_uses() expects parameter 2 to be bool, resource given, %s(%d)
-bool(false)
-===DONE===
diff --git a/ext/spl/tests/dualiterator.inc b/ext/spl/tests/dualiterator.inc
new file mode 100644
index 0000000000..eeb8ae869c
--- /dev/null
+++ b/ext/spl/tests/dualiterator.inc
@@ -0,0 +1,210 @@
+<?php
+
+/** @file dualiterator.inc
+ * @ingroup Examples
+ * @brief class DualIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2006
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief Synchronous iteration over two iterators
+ * @author Marcus Boerger
+ * @version 1.3
+ */
+class DualIterator implements Iterator
+{
+ const CURRENT_LHS = 0x01;
+ const CURRENT_RHS = 0x02;
+ const CURRENT_ARRAY = 0x03;
+ const CURRENT_0 = 0x00;
+
+ const KEY_LHS = 0x10;
+ const KEY_RHS = 0x20;
+ const KEY_0 = 0x00;
+
+ const DEFAULT_FLAGS = 0x13;
+
+ private $lhs;
+ private $rhs;
+ private $flags;
+
+ /** construct iterator from two iterators
+ *
+ * @param lhs Left Hand Side Iterator
+ * @param rhs Right Hand Side Iterator
+ * @param flags iteration flags
+ */
+ function __construct(Iterator $lhs, Iterator $rhs,
+ $flags = 0x13 /*DualIterator::DEFAULT_FLAGS*/)
+ {
+ $this->lhs = $lhs;
+ $this->rhs = $rhs;
+ $this->flags = $flags;
+ }
+
+ /** @return Left Hand Side Iterator
+ */
+ function getLHS()
+ {
+ return $this->lhs;
+ }
+
+ /** @return Right Hand Side Iterator
+ */
+ function getRHS()
+ {
+ return $this->rhs;
+ }
+
+ /** @param flags new flags
+ */
+ function setFlags($flags)
+ {
+ $this->flags = $flags;
+ }
+
+ /** @return current flags
+ */
+ function getFlags()
+ {
+ return $this->flags;
+ }
+
+ /** rewind both inner iterators
+ */
+ function rewind()
+ {
+ $this->lhs->rewind();
+ $this->rhs->rewind();
+ }
+
+ /** @return whether both inner iterators are valid
+ */
+ function valid()
+ {
+ return $this->lhs->valid() && $this->rhs->valid();
+ }
+
+ /** @return current value depending on CURRENT_* flags
+ */
+ function current()
+ {
+ switch($this->flags & 0x0F)
+ {
+ default:
+ case self::CURRENT_ARRAY:
+ return array($this->lhs->current(), $this->rhs->current());
+ case self::CURRENT_LHS:
+ return $this->lhs->current();
+ case self::CURRENT_RHS:
+ return $this->rhs->current();
+ case self::CURRENT_0:
+ return NULL;
+ }
+ }
+
+ /** @return key value depending on KEY_* flags
+ */
+ function key()
+ {
+ switch($this->flags & 0xF0)
+ {
+ default:
+ case self::KEY_LHS:
+ return $this->lhs->key();
+ case self::KEY_RHS:
+ return $this->rhs->key();
+ case self::KEY_0:
+ return NULL;
+ }
+ }
+
+ /** move both inner iterators forward
+ */
+ function next()
+ {
+ $this->lhs->next();
+ $this->rhs->next();
+ }
+
+ /** @return whether both inner iterators are valid and have identical
+ * current and key values or both are non valid.
+ */
+ function areIdentical()
+ {
+ return $this->valid()
+ ? $this->lhs->current() === $this->rhs->current()
+ && $this->lhs->key() === $this->rhs->key()
+ : $this->lhs->valid() == $this->rhs->valid();
+ }
+
+ /** @return whether both inner iterators are valid and have equal current
+ * and key values or both are non valid.
+ */
+ function areEqual()
+ {
+ return $this->valid()
+ ? $this->lhs->current() == $this->rhs->current()
+ && $this->lhs->key() == $this->rhs->key()
+ : $this->lhs->valid() == $this->rhs->valid();
+ }
+
+ /** Compare two iterators
+ *
+ * @param lhs Left Hand Side Iterator
+ * @param rhs Right Hand Side Iterator
+ * @param identical whether to use areEqual() or areIdentical()
+ * @return whether both iterators are equal/identical
+ *
+ * @note If one implements RecursiveIterator the other must do as well.
+ * And if both do then a recursive comparison is being used.
+ */
+ static function compareIterators(Iterator $lhs, Iterator $rhs,
+ $identical = false)
+ {
+ if ($lhs instanceof RecursiveIterator)
+ {
+ if ($rhs instanceof RecursiveIterator)
+ {
+ $it = new RecursiveDualIterator($lhs, $rhs,
+ self::CURRENT_0 | self::KEY_0);
+ $it = new RecursiveCompareDualIterator($it);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ $it = new DualIterator($lhs, $rhs, self::CURRENT_0 | self::KEY_0);
+ }
+
+ if ($identical)
+ {
+ foreach($it as $n)
+ {
+ if (!$it->areIdentical())
+ {
+ return false;
+ }
+ }
+ }
+ else
+ {
+ foreach($it as $n)
+ {
+ if (!$it->areEqual())
+ {
+ return false;
+ }
+ }
+ }
+ return $identical ? $it->areIdentical() : $it->areEqual();
+ }
+}
+
+?>
diff --git a/ext/spl/tests/dualiterator_001.phpt b/ext/spl/tests/dualiterator_001.phpt
new file mode 100644
index 0000000000..dd75ca9463
--- /dev/null
+++ b/ext/spl/tests/dualiterator_001.phpt
@@ -0,0 +1,46 @@
+--TEST--
+SPL: DualIterator
+--FILE--
+<?php
+
+function spl_examples_autoload($classname)
+{
+ include(dirname(__FILE__) . '/' . strtolower($classname) . '.inc');
+}
+
+spl_autoload_register('spl_examples_autoload');
+
+function test($a, $b, $identical = false)
+{
+ var_dump(DualIterator::compareIterators(
+ new RecursiveArrayIterator($a),
+ new RecursiveArrayIterator($b),
+ $identical));
+}
+
+test(array(1,2,3), array(1,2,3));
+test(array(1,2,3), array(1,2));
+test(array(1,array(21,22),3), array(1,array(21,22),3));
+test(array(1,array(21,22),3), array(1,array(21,22,23),3));
+test(array(1,array(21,22),3), array(1,array(21,22,3)));
+test(array(1,array(21,22),3), array(1,array(21),array(22),3));
+test(array(1,2,3), array(1,"2",3), false);
+test(array(1,2,3), array(1,"2",3), true);
+test(array(1,array(21,22),3), array(1,array(21,"22"),3), false);
+test(array(1,array(21,22),3), array(1,array(21,"22"),3), true);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/fileobject_001.phpt b/ext/spl/tests/fileobject_001.phpt
index 61f688d79f..35a5156401 100644
--- a/ext/spl/tests/fileobject_001.phpt
+++ b/ext/spl/tests/fileobject_001.phpt
@@ -40,12 +40,12 @@ foreach($o as $n => $l)
?>
===DONE===
---EXPECT--
+--EXPECTF--
int(0)
-string(2) "0
+string(%d) "0
"
int(0)
-string(2) "0
+string(%d) "0
"
int(0)
int(1)
diff --git a/ext/spl/tests/fileobject_001a.txt b/ext/spl/tests/fileobject_001a.txt
index e8371f0060..e8371f0060 100755..100644
--- a/ext/spl/tests/fileobject_001a.txt
+++ b/ext/spl/tests/fileobject_001a.txt
diff --git a/ext/spl/tests/fileobject_001b.txt b/ext/spl/tests/fileobject_001b.txt
index 0c4a8b5cd3..0c4a8b5cd3 100755..100644
--- a/ext/spl/tests/fileobject_001b.txt
+++ b/ext/spl/tests/fileobject_001b.txt
diff --git a/ext/spl/tests/fileobject_002.phpt b/ext/spl/tests/fileobject_002.phpt
index 8031e98fdc..1f7e4eaf14 100644
--- a/ext/spl/tests/fileobject_002.phpt
+++ b/ext/spl/tests/fileobject_002.phpt
@@ -12,6 +12,10 @@ function test($name)
var_dump($o->key());
while(($c = $o->fgetc()) !== false)
{
+ // Kinda ugly but works around new lines mess
+ if ($c === "\r") {
+ continue;
+ }
var_dump($o->key(), $c, $o->eof());
}
echo "===EOF?===\n";
diff --git a/ext/spl/tests/iterator_035.phpt b/ext/spl/tests/iterator_035.phpt
index e6d68fbea6..0688635450 100644
--- a/ext/spl/tests/iterator_035.phpt
+++ b/ext/spl/tests/iterator_035.phpt
@@ -14,7 +14,7 @@ echo "Done\n";
--EXPECTF--
Notice: Indirect modification of overloaded element of ArrayIterator has no effect in %s on line %d
-Fatal error: Uncaught Error: Cannot assign by reference to overloaded object in %s:%d
+Fatal error: Uncaught Error: Cannot assign by reference to an array dimension of an object in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
diff --git a/ext/spl/tests/recursivecomparedualiterator.inc b/ext/spl/tests/recursivecomparedualiterator.inc
new file mode 100644
index 0000000000..5b63e9f0b3
--- /dev/null
+++ b/ext/spl/tests/recursivecomparedualiterator.inc
@@ -0,0 +1,69 @@
+<?php
+
+/** @file recursivecomparedualiterator.inc
+ * @ingroup Examples
+ * @brief class DualIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2006
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief Recursive comparison iterator for a RecursiveDualIterator
+ * @author Marcus Boerger
+ * @version 1.0
+ */
+class RecursiveCompareDualIterator extends RecursiveIteratorIterator
+{
+ /** Used to keep end of recursion equality. That is en leaving a nesting
+ * level we need to check whether both child iterators are at their end.
+ */
+ protected $equal = false;
+
+ /** Construct from RecursiveDualIterator
+ *
+ * @param $it RecursiveDualIterator
+ * @param $mode should be LEAVES_ONLY
+ * @param $flags should be 0
+ */
+ function __construct(RecursiveDualIterator $it, $mode = self::LEAVES_ONLY, $flags = 0)
+ {
+ parent::__construct($it);
+ }
+
+ /** Rewind iteration andcomparison process. Starting with $equal = true.
+ */
+ function rewind()
+ {
+ $this->equal = true;
+ parent::rewind();
+ }
+
+ /** Calculate $equal
+ * @see $equal
+ */
+ function endChildren()
+ {
+ $this->equal &= !$this->getInnerIterator()->getLHS()->valid()
+ && !$this->getInnerIterator()->getRHS()->valid();
+ }
+
+ /** @return whether both inner iterators are valid and have identical
+ * current and key values or both are non valid.
+ */
+ function areIdentical()
+ {
+ return $this->equal && $this->getInnerIterator()->areIdentical();
+ }
+
+ /** @return whether both inner iterators are valid and have equal current
+ * and key values or both are non valid.
+ */
+ function areEqual()
+ {
+ return $this->equal && $this->getInnerIterator()->areEqual();
+ }
+}
+
+?>
diff --git a/ext/spl/tests/recursivedualiterator.inc b/ext/spl/tests/recursivedualiterator.inc
new file mode 100644
index 0000000000..a56984e083
--- /dev/null
+++ b/ext/spl/tests/recursivedualiterator.inc
@@ -0,0 +1,72 @@
+<?php
+
+/** @file recursivedualiterator.inc
+ * @ingroup Examples
+ * @brief class RecursiveDualIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2006
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief Synchronous iteration over two recursive iterators
+ * @author Marcus Boerger
+ * @version 1.0
+ */
+class RecursiveDualIterator extends DualIterator implements RecursiveIterator
+{
+ private $ref;
+
+ /** construct iterator from two RecursiveIterator instances
+ *
+ * @param lhs Left Hand Side Iterator
+ * @param rhs Right Hand Side Iterator
+ * @param flags iteration flags
+ */
+ function __construct(RecursiveIterator $lhs, RecursiveIterator $rhs,
+ $flags = 0x33 /*DualIterator::DEFAULT_FLAGS*/)
+ {
+ parent::__construct($lhs, $rhs, $flags);
+ }
+
+ /** @return whether both LHS and RHS have children
+ */
+ function hasChildren()
+ {
+ return $this->getLHS()->hasChildren() && $this->getRHS()->hasChildren();
+ }
+
+ /** @return new RecursiveDualIterator (late binding) for the two inner
+ * iterators current children.
+ */
+ function getChildren()
+ {
+ if (empty($this->ref))
+ {
+ $this->ref = new ReflectionClass($this);
+ }
+ return $this->ref->newInstance(
+ $this->getLHS()->getChildren(), $this->getRHS()->getChildren(), $this->getFlags());
+ }
+
+ /** @return whether both inner iterators are valid, have same hasChildren()
+ * state and identical current and key values or both are non valid.
+ */
+ function areIdentical()
+ {
+ return $this->getLHS()->hasChildren() === $this->getRHS()->hasChildren()
+ && parent::areIdentical();
+ }
+
+ /** @return whether both inner iterators are valid, have same hasChildren()
+ * state and equal current and key values or both are invalid.
+ */
+ function areEqual()
+ {
+ return $this->getLHS()->hasChildren() === $this->getRHS()->hasChildren()
+ && parent::areEqual();
+ }
+}
+
+?>
diff --git a/ext/spl/tests/testclass b/ext/spl/tests/testclass
index ceb24c877c..ceb24c877c 100755..100644
--- a/ext/spl/tests/testclass
+++ b/ext/spl/tests/testclass