diff options
author | SVN Migration <svn@php.net> | 2005-06-10 18:06:44 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2005-06-10 18:06:44 +0000 |
commit | 02889a1980340caaa4f2450c834da87fb675f848 (patch) | |
tree | 2e0b0f07f6810a635d5ecba89f63b6bfb63126f8 /ext/spl/tests | |
parent | 3b1f8e9ad74ad07580e4248b39fd0db261c31aa0 (diff) | |
download | php-git-php-5.0.1b1.tar.gz |
This commit was manufactured by cvs2svn to create tag 'php_5_0_1b1'.php-5.0.1b1
Diffstat (limited to 'ext/spl/tests')
66 files changed, 0 insertions, 4344 deletions
diff --git a/ext/spl/tests/.htaccess b/ext/spl/tests/.htaccess deleted file mode 100755 index 5a01a1c16e..0000000000 --- a/ext/spl/tests/.htaccess +++ /dev/null @@ -1,3 +0,0 @@ -<IfModule mod_autoindex.c> - IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t *.php -</IfModule> diff --git a/ext/spl/tests/array_001.phpt b/ext/spl/tests/array_001.phpt deleted file mode 100755 index 1c7566ecb9..0000000000 --- a/ext/spl/tests/array_001.phpt +++ /dev/null @@ -1,103 +0,0 @@ ---TEST-- -SPL: ArrayObject ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -$ar = array(0=>0, 1=>1); -$ar = new ArrayObject($ar); - -var_dump($ar); - -$ar[2] = 2; -var_dump($ar[2]); -var_dump($ar["3"] = 3); - -var_dump(array_merge((array)$ar, array(4=>4, 5=>5))); - -var_dump($ar["a"] = "a"); - -var_dump($ar); -var_dump($ar[0]); -var_dump($ar[6]); -var_dump($ar["b"]); - -unset($ar[1]); -unset($ar["3"]); -unset($ar["a"]); -unset($ar[7]); -unset($ar["c"]); -var_dump($ar); - -$ar[] = '3'; -$ar[] = 4; -var_dump($ar); - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -object(ArrayObject)#1 (2) { - [0]=> - int(0) - [1]=> - int(1) -} -int(2) -int(3) -array(6) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [3]=> - int(3) - [4]=> - int(4) - [5]=> - int(5) -} -string(1) "a" -object(ArrayObject)#1 (5) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [3]=> - int(3) - ["a"]=> - string(1) "a" -} -int(0) - -Notice: Undefined offset: 6 in %sarray_001.php on line %d -NULL - -Notice: Undefined index: b in %sarray_001.php on line %d -NULL - -Notice: Undefined offset: 7 in %sarray_001.php on line %d - -Notice: Undefined index: c in %sarray_001.php on line %d -object(ArrayObject)#1 (2) { - [0]=> - int(0) - [2]=> - int(2) -} -object(ArrayObject)#1 (4) { - [0]=> - int(0) - [2]=> - int(2) - [4]=> - string(1) "3" - [5]=> - int(4) -} -===DONE=== diff --git a/ext/spl/tests/array_002.phpt b/ext/spl/tests/array_002.phpt deleted file mode 100755 index 960253f335..0000000000 --- a/ext/spl/tests/array_002.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -SPL: ArrayObject copy constructor ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -$array = array('1' => 'one', - '2' => 'two', - '3' => 'three'); - -$object = new ArrayObject($array); -$object[] = 'four'; - -$arrayObject = new ArrayObject($object); - -$arrayObject[] = 'five'; - -var_dump($arrayObject); - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -object(ArrayObject)#%d (5) { - [1]=> - string(3) "one" - [2]=> - string(3) "two" - [3]=> - string(5) "three" - [4]=> - string(4) "four" - [5]=> - string(4) "five" -} -===DONE=== diff --git a/ext/spl/tests/array_003.phpt b/ext/spl/tests/array_003.phpt deleted file mode 100755 index 386c7bcf7d..0000000000 --- a/ext/spl/tests/array_003.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -SPL: ArrayObject from object ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -// This test also needs to exclude the protected and private variables -// since they cannot be accessed from the external object which iterates -// them. - -class test -{ - public $pub = "public"; - protected $pro = "protected"; - private $pri = "private"; - - function __construct() - { - $this->imp = "implicit"; - } -}; - -$test = new test; -$test->dyn = "dynamic"; - -print_r($test); - -$object = new ArrayObject($test); - -print_r($object); - -foreach($test as $key => $val) -{ - echo "$key => $val\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -test Object -( - [pub] => public - [pro:protected] => protected - [pri:private] => private - [imp] => implicit - [dyn] => dynamic -) -ArrayObject Object -( - [pub] => public - [pro:protected] => protected - [pri:private] => private - [imp] => implicit - [dyn] => dynamic -) -pub => public -imp => implicit -dyn => dynamic -===DONE=== diff --git a/ext/spl/tests/array_004.phpt b/ext/spl/tests/array_004.phpt deleted file mode 100755 index e7abf2b1dc..0000000000 --- a/ext/spl/tests/array_004.phpt +++ /dev/null @@ -1,143 +0,0 @@ ---TEST-- -SPL: ArrayIterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---INI-- -allow_call_time_pass_reference=1 ---FILE-- -<?php - -echo "==Normal==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new ArrayObject($arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==0 && $bk==0) { - $arr[0] = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==UseRef==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new ArrayObject(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==0 && $bk==0) { - $arr[0] = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==Modify==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new ArrayObject(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==0 && $bk==0) { - $arr[0] = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==Delete==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new ArrayObject(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==1 && $bk==1) { - unset($arr[1]); - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==Change==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new ArrayObject(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==1 && $bk==1) { - $arr = NULL; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "Done\n"; -?> ---EXPECTF-- -==Normal== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>0 -1=>1 - 1=>1 -1=>1 - 2=>2 -2=>2 - 0=>0 -2=>2 - 1=>1 -2=>2 - 2=>2 -==UseRef== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>modify -1=>1 - 1=>1 -1=>1 - 2=>2 -2=>2 - 0=>modify -2=>2 - 1=>1 -2=>2 - 2=>2 -==Modify== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>modify -1=>1 - 1=>1 -1=>1 - 2=>2 -2=>2 - 0=>modify -2=>2 - 1=>1 -2=>2 - 2=>2 -==Delete== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>0 -1=>1 - 1=>1 - -Notice: main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_004.php on line %d -1=>1 - 0=>0 -1=>1 - 2=>2 - -Notice: main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_004.php on line %d -0=>0 - 0=>0 -0=>0 - 2=>2 -2=>2 - 0=>0 -2=>2 - 2=>2 -==Change== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>0 -1=>1 - 1=>1 - -Notice: main(): ArrayIterator::current(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d - -Notice: main(): ArrayIterator::valid(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d - -Notice: main(): ArrayIterator::current(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d - -Notice: main(): ArrayIterator::valid(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d -Done diff --git a/ext/spl/tests/array_005.phpt b/ext/spl/tests/array_005.phpt deleted file mode 100755 index 9214a4c92b..0000000000 --- a/ext/spl/tests/array_005.phpt +++ /dev/null @@ -1,93 +0,0 @@ ---TEST-- -SPL: ArrayObject/Iterator interaction ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -class Student -{ - private $id; - private $name; - - public function __construct($id, $name) - { - $this->id = $id; - $this->name = $name; - } - - public function __toString() - { - return $this->id . ', ' . $this->name; - } - - public function getId() - { - return $this->id; - } -} - -class StudentIdFilter extends FilterIterator -{ - private $id; - - public function __construct(ArrayObject $students, Student $other) - { - FilterIterator::__construct($students->getIterator()); - $this->id = $other->getId(); - } - - public function accept() - { - echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n"; - return $this->current()->getId() == $this->id; - } -} - -class StudentList implements IteratorAggregate -{ - private $students; - - public function __construct() - { - $this->students = new ArrayObject(array()); - } - - public function add(Student $student) - { - if (!$this->contains($student)) { - $this->students[] = $student; - } - } - - public function contains(Student $student) - { - foreach ($this->students as $s) - { - if ($s->getId() == $student->getId()) { - return true; - } - } - return false; - } - - public function getIterator() { - return $this->students->getIterator(); - } -} - -$students = new StudentList(); -$students->add(new Student('01234123', 'Joe')); -$students->add(new Student('00000014', 'Bob')); -$students->add(new Student('00000014', 'Foo')); - -foreach ($students as $student) { - echo $student, "\n"; -} -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -01234123, Joe -00000014, Bob -===DONE=== diff --git a/ext/spl/tests/array_006.phpt b/ext/spl/tests/array_006.phpt deleted file mode 100755 index 5dd9bdec7a..0000000000 --- a/ext/spl/tests/array_006.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -SPL: ArrayIterator without ArrayObject ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---INI-- -allow_call_time_pass_reference=1 ---FILE-- -<?php - -echo "==Normal==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new ArrayIterator($arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==0 && $bk==0) { - $arr[0] = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -==Normal== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -===DONE=== diff --git a/ext/spl/tests/array_007.phpt b/ext/spl/tests/array_007.phpt deleted file mode 100755 index 3e74e00da4..0000000000 --- a/ext/spl/tests/array_007.phpt +++ /dev/null @@ -1,65 +0,0 @@ ---TEST-- -SPL: ArrayObject/Iterator from IteratorAggregate ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -// This test also needs to exclude the protected and private variables -// since they cannot be accessed from the external object which iterates -// them. - -class test implements IteratorAggregate -{ - public $pub = "public"; - protected $pro = "protected"; - private $pri = "private"; - - function __construct() - { - $this->imp = "implicit"; - } - - function getIterator() - { - $it = new ArrayObject($this); - return $it->getIterator(); - } -}; - -$test = new test; -$test->dyn = "dynamic"; - -print_r($test); - -print_r($test->getIterator()); - -foreach($test as $key => $val) -{ - echo "$key => $val\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -test Object -( - [pub] => public - [pro:protected] => protected - [pri:private] => private - [imp] => implicit - [dyn] => dynamic -) -ArrayIterator Object -( - [pub] => public - [pro:protected] => protected - [pri:private] => private - [imp] => implicit - [dyn] => dynamic -) -pub => public -imp => implicit -dyn => dynamic -===DONE=== diff --git a/ext/spl/tests/array_008.phpt b/ext/spl/tests/array_008.phpt deleted file mode 100755 index 613e324776..0000000000 --- a/ext/spl/tests/array_008.phpt +++ /dev/null @@ -1,62 +0,0 @@ ---TEST-- -SPL: ArrayIterator and foreach reference ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---INI-- -allow_call_time_pass_reference=1 ---FILE-- -<?php - -echo "==Normal==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new ArrayObject($arr); - -foreach($obj as $ak=>&$av) { - foreach($obj as $bk=>&$bv) { - if ($ak==0 && $bk==0) { - $bv = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==UseRef==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new ArrayObject(&$arr); - -foreach($obj as $ak=>&$av) { - foreach($obj as $bk=>&$bv) { - if ($ak==0 && $bk==0) { - $bv = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -==Normal== -0=>modify - 0=>modify -0=>modify - 1=>1 -0=>modify - 2=>2 -1=>1 - 0=>modify -1=>1 - 1=>1 -1=>1 - 2=>2 -2=>2 - 0=>modify -2=>2 - 1=>1 -2=>2 - 2=>2 -==UseRef== -0=>modify - 0=>modify -0=>modify - 1=>1 -0=>modify - 2=>2 -1=>1 - 0=>modify -1=>1 - 1=>1 -1=>1 - 2=>2 -2=>2 - 0=>modify -2=>2 - 1=>1 -2=>2 - 2=>2 -===DONE=== diff --git a/ext/spl/tests/array_009.phpt b/ext/spl/tests/array_009.phpt deleted file mode 100755 index 5499caad69..0000000000 --- a/ext/spl/tests/array_009.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -SPL: ArrayIterator implementing RecursiveIterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -class RecursiceArrayIterator extends ArrayIterator implements RecursiveIterator -{ - function hasChildren() - { - return is_array($this->current()); - } - - function getChildren() - { - return new RecursiceArrayIterator($this->current()); - } -} - -$array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3); - -$dir = new RecursiveIteratorIterator(new RecursiceArrayIterator($array), RIT_LEAVES_ONLY); - -foreach ($dir as $file) { - print "$file\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -1 -21 -221 -222 -231 -3 -===DONE=== diff --git a/ext/spl/tests/array_010.phpt b/ext/spl/tests/array_010.phpt deleted file mode 100755 index dae6b93d6d..0000000000 --- a/ext/spl/tests/array_010.phpt +++ /dev/null @@ -1,146 +0,0 @@ ---TEST-- -SPL: ArrayIterator implements ArrayAccess ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -$obj = new ArrayObject(array('1st', 1, 2=>'3rd', '4th'=>4)); - -var_dump($obj->getArrayCopy()); - -echo "===EMPTY===\n"; -var_dump(empty($obj[0])); -var_dump(empty($obj[1])); -var_dump(empty($obj[2])); -var_dump(empty($obj['4th'])); -var_dump(empty($obj['5th'])); -var_dump(empty($obj[6])); - -echo "===isset===\n"; -var_dump(isset($obj[0])); -var_dump(isset($obj[1])); -var_dump(isset($obj[2])); -var_dump(isset($obj['4th'])); -var_dump(isset($obj['5th'])); -var_dump(isset($obj[6])); - -echo "===offsetGet===\n"; -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -echo "===offsetSet===\n"; -echo "WRITE 1\n"; -$obj[1] = 'Changed 1'; -var_dump($obj[1]); -echo "WRITE 2\n"; -$obj['4th'] = 'Changed 4th'; -var_dump($obj['4th']); -echo "WRITE 3\n"; -$obj['5th'] = 'Added 5th'; -var_dump($obj['5th']); -echo "WRITE 4\n"; -$obj[6] = 'Added 6'; -var_dump($obj[6]); - -var_dump($obj[0]); -var_dump($obj[2]); - -$x = $obj[6] = 'changed 6'; -var_dump($obj[6]); -var_dump($x); - -echo "===unset===\n"; -var_dump($obj->getArrayCopy()); -unset($obj[2]); -unset($obj['4th']); -unset($obj[7]); -unset($obj['8th']); -var_dump($obj->getArrayCopy()); - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -===EMPTY=== -bool(false) -bool(false) -bool(false) -bool(false) -bool(true) -bool(true) -===isset=== -bool(true) -bool(true) -bool(true) -bool(true) -bool(false) -bool(false) -===offsetGet=== -string(3) "1st" -int(1) -string(3) "3rd" -int(4) - -Notice: Undefined index: 5th in %sarray_010.php on line %d -NULL - -Notice: Undefined offset: 6 in %sarray_010.php on line %d -NULL -===offsetSet=== -WRITE 1 -string(9) "Changed 1" -WRITE 2 -string(11) "Changed 4th" -WRITE 3 -string(9) "Added 5th" -WRITE 4 -string(7) "Added 6" -string(3) "1st" -string(3) "3rd" -string(9) "changed 6" -string(9) "changed 6" -===unset=== -array(6) { - [0]=> - string(3) "1st" - [1]=> - string(9) "Changed 1" - [2]=> - string(3) "3rd" - ["4th"]=> - string(11) "Changed 4th" - ["5th"]=> - string(9) "Added 5th" - [6]=> - string(9) "changed 6" -} - -Notice: Undefined offset: 7 in %sarray_010.php on line %d - -Notice: Undefined index: 8th in %sarray_010.php on line %d -array(4) { - [0]=> - string(3) "1st" - [1]=> - string(9) "Changed 1" - ["5th"]=> - string(9) "Added 5th" - [6]=> - string(9) "changed 6" -} -===DONE=== diff --git a/ext/spl/tests/array_011.phpt b/ext/spl/tests/array_011.phpt deleted file mode 100755 index 09b132cfef..0000000000 --- a/ext/spl/tests/array_011.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -SPL: ArrayIterator, LimitIterator and string keys ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -$a = array('zero' => 0, 'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5); -//foreach (new ArrayIterator($a) as $k => $v) -foreach (new LimitIterator(new ArrayIterator($a), 1, 3) as $k => $v) -{ - var_dump(array($k, $v)); -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -array(2) { - [0]=> - string(3) "one" - [1]=> - int(1) -} -array(2) { - [0]=> - string(3) "two" - [1]=> - int(2) -} -array(2) { - [0]=> - string(5) "three" - [1]=> - int(3) -} -===DONE=== diff --git a/ext/spl/tests/array_012.phpt b/ext/spl/tests/array_012.phpt deleted file mode 100755 index a8889654a5..0000000000 --- a/ext/spl/tests/array_012.phpt +++ /dev/null @@ -1,65 +0,0 @@ ---TEST-- -SPL: ArrayIterator::count ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -echo "===Array===\n"; - -$a = array('zero' => 0, 'one' => 1, 'two' => 2); -$it = new ArrayIterator($a); - -var_dump($it->count()); -foreach($it as $key => $val) -{ - echo "$key=>$val\n"; - var_dump($it->count()); -} -var_dump($it->count()); - -echo "===Object===\n"; - -class test -{ - public $zero = 0; - protected $pro; - public $one = 1; - private $pri; - public $two = 2; -} - -$o = new test; -$it = new ArrayIterator($o); - -var_dump($it->count()); -foreach($it as $key => $val) -{ - echo "$key=>$val\n"; - var_dump($it->count()); -} -var_dump($it->count()); - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -===Array=== -int(3) -zero=>0 -int(3) -one=>1 -int(3) -two=>2 -int(3) -int(3) -===Object=== -int(3) -zero=>0 -int(3) -one=>1 -int(3) -two=>2 -int(3) -int(3) -===DONE=== diff --git a/ext/spl/tests/array_013.phpt b/ext/spl/tests/array_013.phpt deleted file mode 100755 index 6d74bcb419..0000000000 --- a/ext/spl/tests/array_013.phpt +++ /dev/null @@ -1,81 +0,0 @@ ---TEST-- -SPL: ArrayIterator::append ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -if (!class_exists('NoRewindIterator', false)) -{ - require_once(dirname(__FILE__) . '/../examples/norewinditerator.inc'); -} - -echo "===Array===\n"; - -$a = array(0 => 'zero', 1 => 'one', 2 => 'two'); -$it = new ArrayIterator($a); - -foreach($it as $key => $val) -{ - echo "$key=>$val\n"; -} - -echo "===Append===\n"; - -$it->append('three'); -$it->append('four'); - -foreach(new NoRewindIterator($it) as $key => $val) -{ - echo "$key=>$val\n"; -} - -echo "===Object===\n"; - -class test -{ - public $zero = 0; - protected $pro; - public $one = 1; - private $pri; - public $two = 2; -} - -$o = new test; -$it = new ArrayIterator($o); - -foreach($it as $key => $val) -{ - echo "$key=>$val\n"; -} - -echo "===Append===\n"; - -$it->append('three'); -$it->append('four'); - -foreach(new NoRewindIterator($it) as $key => $val) -{ - echo "$key=>$val\n"; -} - -var_dump($o->{0}); /* doesn't wotk anyway */ - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -===Array=== -0=>zero -1=>one -2=>two -===Append=== -3=>three -4=>four -===Object=== -zero=>0 -one=>1 -two=>2 -===Append=== - -Fatal error: ArrayIterator::append(): Cannot append properties to objects, use ArrayIterator::offsetSet() instead in %sarray_013.php on line %d diff --git a/ext/spl/tests/array_014.phpt b/ext/spl/tests/array_014.phpt deleted file mode 100755 index ad9bc6c4ac..0000000000 --- a/ext/spl/tests/array_014.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -SPL: ArrayIterator::seek() ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -$it = new ArrayIterator(range(0,10)); -var_dump($it->count()); -$it->seek(5); -var_dump($it->current()); -$it->seek(4); -var_dump($it->current()); -try -{ - $it->seek(-1); - var_dump($it->current()); -} -catch(Exception $e) -{ - echo $e->getMessage() . "\n"; -} - -try -{ - $it->seek(12); - var_dump($it->current()); -} -catch(Exception $e) -{ - echo $e->getMessage() . "\n"; -} - -$pos = 0; -foreach($it as $v) -{ - $it->seek($pos++); - var_dump($v); -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -int(11) -int(5) -int(4) -Seek position -1 is out of range -Seek position 12 is out of range -int(0) -int(1) -int(2) -int(3) -int(4) -int(5) -int(6) -int(7) -int(8) -int(9) -int(10) -===DONE=== diff --git a/ext/spl/tests/array_015.phpt b/ext/spl/tests/array_015.phpt deleted file mode 100755 index 0a82fc7a5d..0000000000 --- a/ext/spl/tests/array_015.phpt +++ /dev/null @@ -1,85 +0,0 @@ ---TEST-- -SPL: ArrayIterator::next() with internal arrays ---FILE-- -<?php - -$ar = new ArrayObject(); - -$ar[0] = 1; -$ar[1] = 2; -$ar[2] = 3; -$ar[3] = 4; -$ar[4] = 5; - -var_dump($ar); - -$it = $ar->getIterator(); - -$ar->offsetUnset($it->key()); -$it->next(); - -var_dump($it->current()); -var_dump($ar); - -foreach($it as $k => $v) -{ - $ar->offsetUnset($k+1); - echo "$k=>$v\n"; -} - -var_dump($ar); - -foreach($it as $k => $v) -{ - $ar->offsetUnset($k); - echo "$k=>$v\n"; -} - -var_dump($ar); - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -object(ArrayObject)#%d (5) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) -} - -Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_015.php on line %d -int(2) -object(ArrayObject)#%d (4) { - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) -} -1=>2 -3=>4 -object(ArrayObject)#%d (2) { - [1]=> - int(2) - [3]=> - int(4) -} -1=>2 - -Notice: main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_015.php on line %d -3=>4 - -Notice: main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_015.php on line %d -object(ArrayObject)#%d (0) { -} -===DONE=== diff --git a/ext/spl/tests/array_016.phpt b/ext/spl/tests/array_016.phpt deleted file mode 100755 index d4ea0ab39a..0000000000 --- a/ext/spl/tests/array_016.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -SPL: ArrayItaerator/Object and IteratorIterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -$it = new ArrayIterator(range(0,3)); - -foreach(new IteratorIterator($it) as $v) -{ - var_dump($v); -} - -$it = new ArrayObject(range(0,3)); - -foreach(new IteratorIterator($it) as $v) -{ - var_dump($v); -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -int(0) -int(1) -int(2) -int(3) -int(0) -int(1) -int(2) -int(3) -===DONE=== diff --git a/ext/spl/tests/bug28822.phpt b/ext/spl/tests/bug28822.phpt deleted file mode 100755 index 0cf5575367..0000000000 --- a/ext/spl/tests/bug28822.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Bug #28822 (ArrayObject::offsetExists() works inverted) ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -$array = new ArrayObject(); -$array->offsetSet('key', 'value'); -var_dump($array->offsetExists('key')); -var_dump($array->offsetExists('nokey')); - -?> -===DONE=== ---EXPECT-- -bool(true) -bool(false) -===DONE=== diff --git a/ext/spl/tests/bug31185.phpt b/ext/spl/tests/bug31185.phpt deleted file mode 100755 index b4f315b0b9..0000000000 --- a/ext/spl/tests/bug31185.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -Bug #31185 (Crash when exceptions thrown from ArrayAccess::offsetUnset()) ---FILE-- -<?php - -class FooBar implements ArrayAccess { - private $array = array(); - - public function offsetExists($index) { - return isset($this->array[$index]); - } - - public function offsetGet($index) { - return $this->array[$index]; - } - - public function offsetSet($index, $value) { - echo __METHOD__ . "($index, $value)\n"; - $this->array[$index] = $value; - } - - public function offsetUnset($index) { - throw new Exception('FAIL'); - unset($this->array[$index]); - } - -} - -$i = 0; $j = 0; -$foo = new FooBar(); -$foo[$j++] = $i++; -$foo[$j++] = $i++; -$foo[$j++] = $i++; -try -{ - unset($foo[1]); -} -catch (Exception $e) -{ - echo "CAUGHT: " . $e->getMessage() . "\n"; -} - -print_R($foo); -?> -===DONE=== ---EXPECT-- -FooBar::offsetSet(0, 0) -FooBar::offsetSet(1, 1) -FooBar::offsetSet(2, 2) -CAUGHT: FAIL -FooBar Object -( - [array:private] => Array - ( - [0] => 0 - [1] => 1 - [2] => 2 - ) - -) -===DONE=== diff --git a/ext/spl/tests/bug31346.phpt b/ext/spl/tests/bug31346.phpt deleted file mode 100755 index 9b5618ec0e..0000000000 --- a/ext/spl/tests/bug31346.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -Bug #31486 (ArrayIterator::next segfaults) ---FILE-- -<?php -$obj = new stdClass; -$obj->var1=1; - -$ao = new ArrayObject($obj); - -$i = $ao->getIterator(); - -$ao->offsetUnset($i->key()); -$i->next(); - -?> -===DONE=== ---EXPECTF-- -Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sbug31346.php on line %d -===DONE=== diff --git a/ext/spl/tests/bug31348.phpt b/ext/spl/tests/bug31348.phpt deleted file mode 100755 index 047e4b223a..0000000000 --- a/ext/spl/tests/bug31348.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Bug #31348 (CachingIterator::rewind() leaks) ---FILE-- -<?php -$a = Array("some","blah"); -$i = new ArrayIterator($a); - -$ci = new CachingIterator($i); - -$ci->rewind(); - -?> -===DONE=== ---EXPECT-- -===DONE=== diff --git a/ext/spl/tests/bug31926.phpt b/ext/spl/tests/bug31926.phpt deleted file mode 100755 index 428039b1cb..0000000000 --- a/ext/spl/tests/bug31926.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Bug #31926 (php in free() error with RecursiveArrayIterator) ---FILE-- -<?php - -$array = array(0 => array('world')); - -class RecursiveArrayIterator extends ArrayIterator implements -RecursiveIterator { - function hasChildren() { - return (is_array($this->current())); - } - - function getChildren() { - return new self($this->current()); - } -} - -$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($array)); -foreach($it as $key => $val) { - var_dump($key, $val); -} - -?> ---EXPECT-- -int(0) -string(5) "world" diff --git a/ext/spl/tests/bug32134.phpt b/ext/spl/tests/bug32134.phpt deleted file mode 100755 index 5a880b321d..0000000000 --- a/ext/spl/tests/bug32134.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -Bug #32134 (Overloading offsetGet/offsetSet) ---FILE-- -<?php - -class myArray extends ArrayIterator -{ - - public function __construct($array = array()) - { - parent::__construct($array); - } - - public function offsetGet($index) - { - static $i = 0; - echo __METHOD__ . "($index)\n"; - if (++$i > 3) exit(1); - return parent::offsetGet($index); - } - - public function offsetSet($index, $newval) - { - echo __METHOD__ . "($index,$newval)\n"; - return parent::offsetSet($index, $newval); - } - -} - -$myArray = new myArray(); - -$myArray->offsetSet('one', 'one'); -var_dump($myArray->offsetGet('one')); - -$myArray['two'] = 'two'; -var_dump($myArray['two']); - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -myArray::offsetSet(one,one) -myArray::offsetGet(one) -string(3) "one" -myArray::offsetSet(two,two) -myArray::offsetGet(two) -string(3) "two" -===DONE=== diff --git a/ext/spl/tests/bug32394.phpt b/ext/spl/tests/bug32394.phpt deleted file mode 100755 index 8189b23f7a..0000000000 --- a/ext/spl/tests/bug32394.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Bug #32394 (offsetUnset() segfaults in a foreach) ---FILE-- -<?php - -$object = new ArrayIterator; -$object->append(1); - -foreach($object as $key => $value) -{ - $object->offsetUnset($key); -} - -?> -===DONE=== ---EXPECT-- -===DONE=== diff --git a/ext/spl/tests/dit_001.phpt b/ext/spl/tests/dit_001.phpt deleted file mode 100755 index f02291c77b..0000000000 --- a/ext/spl/tests/dit_001.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -SPL: Problem with casting to string ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -$d = new DirectoryIterator('.'); -var_dump($d); -var_dump(is_string($d)); -preg_match('/x/', $d); -var_dump(is_string($d)); -?> -===DONE=== ---EXPECTF-- -object(DirectoryIterator)#%d (0) { -} -bool(false) -bool(false) -===DONE=== diff --git a/ext/spl/tests/fileobject_001.phpt b/ext/spl/tests/fileobject_001.phpt deleted file mode 100755 index 056c1e17f7..0000000000 --- a/ext/spl/tests/fileobject_001.phpt +++ /dev/null @@ -1,88 +0,0 @@ ---TEST-- -SPL: FileObject::seek'ing ---FILE-- -<?php - -$o = new FileObject(dirname(__FILE__) . '/fileobject_001a.txt'); - -var_dump($o->key()); -var_dump($o->current()); -$o->setFlags(FO_DROP_NEW_LINE); -var_dump($o->key()); -var_dump($o->current()); -var_dump($o->key()); -$o->next(); -var_dump($o->key()); -var_dump($o->current()); -var_dump($o->key()); -$o->rewind(); -var_dump($o->key()); -var_dump($o->current()); -var_dump($o->key()); -$o->seek(4); -var_dump($o->key()); -var_dump($o->current()); -var_dump($o->key()); - -echo "===A===\n"; -foreach($o as $n => $l) -{ - var_dump($n, $l); -} - -echo "===B===\n"; -$o = new FileObject(dirname(__FILE__) . '/fileobject_001b.txt'); -$o->setFlags(FO_DROP_NEW_LINE); -foreach($o as $n => $l) -{ - var_dump($n, $l); -} - -?> -===DONE=== ---EXPECT-- -int(0) -string(2) "0 -" -int(0) -string(2) "0 -" -int(0) -int(1) -string(1) "1" -int(1) -int(0) -string(1) "0" -int(0) -int(4) -string(1) "4" -int(4) -===A=== -int(0) -string(1) "0" -int(1) -string(1) "1" -int(2) -string(1) "2" -int(3) -string(1) "3" -int(4) -string(1) "4" -int(5) -string(1) "5" -int(6) -string(0) "" -===B=== -int(0) -string(1) "0" -int(1) -string(1) "1" -int(2) -string(1) "2" -int(3) -string(1) "3" -int(4) -string(1) "4" -int(5) -string(1) "5" -===DONE=== diff --git a/ext/spl/tests/fileobject_001a.txt b/ext/spl/tests/fileobject_001a.txt deleted file mode 100755 index e8371f0060..0000000000 --- a/ext/spl/tests/fileobject_001a.txt +++ /dev/null @@ -1,6 +0,0 @@ -0 -1 -2 -3 -4 -5 diff --git a/ext/spl/tests/fileobject_001b.txt b/ext/spl/tests/fileobject_001b.txt deleted file mode 100755 index 0c4a8b5cd3..0000000000 --- a/ext/spl/tests/fileobject_001b.txt +++ /dev/null @@ -1,6 +0,0 @@ -0 -1 -2 -3 -4 -5
\ No newline at end of file diff --git a/ext/spl/tests/fileobject_002.phpt b/ext/spl/tests/fileobject_002.phpt deleted file mode 100755 index f85b020503..0000000000 --- a/ext/spl/tests/fileobject_002.phpt +++ /dev/null @@ -1,122 +0,0 @@ ---TEST-- -SPL: FileObject::fgetc ---FILE-- -<?php - -function test($name) -{ - echo "===$name===\n"; - - $o = new FileObject(dirname(__FILE__) . '/' . $name); - - var_dump($o->key()); - while(($c = $o->fgetc()) !== false) - { - var_dump($o->key(), $c, $o->eof()); - } - echo "===EOF?===\n"; - var_dump($o->eof()); - var_dump($o->key()); - var_dump($o->eof()); -} - -test('fileobject_001a.txt'); -test('fileobject_001b.txt'); - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -===fileobject_001a.txt=== -int(0) -int(0) -string(1) "0" -bool(false) -int(1) -string(1) " -" -bool(false) -int(1) -string(1) "1" -bool(false) -int(2) -string(1) " -" -bool(false) -int(2) -string(1) "2" -bool(false) -int(3) -string(1) " -" -bool(false) -int(3) -string(1) "3" -bool(false) -int(4) -string(1) " -" -bool(false) -int(4) -string(1) "4" -bool(false) -int(5) -string(1) " -" -bool(false) -int(5) -string(1) "5" -bool(false) -int(6) -string(1) " -" -bool(false) -===EOF?=== -bool(true) -int(6) -bool(true) -===fileobject_001b.txt=== -int(0) -int(0) -string(1) "0" -bool(false) -int(1) -string(1) " -" -bool(false) -int(1) -string(1) "1" -bool(false) -int(2) -string(1) " -" -bool(false) -int(2) -string(1) "2" -bool(false) -int(3) -string(1) " -" -bool(false) -int(3) -string(1) "3" -bool(false) -int(4) -string(1) " -" -bool(false) -int(4) -string(1) "4" -bool(false) -int(5) -string(1) " -" -bool(false) -int(5) -string(1) "5" -bool(false) -===EOF?=== -bool(true) -int(5) -bool(true) -===DONE=== diff --git a/ext/spl/tests/iterator_001.phpt b/ext/spl/tests/iterator_001.phpt deleted file mode 100755 index 2239417778..0000000000 --- a/ext/spl/tests/iterator_001.phpt +++ /dev/null @@ -1,173 +0,0 @@ ---TEST-- -SPL: Iterator aggregating inner iterator's methods ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -class NumericArrayIterator implements Iterator -{ - protected $a; - protected $i = 0; - - public function __construct($a) - { - echo __METHOD__ . "\n"; - $this->a = $a; - } - - public function rewind() - { - echo __METHOD__ . "\n"; - $this->i = 0; - } - - public function valid() - { - $ret = $this->i < count($this->a); - echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n"; - return $ret; - } - - public function key() - { - echo __METHOD__ . "\n"; - return $this->i; - } - - public function current() - { - echo __METHOD__ . "\n"; - return $this->a[$this->i]; - } - - public function next() - { - echo __METHOD__ . "\n"; - $this->i++; - } - - public function greaterThan($comp) - { - echo get_class($this) . '::' . __FUNCTION__ . '(' . $comp . ")\n"; - return $this->current() > $comp; - } -} - -class SeekableNumericArrayIterator extends NumericArrayIterator implements SeekableIterator -{ - public function seek($index) - { - if ($index < count($this->a)) { - $this->i = $index; - } - echo __METHOD__ . '(' . $index . ")\n"; - } -} - -$a = array(1, 2, 3, 4, 5); -$it = new LimitIterator(new NumericArrayIterator($a), 1, 3); -foreach ($it as $v) -{ - print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; -} - -echo "===SEEKABLE===\n"; -$a = array(1, 2, 3, 4, 5); -$it = new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3); -foreach($it as $v) -{ - print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; -} - -echo "===STACKED===\n"; -echo "Shows '2 is greater than 2' because the test is actually done with the current value which is 3.\n"; -$a = array(1, 2, 3, 4, 5); -$it = new CachingIterator(new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3)); -foreach($it as $v) -{ - print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -NumericArrayIterator::__construct -NumericArrayIterator::rewind -NumericArrayIterator::valid(true) -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -NumericArrayIterator::greaterThan(2) -NumericArrayIterator::current -2 is less than or equal 2 -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -NumericArrayIterator::greaterThan(2) -NumericArrayIterator::current -3 is greater than 2 -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -NumericArrayIterator::greaterThan(2) -NumericArrayIterator::current -4 is greater than 2 -NumericArrayIterator::next -===SEEKABLE=== -NumericArrayIterator::__construct -NumericArrayIterator::rewind -SeekableNumericArrayIterator::seek(1) -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -SeekableNumericArrayIterator::greaterThan(2) -NumericArrayIterator::current -2 is less than or equal 2 -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -SeekableNumericArrayIterator::greaterThan(2) -NumericArrayIterator::current -3 is greater than 2 -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -SeekableNumericArrayIterator::greaterThan(2) -NumericArrayIterator::current -4 is greater than 2 -NumericArrayIterator::next -===STACKED=== -Shows '2 is greater than 2' because the test is actually done with the current value which is 3. -NumericArrayIterator::__construct -NumericArrayIterator::rewind -SeekableNumericArrayIterator::seek(1) -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -SeekableNumericArrayIterator::greaterThan(2) -NumericArrayIterator::current -2 is greater than 2 -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -SeekableNumericArrayIterator::greaterThan(2) -NumericArrayIterator::current -3 is greater than 2 -NumericArrayIterator::next -SeekableNumericArrayIterator::greaterThan(2) -NumericArrayIterator::current -4 is greater than 2 -===DONE=== diff --git a/ext/spl/tests/iterator_002.phpt b/ext/spl/tests/iterator_002.phpt deleted file mode 100755 index b481a0e00f..0000000000 --- a/ext/spl/tests/iterator_002.phpt +++ /dev/null @@ -1,57 +0,0 @@ ---TEST-- -SPL: Iterator using getInnerIterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -class RecursiceArrayIterator extends ArrayIterator implements RecursiveIterator -{ - function hasChildren() - { - return is_array($this->current()); - } - - function getChildren() - { - return new RecursiceArrayIterator($this->current()); - } -} - -class CrashIterator extends FilterIterator implements RecursiveIterator -{ - function accept() - { - return true; - } - - function hasChildren() - { - return $this->getInnerIterator()->hasChildren(); - } - - function getChildren() - { - return new RecursiceArrayIterator($this->getInnerIterator()->current()); - } -} - -$array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3); - -$dir = new RecursiveIteratorIterator(new CrashIterator(new RecursiceArrayIterator($array)), RIT_LEAVES_ONLY); - -foreach ($dir as $file) { - print "$file\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -1 -21 -221 -222 -231 -3 -===DONE=== diff --git a/ext/spl/tests/iterator_003.phpt b/ext/spl/tests/iterator_003.phpt deleted file mode 100755 index c60776cb33..0000000000 --- a/ext/spl/tests/iterator_003.phpt +++ /dev/null @@ -1,97 +0,0 @@ ---TEST-- -SPL: CachingIterator and __toString() ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -class Student -{ - private $id; - private $name; - - public function __construct($id, $name) - { - $this->id = $id; - $this->name = $name; - } - - public function __toString() - { - return $this->id . ', ' . $this->name; - } - - public function getId() - { - return $this->id; - } -} - -class StudentIdFilter extends FilterIterator -{ - private $id; - - public function __construct(ArrayObject $students, Student $other) - { - FilterIterator::__construct($students->getIterator()); - $this->id = $other->getId(); - } - - public function accept() - { - echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n"; - return $this->current()->getId() == $this->id; - } -} - -class StudentList implements IteratorAggregate -{ - private $students; - - public function __construct() - { - $this->students = new ArrayObject(array()); - } - - public function add(Student $student) - { - if (!$this->contains($student)) { - $this->students[] = $student; - } - } - - public function contains(Student $student) - { - foreach ($this->students as $s) - { - if ($s->getId() == $student->getId()) { - return true; - } - } - return false; - } - - public function getIterator() { - return new CachingIterator($this->students->getIterator(), true); - } -} - -$students = new StudentList(); -$students->add(new Student('01234123', 'Joe')); -$students->add(new Student('00000014', 'Bob')); -$students->add(new Student('00000014', 'Foo')); - -// The goal is to verify we can access the cached string value even if it was -// generated by a call to __toString(). To check this we need to access the -// iterator's __toString() method. -$it = $students->getIterator(); -foreach ($it as $student) { - echo $it->__toString(), "\n"; -} -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -01234123, Joe -00000014, Bob -===DONE=== diff --git a/ext/spl/tests/iterator_004.phpt b/ext/spl/tests/iterator_004.phpt deleted file mode 100755 index 4e6006621b..0000000000 --- a/ext/spl/tests/iterator_004.phpt +++ /dev/null @@ -1,144 +0,0 @@ ---TEST-- -SPL: SeekableIterator and string keys ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -class NumericArrayIterator implements Iterator -{ - protected $a; - protected $i; - - public function __construct($a) - { - echo __METHOD__ . "\n"; - $this->a = $a; - } - - public function rewind() - { - echo __METHOD__ . "\n"; - $this->i = 0; - } - - public function valid() - { - $ret = $this->i < count($this->a); - echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n"; - return $ret; - } - - public function key() - { - echo __METHOD__ . "\n"; - return $this->i; - } - - public function current() - { - echo __METHOD__ . "\n"; - return $this->a[$this->i]; - } - - public function next() - { - echo __METHOD__ . "\n"; - $this->i++; - } -} - -class SeekableNumericArrayIterator extends NumericArrayIterator implements SeekableIterator -{ - public function seek($index) - { - if ($index < count($this->a)) { - $this->i = $index; - } - echo __METHOD__ . '(' . $index . ")\n"; - } -} - -$a = array(1, 2, 3, 4, 5); -foreach (new LimitIterator(new NumericArrayIterator($a), 1, 3) as $v) -{ - print "$v\n"; -} - -echo "===SEEKABLE===\n"; -$a = array(1, 2, 3, 4, 5); -foreach(new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3) as $v) -{ - print "$v\n"; -} - -echo "===SEEKING===\n"; -$a = array(1, 2, 3, 4, 5); -$l = new LimitIterator(new SeekableNumericArrayIterator($a)); -for($i = 1; $i < 4; $i++) -{ - $l->seek($i); - print $l->current() . "\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -NumericArrayIterator::__construct -NumericArrayIterator::rewind -NumericArrayIterator::valid(true) -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -2 -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -3 -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -4 -NumericArrayIterator::next -===SEEKABLE=== -NumericArrayIterator::__construct -NumericArrayIterator::rewind -SeekableNumericArrayIterator::seek(1) -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -2 -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -3 -NumericArrayIterator::next -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -4 -NumericArrayIterator::next -===SEEKING=== -NumericArrayIterator::__construct -SeekableNumericArrayIterator::seek(1) -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -2 -SeekableNumericArrayIterator::seek(2) -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -3 -SeekableNumericArrayIterator::seek(3) -NumericArrayIterator::valid(true) -NumericArrayIterator::current -NumericArrayIterator::key -4 -===DONE=== diff --git a/ext/spl/tests/iterator_005.phpt b/ext/spl/tests/iterator_005.phpt deleted file mode 100755 index 4aae600169..0000000000 --- a/ext/spl/tests/iterator_005.phpt +++ /dev/null @@ -1,54 +0,0 @@ ---TEST-- -SPL: IteratorIterator and ArrayIterator/Object ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -class ArrayIteratorEx extends ArrayIterator -{ - function rewind() - { - echo __METHOD__ . "\n"; - return parent::rewind(); - } -} - -$it = new ArrayIteratorEx(range(0,3)); - -foreach(new IteratorIterator($it) as $v) -{ - var_dump($v); -} - -class ArrayObjectEx extends ArrayObject -{ - function getIterator() - { - echo __METHOD__ . "\n"; - return parent::getIterator(); - } -} - -$it = new ArrayObjectEx(range(0,3)); - -foreach(new IteratorIterator($it) as $v) -{ - var_dump($v); -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -ArrayIteratorEx::rewind -int(0) -int(1) -int(2) -int(3) -ArrayObjectEx::getIterator -int(0) -int(1) -int(2) -int(3) -===DONE=== diff --git a/ext/spl/tests/iterator_006.phpt b/ext/spl/tests/iterator_006.phpt deleted file mode 100755 index 855741c711..0000000000 --- a/ext/spl/tests/iterator_006.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -SPL: IteratorIterator and SimpleXMlElement ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -$root = simplexml_load_string('<?xml version="1.0"?> -<root> - <child>Hello</child> - <child>World</child> -</root> -'); - -foreach (new IteratorIterator($root->child) as $child) { - echo $child."\n"; -} -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -Hello -World -===DONE=== diff --git a/ext/spl/tests/iterator_007.phpt b/ext/spl/tests/iterator_007.phpt deleted file mode 100755 index eb87977ac9..0000000000 --- a/ext/spl/tests/iterator_007.phpt +++ /dev/null @@ -1,168 +0,0 @@ ---TEST-- -SPL: NoRewindIterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -class ArrayIteratorEx extends ArrayIterator -{ - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } -} - -class NoRewindIteratorEx extends NoRewindIterator -{ - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } -} - -$it = new NoRewindIteratorEx(new ArrayIteratorEx(range(0,3))); - -echo "===0===\n"; -foreach ($it->getInnerIterator() as $v) { - var_dump($v); -} - -echo "===1===\n"; -foreach ($it as $v) { - var_dump($v); -} - -$pos =0; - -$it = new NoRewindIteratorEx(new ArrayIteratorEx(range(0,3))); - -echo "===2===\n"; -foreach ($it as $v) { - var_dump($v); - if ($pos++ > 1) { - break; - } -} - -echo "===3===\n"; -foreach ($it as $v) { - var_dump($v); -} - -echo "===4===\n"; -foreach ($it as $v) { - var_dump($v); -} -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -===0=== -ArrayIteratorEx::rewind -ArrayIteratorEx::valid -ArrayIteratorEx::current -int(0) -ArrayIteratorEx::next -ArrayIteratorEx::valid -ArrayIteratorEx::current -int(1) -ArrayIteratorEx::next -ArrayIteratorEx::valid -ArrayIteratorEx::current -int(2) -ArrayIteratorEx::next -ArrayIteratorEx::valid -ArrayIteratorEx::current -int(3) -ArrayIteratorEx::next -ArrayIteratorEx::valid -===1=== -NoRewindIteratorEx::rewind -NoRewindIteratorEx::valid -ArrayIteratorEx::valid -===2=== -NoRewindIteratorEx::rewind -NoRewindIteratorEx::valid -ArrayIteratorEx::valid -NoRewindIteratorEx::current -ArrayIteratorEx::current -int(0) -NoRewindIteratorEx::next -ArrayIteratorEx::next -NoRewindIteratorEx::valid -ArrayIteratorEx::valid -NoRewindIteratorEx::current -ArrayIteratorEx::current -int(1) -NoRewindIteratorEx::next -ArrayIteratorEx::next -NoRewindIteratorEx::valid -ArrayIteratorEx::valid -NoRewindIteratorEx::current -ArrayIteratorEx::current -int(2) -===3=== -NoRewindIteratorEx::rewind -NoRewindIteratorEx::valid -ArrayIteratorEx::valid -NoRewindIteratorEx::current -int(2) -NoRewindIteratorEx::next -ArrayIteratorEx::next -NoRewindIteratorEx::valid -ArrayIteratorEx::valid -NoRewindIteratorEx::current -ArrayIteratorEx::current -int(3) -NoRewindIteratorEx::next -ArrayIteratorEx::next -NoRewindIteratorEx::valid -ArrayIteratorEx::valid -===4=== -NoRewindIteratorEx::rewind -NoRewindIteratorEx::valid -ArrayIteratorEx::valid -===DONE=== diff --git a/ext/spl/tests/iterator_008.phpt b/ext/spl/tests/iterator_008.phpt deleted file mode 100755 index 5f3c7d89df..0000000000 --- a/ext/spl/tests/iterator_008.phpt +++ /dev/null @@ -1,91 +0,0 @@ ---TEST-- -SPL: InfiniteIterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -class ArrayIteratorEx extends ArrayIterator -{ - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } -} - -$it = new InfiniteIterator(new ArrayIteratorEx(range(0,2))); - -$pos =0; - -foreach ($it as $v) { - var_dump($v); - if ($pos++ > 5) { - break; - } -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -ArrayIteratorEx::rewind -ArrayIteratorEx::valid -ArrayIteratorEx::current -ArrayIteratorEx::key -int(0) -ArrayIteratorEx::next -ArrayIteratorEx::valid -ArrayIteratorEx::current -ArrayIteratorEx::key -int(1) -ArrayIteratorEx::next -ArrayIteratorEx::valid -ArrayIteratorEx::current -ArrayIteratorEx::key -int(2) -ArrayIteratorEx::next -ArrayIteratorEx::valid -ArrayIteratorEx::rewind -ArrayIteratorEx::valid -ArrayIteratorEx::current -ArrayIteratorEx::key -int(0) -ArrayIteratorEx::next -ArrayIteratorEx::valid -ArrayIteratorEx::current -ArrayIteratorEx::key -int(1) -ArrayIteratorEx::next -ArrayIteratorEx::valid -ArrayIteratorEx::current -ArrayIteratorEx::key -int(2) -ArrayIteratorEx::next -ArrayIteratorEx::valid -ArrayIteratorEx::rewind -ArrayIteratorEx::valid -ArrayIteratorEx::current -ArrayIteratorEx::key -int(0) -===DONE=== diff --git a/ext/spl/tests/iterator_009.phpt b/ext/spl/tests/iterator_009.phpt deleted file mode 100755 index 27a3e0655f..0000000000 --- a/ext/spl/tests/iterator_009.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -SPL: EmptyIterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -class EmptyIteratorEx extends EmptyIterator -{ - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } -} - -foreach (new EmptyIteratorEx() as $v) { - var_dump($v); -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -EmptyIteratorEx::rewind -EmptyIteratorEx::valid -===DONE=== diff --git a/ext/spl/tests/iterator_010.phpt b/ext/spl/tests/iterator_010.phpt deleted file mode 100755 index 39d1000f62..0000000000 --- a/ext/spl/tests/iterator_010.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -SPL: EmptyIterator ---FILE-- -<?php - -echo "===EmptyIterator===\n"; - -foreach(new LimitIterator(new EmptyIterator(), 0, 3) as $key => $val) -{ - echo "$key=>$val\n"; -} - -?> -===DONE=== -<?php exit(0); ---EXPECTF-- -===EmptyIterator=== -===DONE=== diff --git a/ext/spl/tests/iterator_011.phpt b/ext/spl/tests/iterator_011.phpt deleted file mode 100755 index fca159a20f..0000000000 --- a/ext/spl/tests/iterator_011.phpt +++ /dev/null @@ -1,51 +0,0 @@ ---TEST-- -SPL: InfiniteIterator ---FILE-- -<?php - -echo "===EmptyIterator===\n"; - -foreach(new LimitIterator(new InfiniteIterator(new EmptyIterator()), 0, 3) as $key=>$val) -{ - echo "$key=>$val\n"; -} - -echo "===InfiniteIterator===\n"; - -$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D')); -$it = new InfiniteIterator($it); -$it = new LimitIterator($it, 2, 5); -foreach($it as $val=>$key) -{ - echo "$val=>$key\n"; -} - -echo "===Infinite/LimitIterator===\n"; - -$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D')); -$it = new LimitIterator($it, 1, 2); -$it = new InfiniteIterator($it); -$it = new LimitIterator($it, 2, 5); -foreach($it as $val=>$key) -{ - echo "$val=>$key\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -===EmptyIterator=== -===InfiniteIterator=== -2=>C -3=>D -0=>A -1=>B -2=>C -===Infinite/LimitIterator=== -1=>B -2=>C -1=>B -2=>C -1=>B -===DONE=== diff --git a/ext/spl/tests/iterator_012.phpt b/ext/spl/tests/iterator_012.phpt deleted file mode 100755 index 09842b0988..0000000000 --- a/ext/spl/tests/iterator_012.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -SPL: NoRweindIterator ---FILE-- -<?php - -echo "===Current===\n"; - -$it = new NoRewindIterator(new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C'))); - -echo $it->key() . '=>' . $it->current() . "\n"; - -echo "===Next===\n"; - -$it->next(); - -echo "===Foreach===\n"; - -foreach($it as $key=>$val) -{ - echo "$key=>$val\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -===Current=== -0=>A -===Next=== -===Foreach=== -1=>B -2=>C -===DONE=== diff --git a/ext/spl/tests/iterator_013.phpt b/ext/spl/tests/iterator_013.phpt deleted file mode 100755 index 119631c000..0000000000 --- a/ext/spl/tests/iterator_013.phpt +++ /dev/null @@ -1,66 +0,0 @@ ---TEST-- -SPL: AppendIterator ---FILE-- -<?php - -echo "===Empty===\n"; - -$it = new AppendIterator; - -foreach($it as $key=>$val) -{ - echo "$key=>$val\n"; -} - -echo "===Append===\n"; - -$it->append(new ArrayIterator(array(0 => 'A', 1 => 'B'))); - -foreach($it as $key=>$val) -{ - echo "$key=>$val\n"; -} - -echo "===Rewind===\n"; - -foreach($it as $key=>$val) -{ - echo "$key=>$val\n"; -} - -echo "===Append===\n"; - -$it->append(new ArrayIterator(array(2 => 'C', 3 => 'D'))); - -foreach(new NoRewindIterator($it) as $key=>$val) -{ - echo "$key=>$val\n"; -} - -echo "===Rewind===\n"; - -foreach($it as $key=>$val) -{ - echo "$key=>$val\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -===Empty=== -===Append=== -0=>A -1=>B -===Rewind=== -0=>A -1=>B -===Append=== -2=>C -3=>D -===Rewind=== -0=>A -1=>B -2=>C -3=>D -===DONE=== diff --git a/ext/spl/tests/iterator_014.phpt b/ext/spl/tests/iterator_014.phpt deleted file mode 100755 index f6e8ce9d01..0000000000 --- a/ext/spl/tests/iterator_014.phpt +++ /dev/null @@ -1,143 +0,0 @@ ---TEST-- -SPL: RecursiveIteratorIterator and beginChildren/endChildren ---FILE-- -<?php - -class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator -{ - function hasChildren() - { - return is_array($this->current()); - } - - function getChildren() - { - echo __METHOD__ . "\n"; - return new RecursiveArrayIterator($this->current()); - } - - function valid() - { - if (!parent::valid()) - { - echo __METHOD__ . " = false\n"; - return false; - } - else - { - return true; - } - } -} - -class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator -{ - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } - - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } - - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } - - function beginChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } - - function endChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } -} - -foreach(new RecursiveArrayIteratorIterator(new RecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d"))) as $k=>$v) -{ - echo "$k=>$v\n"; -} -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -RecursiveArrayIteratorIterator::rewind -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>a -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::getChildren -RecursiveArrayIteratorIterator::beginChildren(1) -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>ba -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::getChildren -RecursiveArrayIteratorIterator::beginChildren(2) -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>bba -RecursiveArrayIteratorIterator::next -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -1=>bbb -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(2) -RecursiveArrayIterator::getChildren -RecursiveArrayIteratorIterator::beginChildren(2) -RecursiveArrayIterator::getChildren -RecursiveArrayIteratorIterator::beginChildren(3) -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>bcaa -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(3) -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(2) -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(1) -RecursiveArrayIterator::getChildren -RecursiveArrayIteratorIterator::beginChildren(1) -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>ca -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(1) -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -3=>d -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::valid -RecursiveArrayIterator::valid = false -===DONE=== diff --git a/ext/spl/tests/iterator_015.phpt b/ext/spl/tests/iterator_015.phpt deleted file mode 100755 index 3a18efd80f..0000000000 --- a/ext/spl/tests/iterator_015.phpt +++ /dev/null @@ -1,75 +0,0 @@ ---TEST-- -SPL: RecursiveIteratorIterator and beginChildren/endChildren ---FILE-- -<?php - -class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator -{ - function hasChildren() - { - return is_array($this->current()); - } - - function getChildren() - { - return new RecursiveArrayIterator($this->current()); - } -} - -class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator -{ - function rewind() - { - echo "<ul>\n"; - parent::rewind(); - } - function beginChildren() - { - echo str_repeat(' ',$this->getDepth())."<ul>\n"; - } - - function endChildren() - { - echo str_repeat(' ',$this->getDepth())."</ul>\n"; - } - function valid() - { - if (!parent::valid()) { - echo "<ul>\n"; - return false; - } - return true; - } -} - -$arr = array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d"); -$obj = new RecursiveArrayIterator($arr); -$rit = new RecursiveArrayIteratorIterator($obj); -foreach($rit as $k=>$v) -{ - echo str_repeat(' ',$rit->getDepth()+1)."$k=>$v\n"; -} -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -<ul> - 0=>a - <ul> - 0=>ba - <ul> - 0=>bba - 1=>bbb - </ul> - <ul> - <ul> - 0=>bcaa - </ul> - </ul> - </ul> - <ul> - 0=>ca - </ul> - 3=>d -<ul> -===DONE=== diff --git a/ext/spl/tests/iterator_016.phpt b/ext/spl/tests/iterator_016.phpt deleted file mode 100755 index 6a811edf29..0000000000 --- a/ext/spl/tests/iterator_016.phpt +++ /dev/null @@ -1,89 +0,0 @@ ---TEST-- -SPL: RecursiveIteratorIterator and beginChildren/endChildren ---FILE-- -<?php - -class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator -{ - function hasChildren() - { - return is_array($this->current()); - } - - function getChildren() - { - return new RecursiveArrayIterator($this->current()); - } -} - -class Menu extends ArrayObject -{ - function getIterator() - { - echo __METHOD__ . "\n"; - return new RecursiveArrayIterator($this); - } -} - -class MenuOutput extends RecursiveIteratorIterator -{ - function __construct(Menu $it) - { - parent::__construct($it); - } - function rewind() - { - echo "<ul>\n"; - parent::rewind(); - } - function beginChildren() - { - echo str_repeat(' ',$this->getDepth())."<ul>\n"; - } - - function endChildren() - { - echo str_repeat(' ',$this->getDepth())."</ul>\n"; - } - function valid() - { - if (!parent::valid()) { - echo "<ul>\n"; - return false; - } - return true; - } -} - -$arr = array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d"); -$obj = new Menu($arr); -$rit = new MenuOutput($obj); -foreach($rit as $k=>$v) -{ - echo str_repeat(' ',$rit->getDepth()+1)."$k=>$v\n"; -} -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -Menu::getIterator -<ul> - 0=>a - <ul> - 0=>ba - <ul> - 0=>bba - 1=>bbb - </ul> - <ul> - <ul> - 0=>bcaa - </ul> - </ul> - </ul> - <ul> - 0=>ca - </ul> - 3=>d -<ul> -===DONE=== diff --git a/ext/spl/tests/iterator_017.phpt b/ext/spl/tests/iterator_017.phpt deleted file mode 100755 index 39d1000f62..0000000000 --- a/ext/spl/tests/iterator_017.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -SPL: EmptyIterator ---FILE-- -<?php - -echo "===EmptyIterator===\n"; - -foreach(new LimitIterator(new EmptyIterator(), 0, 3) as $key => $val) -{ - echo "$key=>$val\n"; -} - -?> -===DONE=== -<?php exit(0); ---EXPECTF-- -===EmptyIterator=== -===DONE=== diff --git a/ext/spl/tests/iterator_018.phpt b/ext/spl/tests/iterator_018.phpt deleted file mode 100755 index 9c234bb11d..0000000000 --- a/ext/spl/tests/iterator_018.phpt +++ /dev/null @@ -1,51 +0,0 @@ ---TEST-- -SPL: InfiniteIterator ---FILE-- -<?php - -echo "===EmptyIterator===\n"; - -foreach(new LimitIterator(new InfiniteIterator(new EmptyIterator()), 0, 3) as $key=>$val) -{ - echo "$key=>$val\n"; -} - -echo "===InfiniteIterator===\n"; - -$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D')); -$it = new InfiniteIterator($it); -$it = new LimitIterator($it, 2, 5); -foreach($it as $val=>$key) -{ - echo "$val=>$key\n"; -} - -echo "===Infinite/LimitIterator===\n"; - -$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D')); -$it = new LimitIterator($it, 1, 2); -$it = new InfiniteIterator($it); -$it = new LimitIterator($it, 2, 5); -foreach($it as $val=>$key) -{ - echo "$val=>$key\n"; -} - -?> -===DONE=== -<?php exit(0); ---EXPECTF-- -===EmptyIterator=== -===InfiniteIterator=== -2=>C -3=>D -0=>A -1=>B -2=>C -===Infinite/LimitIterator=== -1=>B -2=>C -1=>B -2=>C -1=>B -===DONE=== diff --git a/ext/spl/tests/iterator_019.phpt b/ext/spl/tests/iterator_019.phpt deleted file mode 100755 index 09842b0988..0000000000 --- a/ext/spl/tests/iterator_019.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -SPL: NoRweindIterator ---FILE-- -<?php - -echo "===Current===\n"; - -$it = new NoRewindIterator(new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C'))); - -echo $it->key() . '=>' . $it->current() . "\n"; - -echo "===Next===\n"; - -$it->next(); - -echo "===Foreach===\n"; - -foreach($it as $key=>$val) -{ - echo "$key=>$val\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -===Current=== -0=>A -===Next=== -===Foreach=== -1=>B -2=>C -===DONE=== diff --git a/ext/spl/tests/iterator_020.phpt b/ext/spl/tests/iterator_020.phpt deleted file mode 100755 index 119631c000..0000000000 --- a/ext/spl/tests/iterator_020.phpt +++ /dev/null @@ -1,66 +0,0 @@ ---TEST-- -SPL: AppendIterator ---FILE-- -<?php - -echo "===Empty===\n"; - -$it = new AppendIterator; - -foreach($it as $key=>$val) -{ - echo "$key=>$val\n"; -} - -echo "===Append===\n"; - -$it->append(new ArrayIterator(array(0 => 'A', 1 => 'B'))); - -foreach($it as $key=>$val) -{ - echo "$key=>$val\n"; -} - -echo "===Rewind===\n"; - -foreach($it as $key=>$val) -{ - echo "$key=>$val\n"; -} - -echo "===Append===\n"; - -$it->append(new ArrayIterator(array(2 => 'C', 3 => 'D'))); - -foreach(new NoRewindIterator($it) as $key=>$val) -{ - echo "$key=>$val\n"; -} - -echo "===Rewind===\n"; - -foreach($it as $key=>$val) -{ - echo "$key=>$val\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -===Empty=== -===Append=== -0=>A -1=>B -===Rewind=== -0=>A -1=>B -===Append=== -2=>C -3=>D -===Rewind=== -0=>A -1=>B -2=>C -3=>D -===DONE=== diff --git a/ext/spl/tests/iterator_021.phpt b/ext/spl/tests/iterator_021.phpt deleted file mode 100755 index 115461d053..0000000000 --- a/ext/spl/tests/iterator_021.phpt +++ /dev/null @@ -1,185 +0,0 @@ ---TEST-- -SPL: RecursiveIteratorIterator and hasChildren ---FILE-- -<?php - -class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator -{ - function hasChildren() - { - return is_array($this->current()); - } - - function getChildren() - { - echo __METHOD__ . "\n"; - return new RecursiveArrayIterator($this->current()); - } - - function valid() - { - if (!parent::valid()) - { - echo __METHOD__ . " = false\n"; - return false; - } - else - { - return true; - } - } -} - -class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator -{ - private $max_depth; - private $over = 0; - private $skip = false; - - function __construct($it, $max_depth) - { - $this->max_depth = $max_depth; - parent::__construct($it); - } - - function rewind() - { - echo __METHOD__ . "\n"; - $this->skip = false; - parent::rewind(); - } - - function valid() - { - echo __METHOD__ . "\n"; - if ($this->skip) - { - $this->skip = false; - $this->next(); - } - return parent::valid(); - } - - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } - - function callHasChildren() - { - $this->skip = false; - $has = parent::callHasChildren(); - $res = $this->getDepth() < $this->max_depth && $has; - echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n"; - if ($has && !$res) - { - $this->over++; - if ($this->over == 2) { - $this->skip = true; - } - } - return $res; - } - - function beginChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } - - function endChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } -} - -foreach(new RecursiveArrayIteratorIterator(new RecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v) -{ - if (is_array($v)) $v = join('',$v); - echo "$k=>$v\n"; -} -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -RecursiveArrayIteratorIterator::rewind -RecursiveArrayIteratorIterator::callHasChildren(0) = no/no -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>a -RecursiveArrayIteratorIterator::next -RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes -RecursiveArrayIterator::getChildren -RecursiveArrayIteratorIterator::beginChildren(1) -RecursiveArrayIteratorIterator::callHasChildren(1) = no/no -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>ba -RecursiveArrayIteratorIterator::next -RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes -RecursiveArrayIterator::getChildren -RecursiveArrayIteratorIterator::beginChildren(2) -RecursiveArrayIteratorIterator::callHasChildren(2) = no/no -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>bba -RecursiveArrayIteratorIterator::next -RecursiveArrayIteratorIterator::callHasChildren(2) = no/no -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -1=>bbb -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(2) -RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes -RecursiveArrayIterator::getChildren -RecursiveArrayIteratorIterator::beginChildren(2) -RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>bcaa -RecursiveArrayIteratorIterator::next -RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(2) -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(1) -RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes -RecursiveArrayIterator::getChildren -RecursiveArrayIteratorIterator::beginChildren(1) -RecursiveArrayIteratorIterator::callHasChildren(1) = no/no -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>ca -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(1) -RecursiveArrayIteratorIterator::callHasChildren(0) = no/no -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -3=>d -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::valid -RecursiveArrayIterator::valid = false -===DONE=== diff --git a/ext/spl/tests/iterator_022.phpt b/ext/spl/tests/iterator_022.phpt deleted file mode 100755 index 12bec48b15..0000000000 --- a/ext/spl/tests/iterator_022.phpt +++ /dev/null @@ -1,191 +0,0 @@ ---TEST-- -SPL: RecursiveIteratorIterator and callHasChildren/callGetChildren ---FILE-- -<?php - -class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator -{ - function hasChildren() - { - return is_array($this->current()); - } - - function getChildren() - { - echo __METHOD__ . "\n"; - return $this->current(); - } - - function valid() - { - if (!parent::valid()) - { - echo __METHOD__ . " = false\n"; - return false; - } - else - { - return true; - } - } -} - -class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator -{ - private $max_depth; - private $over = 0; - private $skip = false; - - function __construct($it, $max_depth) - { - $this->max_depth = $max_depth; - parent::__construct($it); - } - - function rewind() - { - echo __METHOD__ . "\n"; - $this->skip = false; - parent::rewind(); - } - - function valid() - { - echo __METHOD__ . "\n"; - if ($this->skip) - { - $this->skip = false; - $this->next(); - } - return parent::valid(); - } - - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } - - function callHasChildren() - { - $this->skip = false; - $has = parent::callHasChildren(); - $res = $this->getDepth() < $this->max_depth && $has; - echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n"; - if ($has && !$res) - { - $this->over++; - if ($this->over == 2) { - $this->skip = true; - } - } - return $res; - } - - function callGetChildren() - { - if ($this->over == 2) - { - echo __METHOD__ . "(skip)\n"; - return NULL; - } - echo __METHOD__ . "(ok:{$this->over})\n"; - return new RecursiveArrayIterator($this->current()); - } - - function beginChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } - - function endChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } -} - -try -{ - foreach(new RecursiveArrayIteratorIterator(new RecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v) - { - if (is_array($v)) $v = join('',$v); - echo "$k=>$v\n"; - } -} -catch(UnexpectedValueException $e) -{ - echo $e->getMessage() . "\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -RecursiveArrayIteratorIterator::rewind -RecursiveArrayIteratorIterator::callHasChildren(0) = no/no -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>a -RecursiveArrayIteratorIterator::next -RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes -RecursiveArrayIteratorIterator::callGetChildren(ok:0) -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::beginChildren(1) -RecursiveArrayIteratorIterator::callHasChildren(1) = no/no -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>ba -RecursiveArrayIteratorIterator::next -RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes -RecursiveArrayIteratorIterator::callGetChildren(ok:0) -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::beginChildren(2) -RecursiveArrayIteratorIterator::callHasChildren(2) = no/no -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>bba -RecursiveArrayIteratorIterator::next -RecursiveArrayIteratorIterator::callHasChildren(2) = no/no -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -1=>bbb -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(2) -RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes -RecursiveArrayIteratorIterator::callGetChildren(ok:0) -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::beginChildren(2) -RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::current -RecursiveArrayIteratorIterator::key -0=>bcaa -RecursiveArrayIteratorIterator::next -RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes -RecursiveArrayIteratorIterator::valid -RecursiveArrayIteratorIterator::next -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(2) -RecursiveArrayIterator::valid = false -RecursiveArrayIteratorIterator::endChildren(1) -RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes -RecursiveArrayIteratorIterator::callGetChildren(skip) -Objects returned by RecursiveIterator::getChildren() must implement RecursiveIterator -===DONE=== diff --git a/ext/spl/tests/observer_001.phpt b/ext/spl/tests/observer_001.phpt deleted file mode 100755 index 3b20e25bdc..0000000000 --- a/ext/spl/tests/observer_001.phpt +++ /dev/null @@ -1,116 +0,0 @@ ---TEST-- -SPL: Observer and Subject (empty notify) ---FILE-- -<?php - -class ObserverImpl implements Observer -{ - protected $name = ''; - - function __construct($name = 'obj') - { - $this->name = '$' . $name; - } - - function update(Subject $subject) - { - echo $this->name . '->' . __METHOD__ . '(' . $subject->getName() . ");\n"; - } - - function getName() - { - return $this->name; - } -} - -class SubjectImpl implements Subject -{ - protected $name = ''; - protected $observers = array(); - - function __construct($name = 'sub') - { - $this->name = '$' . $name; - } - - function attach(Observer $observer) - { - echo '$sub->' . __METHOD__ . '(' . $observer->getName() . ");\n"; - if (!in_array($observer, $this->observers)) - { - $this->observers[] = $observer; - } - } - - function detach(Observer $observer) - { - echo '$sub->' . __METHOD__ . '(' . $observer->getName() . ");\n"; - $idx = array_search($observer, $this->observers); - if ($idx !== false) - { - unset($this->observers[$idx]); - } - } - - function notify() - { - echo '$sub->' . __METHOD__ . "();\n"; - foreach($this->observers as $observer) - { - $observer->update($this); - } - } - - function getName() - { - return $this->name; - } -} - -$sub = new SubjectImpl; - -$ob1 = new ObserverImpl("ob1"); -$ob2 = new ObserverImpl("ob2"); -$ob3 = new ObserverImpl("ob3"); - -$sub->attach($ob1); -$sub->attach($ob1); -$sub->attach($ob2); -$sub->attach($ob3); - -$sub->notify(); - -$sub->detach($ob3); - -$sub->notify(); - -$sub->detach($ob2); -$sub->detach($ob1); - -$sub->notify(); - -$sub->attach($ob3); - -$sub->notify(); -?> -===DONE=== ---EXPECT-- -$sub->SubjectImpl::attach($ob1); -$sub->SubjectImpl::attach($ob1); -$sub->SubjectImpl::attach($ob2); -$sub->SubjectImpl::attach($ob3); -$sub->SubjectImpl::notify(); -$ob1->ObserverImpl::update($sub); -$ob2->ObserverImpl::update($sub); -$ob3->ObserverImpl::update($sub); -$sub->SubjectImpl::detach($ob3); -$sub->SubjectImpl::notify(); -$ob1->ObserverImpl::update($sub); -$ob2->ObserverImpl::update($sub); -$sub->SubjectImpl::detach($ob2); -$sub->SubjectImpl::detach($ob1); -$sub->SubjectImpl::notify(); -$sub->SubjectImpl::attach($ob3); -$sub->SubjectImpl::notify(); -$ob3->ObserverImpl::update($sub); -===DONE=== diff --git a/ext/spl/tests/spl_001.phpt b/ext/spl/tests/spl_001.phpt deleted file mode 100755 index e101272a84..0000000000 --- a/ext/spl/tests/spl_001.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -SPL: iterator_to_array() and iterator_count() ---FILE-- -<?php - -$it = new ArrayObject(array("x"=>1, 1=>2, 3=>3, 4, "1"=>5)); - -$ar = iterator_to_array($it); - -var_dump(iterator_count($it)); - -print_r($ar); - -foreach($ar as $v) -{ - var_dump($v); -} - -?> -===DONE=== ---EXPECT-- -int(4) -Array -( - [x] => 1 - [1] => 5 - [3] => 3 - [4] => 4 -) -int(1) -int(5) -int(3) -int(4) -===DONE=== diff --git a/ext/spl/tests/spl_002.phpt b/ext/spl/tests/spl_002.phpt deleted file mode 100755 index d8b71b20cf..0000000000 --- a/ext/spl/tests/spl_002.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -SPL: Countable ---FILE-- -<?php - -class Test implements Countable -{ - function count() - { - return 4; - } -}; - -$a = new Test; - -var_dump(count($a)); - -?> -===DONE=== ---EXPECT-- -int(4) -===DONE=== diff --git a/ext/spl/tests/spl_003.phpt b/ext/spl/tests/spl_003.phpt deleted file mode 100755 index cadf3b5a6c..0000000000 --- a/ext/spl/tests/spl_003.phpt +++ /dev/null @@ -1,76 +0,0 @@ ---TEST-- -SPL: class_parents() and class_implements() ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -class a{} -class b extends a{} -class c extends b{} -class d{} -var_dump(class_parents(new c), - class_parents("c"), - class_parents(new b), - class_parents("b"), - class_parents("d"), - class_parents("foo", 0), - class_parents("foo", 1) -); - -interface iface1{} -interface iface2{} -class f implements iface1, iface2{} -var_dump(class_implements(new a), - class_implements("a"), - class_implements("aaa"), - class_implements("bbb", 0) -); - -function __autoload($cname) { - var_dump($cname); -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -Warning: class_parents(): Class foo does not exist in %sspl_003.php on line %d -string(3) "foo" - -Warning: class_parents(): Class foo does not exist and could not be loaded in %sspl_003.php on line %d -array(2) { - ["b"]=> - string(1) "b" - ["a"]=> - string(1) "a" -} -array(2) { - ["b"]=> - string(1) "b" - ["a"]=> - string(1) "a" -} -array(1) { - ["a"]=> - string(1) "a" -} -array(1) { - ["a"]=> - string(1) "a" -} -array(0) { -} -bool(false) -bool(false) -string(3) "aaa" - -Warning: class_implements(): Class aaa does not exist and could not be loaded in %sspl_003.php on line %d - -Warning: class_implements(): Class bbb does not exist in %sspl_003.php on line %d -array(0) { -} -array(0) { -} -bool(false) -bool(false) -===DONE===
\ No newline at end of file diff --git a/ext/spl/tests/spl_autoload_001.phpt b/ext/spl/tests/spl_autoload_001.phpt deleted file mode 100755 index 8d4c000473..0000000000 --- a/ext/spl/tests/spl_autoload_001.phpt +++ /dev/null @@ -1,136 +0,0 @@ ---TEST-- -SPL: spl_autoload() and friends ---INI-- -include_path=. ---FILE-- -<?php - -echo "===EMPTY===\n"; - -var_dump(spl_autoload_extensions()); - -try -{ - spl_autoload("TestClass"); -} -catch(Exception $e) -{ - echo 'Exception: ' . $e->getMessage() . "\n"; -} - -$test_exts = array(NULL, "1", ".inc,,.php.inc", ""); - -foreach($test_exts as $exts) -{ - echo "===($exts)===\n"; - try - { - spl_autoload("TestClass", $exts); - } - catch(Exception $e) - { - echo 'Exception: ' . $e->getMessage() . "\n"; - } -} - -try -{ - spl_autoload_extensions(".inc,.php.inc"); - spl_autoload("TestClass"); -} -catch(Exception $e) -{ - echo 'Exception: ' . $e->getMessage() . "\n"; -} - -function TestFunc1($classname) -{ - echo __METHOD__ . "($classname)\n"; -} - -function TestFunc2($classname) -{ - echo __METHOD__ . "($classname)\n"; -} - -echo "===SPL_AUTOLOAD()===\n"; - -spl_autoload_register(); - -try -{ - var_dump(spl_autoload_extensions(".inc")); - var_dump(class_exists("TestClass", true)); -} -catch(Exception $e) -{ - echo 'Exception: ' . $e->getMessage() . "\n"; -} - -echo "===REGISTER===\n"; - -spl_autoload_unregister("spl_autoload"); -spl_autoload_register("TestFunc1"); -spl_autoload_register("TestFunc2"); -spl_autoload_register("TestFunc2"); /* 2nd call ignored */ -spl_autoload_extensions(".inc,.class.inc"); /* we do not have spl_autoload_registered yet */ - -try -{ - var_dump(class_exists("TestClass", true)); -} -catch(Exception $e) -{ - echo 'Exception: ' . $e->getMessage() . "\n"; -} - -echo "===LOAD===\n"; - -spl_autoload_register("spl_autoload"); -var_dump(class_exists("TestClass", true)); - -echo "===NOFUNCTION===\n"; - -try -{ - spl_autoload_register("unavailable_autoload_function"); -} -catch(Exception $e) -{ - echo 'Exception: ' . $e->getMessage() . "\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -===EMPTY=== -string(13) ".inc,.inc.php" -%stestclass.inc -Exception: Class TestClass could not be loaded -===()=== -Exception: Class TestClass could not be loaded -===(1)=== -Exception: Class TestClass could not be loaded -===(.inc,,.php.inc)=== -%stestclass -%stestclass.php.inc -Exception: Class TestClass could not be loaded -===()=== -Exception: Class TestClass could not be loaded -Exception: Class TestClass could not be loaded -===SPL_AUTOLOAD()=== -string(4) ".inc" -Exception: Class TestClass could not be loaded -===REGISTER=== -TestFunc1(TestClass) -TestFunc2(TestClass) -bool(false) -===LOAD=== -TestFunc1(TestClass) -TestFunc2(TestClass) -%stestclass.class.inc -bool(true) -===NOFUNCTION=== -Exception: Function 'unavailable_autoload_function' not found -===DONE=== diff --git a/ext/spl/tests/spl_autoload_002.phpt b/ext/spl/tests/spl_autoload_002.phpt deleted file mode 100755 index 21caa43bfa..0000000000 --- a/ext/spl/tests/spl_autoload_002.phpt +++ /dev/null @@ -1,68 +0,0 @@ ---TEST-- -SPL: spl_autoloadfunctions() ---SKIPIF-- -<?php if (spl_autoload_functions() !== false) die('skip __autoload() registered by php.ini'); ?> ---FILE-- -<?php - -function SplAutoloadTest1($name) {} -function SplAutoloadTest2($name) {} - -var_dump(spl_autoload_functions()); - -spl_autoload_register(); - -var_dump(spl_autoload_functions()); - -spl_autoload_register('SplAutoloadTest1'); -spl_autoload_register('SplAutoloadTest2'); -spl_autoload_register('SplAutoloadTest1'); - -var_dump(spl_autoload_functions()); - -spl_autoload_unregister('SplAutoloadTest1'); - -var_dump(spl_autoload_functions()); - -spl_autoload_unregister('spl_autoload_call'); - -var_dump(spl_autoload_functions()); - -spl_autoload_register(); - -var_dump(spl_autoload_functions()); - -spl_autoload_unregister('spl_autoload'); - -var_dump(spl_autoload_functions()); - -?> -===DONE=== -<?php exit(0); ?> ---EXPECT-- -bool(false) -array(1) { - [0]=> - string(12) "spl_autoload" -} -array(3) { - [0]=> - string(12) "spl_autoload" - [1]=> - string(16) "SplAutoloadTest1" - [2]=> - string(16) "SplAutoloadTest2" -} -array(2) { - [0]=> - string(12) "spl_autoload" - [1]=> - string(16) "SplAutoloadTest2" -} -bool(false) -array(1) { - [0]=> - string(12) "spl_autoload" -} -bool(false) -===DONE=== diff --git a/ext/spl/tests/spl_autoload_003.phpt b/ext/spl/tests/spl_autoload_003.phpt deleted file mode 100755 index 00fdd2734f..0000000000 --- a/ext/spl/tests/spl_autoload_003.phpt +++ /dev/null @@ -1,44 +0,0 @@ ---TEST-- -SPL: spl_autoload() and friends ---INI-- -include_path=. ---FILE-- -<?php - -function TestFunc1($classname) -{ - echo __METHOD__ . "($classname)\n"; -} - -function TestFunc2($classname) -{ - echo __METHOD__ . "($classname)\n"; - throw new Exception("Class $classname missing"); -} - -function TestFunc3($classname) -{ - echo __METHOD__ . "($classname)\n"; -} - -spl_autoload_register("TestFunc1"); -spl_autoload_register("TestFunc2"); -spl_autoload_register("TestFunc3"); - -try -{ - var_dump(class_exists("TestClass", true)); -} -catch(Exception $e) -{ - echo 'Exception: ' . $e->getMessage() . "\n"; -} - -?> -===DONE=== -<?php exit(0); ?> ---EXPECTF-- -TestFunc1(TestClass) -TestFunc2(TestClass) -Exception: Class TestClass missing -===DONE=== diff --git a/ext/spl/tests/sxe_001.phpt b/ext/spl/tests/sxe_001.phpt deleted file mode 100755 index 88f83f2abe..0000000000 --- a/ext/spl/tests/sxe_001.phpt +++ /dev/null @@ -1,60 +0,0 @@ ---TEST-- -SPL: SimpleXMLIterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> -<?php if (!extension_loaded("simplexml")) print "skip SimpleXML not present"; ?> ---FILE-- -<?php - -$xml =<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - <elem1 attr1='first'> - <!-- comment --> - <elem2> - <elem3> - <elem4> - <?test processing instruction ?> - </elem4> - </elem3> - </elem2> - </elem1> -</sxe> -EOF; - -$sxe = simplexml_load_string($xml, 'SimpleXMLIterator'); - -print_r($sxe); - -?> -===DONE=== ---EXPECT-- -SimpleXMLIterator Object -( - [elem1] => SimpleXMLIterator Object - ( - [comment] => SimpleXMLIterator Object - ( - ) - - [elem2] => SimpleXMLIterator Object - ( - [elem3] => SimpleXMLIterator Object - ( - [elem4] => SimpleXMLIterator Object - ( - [test] => SimpleXMLIterator Object - ( - ) - - ) - - ) - - ) - - ) - -) -===DONE=== diff --git a/ext/spl/tests/sxe_002.phpt b/ext/spl/tests/sxe_002.phpt deleted file mode 100755 index b230e8cd8d..0000000000 --- a/ext/spl/tests/sxe_002.phpt +++ /dev/null @@ -1,75 +0,0 @@ ---TEST-- -SPL: SimpleXMLIterator and recursion ---SKIPIF-- -<?php - if (!extension_loaded('simplexml')) print 'skip'; - if (!class_exists('RecursiveIteratorIterator')) print 'skip RecursiveIteratorIterator not available'; -?> ---FILE-- -<?php - -$xml =<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - Plain text. - <elem1 attr1='first'> - Bla bla 1. - <!-- comment --> - <elem2> - Here we have some text data. - <elem3> - And here some more. - <elem4> - Wow once again. - </elem4> - </elem3> - </elem2> - </elem1> - <elem11 attr2='second'> - Bla bla 2. - <elem111> - Foo Bar - </elem111> - </elem11> -</sxe> -EOF; - -$sxe = simplexml_load_string($xml, 'SimpleXMLIterator'); - -foreach(new RecursiveIteratorIterator($sxe, 1) as $name => $data) { - var_dump($name); - var_dump(get_class($data)); - var_dump(trim($data)); -} - -echo "===DUMP===\n"; - -var_dump(get_class($sxe)); -var_dump(trim($sxe->elem1)); - -?> -===DONE=== ---EXPECT-- -string(5) "elem1" -string(17) "SimpleXMLIterator" -string(10) "Bla bla 1." -string(5) "elem2" -string(17) "SimpleXMLIterator" -string(28) "Here we have some text data." -string(5) "elem3" -string(17) "SimpleXMLIterator" -string(19) "And here some more." -string(5) "elem4" -string(17) "SimpleXMLIterator" -string(15) "Wow once again." -string(6) "elem11" -string(17) "SimpleXMLIterator" -string(10) "Bla bla 2." -string(7) "elem111" -string(17) "SimpleXMLIterator" -string(7) "Foo Bar" -===DUMP=== -string(17) "SimpleXMLIterator" -string(10) "Bla bla 1." -===DONE=== diff --git a/ext/spl/tests/sxe_003.phpt b/ext/spl/tests/sxe_003.phpt deleted file mode 100755 index aab7de7202..0000000000 --- a/ext/spl/tests/sxe_003.phpt +++ /dev/null @@ -1,77 +0,0 @@ ---TEST-- -SPL: SimpleXMLIterator and getChildren() ---SKIPIF-- -<?php - if (!extension_loaded('simplexml')) print 'skip'; - if (!class_exists('RecursiveIteratorIterator')) print 'skip RecursiveIteratorIterator not available'; -?> ---FILE-- -<?php - -$xml =<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - Plain text. - <elem1 attr1='first'> - Bla bla 1. - <!-- comment --> - <elem2> - Here we have some text data. - <elem3> - And here some more. - <elem4> - Wow once again. - </elem4> - </elem3> - </elem2> - </elem1> - <elem11 attr2='second'> - Bla bla 2. - <elem111> - Foo Bar - </elem111> - </elem11> -</sxe> -EOF; - -$sxe = simplexml_load_string($xml, 'SimpleXMLIterator'); - -foreach($sxe->getChildren() as $name => $data) { - var_dump($name); - var_dump(get_class($data)); - var_dump(trim($data)); -} - -echo "===RESET===\n"; - -for ($sxe->rewind(); $sxe->valid(); $sxe->next()) { - var_dump($sxe->hasChildren()); - var_dump(trim($sxe->key())); - var_dump(trim($sxe->current())); - foreach($sxe->getChildren() as $name => $data) { - var_dump($name); - var_dump(get_class($data)); - var_dump(trim($data)); - } -} - -?> -===DONE=== ---EXPECTF-- - -Warning: Invalid argument supplied for foreach() in %ssxe_003.php on line %d -===RESET=== -bool(true) -string(5) "elem1" -string(10) "Bla bla 1." -string(5) "elem2" -string(17) "SimpleXMLIterator" -string(28) "Here we have some text data." -bool(true) -string(6) "elem11" -string(10) "Bla bla 2." -string(7) "elem111" -string(17) "SimpleXMLIterator" -string(7) "Foo Bar" -===DONE=== diff --git a/ext/spl/tests/sxe_004.phpt b/ext/spl/tests/sxe_004.phpt deleted file mode 100755 index 20aa5dc8ca..0000000000 --- a/ext/spl/tests/sxe_004.phpt +++ /dev/null @@ -1,145 +0,0 @@ ---TEST-- -SPL: SimpleXMLIterator and getChildren() ---SKIPIF-- -<?php - if (!extension_loaded('simplexml')) print 'skip'; - if (!class_exists('RecursiveIteratorIterator')) print 'skip RecursiveIteratorIterator not available'; -?> ---FILE-- -<?php - -$xml =<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - Plain text. - <elem1 attr1='first'> - Bla bla 1. - <!-- comment --> - <elem2> - Here we have some text data. - <elem3> - And here some more. - <elem4> - Wow once again. - </elem4> - </elem3> - </elem2> - </elem1> - <elem11 attr2='second'> - Bla bla 2. - <elem111> - Foo Bar - </elem111> - </elem11> -</sxe> -EOF; - -class SXETest extends SimpleXMLIterator -{ - function rewind() - { - echo __METHOD__ . "\n"; - return parent::rewind(); - } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - function next() - { - echo __METHOD__ . "\n"; - return parent::next(); - } - function hasChildren() - { - echo __METHOD__ . "\n"; - return parent::hasChildren(); - } - function getChildren() - { - echo __METHOD__ . "\n"; - return parent::getChildren(); - } -} - -$sxe = new SXETest($xml); -$rit = new RecursiveIteratorIterator($sxe, RIT_SELF_FIRST); - -foreach($rit as $data) { - var_dump(get_class($data)); - var_dump(trim($data)); -} - -?> -===DONE=== ---EXPECTF-- -SXETest::rewind -SXETest::valid -SXETest::hasChildren -SXETest::valid -SXETest::current -string(7) "SXETest" -string(10) "Bla bla 1." -SXETest::getChildren -SXETest::rewind -SXETest::valid -SXETest::hasChildren -SXETest::valid -SXETest::current -string(7) "SXETest" -string(28) "Here we have some text data." -SXETest::getChildren -SXETest::rewind -SXETest::valid -SXETest::hasChildren -SXETest::valid -SXETest::current -string(7) "SXETest" -string(19) "And here some more." -SXETest::getChildren -SXETest::rewind -SXETest::valid -SXETest::hasChildren -SXETest::valid -SXETest::current -string(7) "SXETest" -string(15) "Wow once again." -SXETest::next -SXETest::valid -SXETest::next -SXETest::valid -SXETest::next -SXETest::valid -SXETest::next -SXETest::valid -SXETest::hasChildren -SXETest::valid -SXETest::current -string(7) "SXETest" -string(10) "Bla bla 2." -SXETest::getChildren -SXETest::rewind -SXETest::valid -SXETest::hasChildren -SXETest::valid -SXETest::current -string(7) "SXETest" -string(7) "Foo Bar" -SXETest::next -SXETest::valid -SXETest::next -SXETest::valid -SXETest::valid -===DONE=== diff --git a/ext/spl/tests/testclass b/ext/spl/tests/testclass deleted file mode 100755 index ceb24c877c..0000000000 --- a/ext/spl/tests/testclass +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -echo __FILE__ . "\n"; - -?>
\ No newline at end of file diff --git a/ext/spl/tests/testclass.class.inc b/ext/spl/tests/testclass.class.inc deleted file mode 100755 index f5fe7411fa..0000000000 --- a/ext/spl/tests/testclass.class.inc +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -echo __FILE__ . "\n"; - -class TestClass -{ -} - -?>
\ No newline at end of file diff --git a/ext/spl/tests/testclass.inc b/ext/spl/tests/testclass.inc deleted file mode 100755 index ceb24c877c..0000000000 --- a/ext/spl/tests/testclass.inc +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -echo __FILE__ . "\n"; - -?>
\ No newline at end of file diff --git a/ext/spl/tests/testclass.php.inc b/ext/spl/tests/testclass.php.inc deleted file mode 100755 index ceb24c877c..0000000000 --- a/ext/spl/tests/testclass.php.inc +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -echo __FILE__ . "\n"; - -?>
\ No newline at end of file |