Skip to content

Commit 1f801dc

Browse files
committed
SPL test fixes
1 parent 3e0b31a commit 1f801dc

19 files changed

+35
-107
lines changed

ext/spl/tests/SplFileInfo_setFileClass_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $info = new SplFileInfo(__FILE__);
77

88
try {
99
$info->setFileClass('stdClass');
10-
} catch (UnexpectedValueException $e) {
10+
} catch (TypeError $e) {
1111
echo $e->getMessage(), "\n";
1212
}
1313

ext/spl/tests/SplFileInfo_setInfoClass_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $info = new SplFileInfo(__FILE__);
77

88
try {
99
$info->setInfoClass('stdClass');
10-
} catch (UnexpectedValueException $e) {
10+
} catch (TypeError $e) {
1111
echo $e->getMessage(), "\n";
1212
}
1313

ext/spl/tests/SplFileObject_seek_error_001.phpt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@
22
SplFileObject::seek function - test parameters
33
--FILE--
44
<?php
5-
$obj = New SplFileObject(__FILE__);
6-
$obj->seek(1,2);
7-
$obj->seek();
5+
$obj = new SplFileObject(__FILE__);
86
try {
97
$obj->seek(-1);
108
} catch (LogicException $e) {
119
echo($e->getMessage());
1210
}
1311
?>
14-
--EXPECTF--
15-
Warning: SplFileObject::seek() expects exactly 1 parameter, 2 given in %s
16-
17-
Warning: SplFileObject::seek() expects exactly 1 parameter, 0 given in %s
12+
--EXPECT--
1813
Can't seek file %s to negative line %s

ext/spl/tests/arrayObject_asort_basic1.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ $ao1 = new ArrayObject(array(4,2,3));
1515
$ao2 = new ArrayObject(array('a'=>4,'b'=>2,'c'=>3));
1616
var_dump($ao1->asort());
1717
var_dump($ao1);
18-
var_dump($ao2->asort('blah'));
18+
try {
19+
var_dump($ao2->asort('blah'));
20+
} catch (TypeError $e) {
21+
echo $e->getMessage(), "\n";
22+
}
1923
var_dump($ao2);
2024
var_dump($ao2->asort(SORT_NUMERIC));
2125
var_dump($ao2);
@@ -35,9 +39,7 @@ object(ArrayObject)#%d (1) {
3539
int(4)
3640
}
3741
}
38-
39-
Warning: asort() expects parameter 2 to be int, string given in %sarrayObject_asort_basic1.php on line %d
40-
bool(false)
42+
asort() expects parameter 2 to be int, string given
4143
object(ArrayObject)#%d (1) {
4244
["storage":"ArrayObject":private]=>
4345
array(3) {

ext/spl/tests/arrayObject_count_basic1.phpt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ var_dump(count($c), count($ao));
2525
unset($c[0]);
2626
unset($ao[0]);
2727
var_dump($c->count(), $ao->count());
28-
29-
//Extra args are ignored.
30-
var_dump($ao->count('blah'));
3128
?>
3229
==ArrayIterator==
3330
<?php
@@ -53,11 +50,8 @@ var_dump(count($c), count($ao));
5350
unset($c[0]);
5451
unset($ao[0]);
5552
var_dump($c->count(), $ao->count());
56-
57-
//Extra args are ignored.
58-
var_dump($ao->count('blah'));
5953
?>
60-
--EXPECTF--
54+
--EXPECT--
6155
==ArrayObject==
6256
int(99)
6357
int(0)
@@ -67,9 +61,6 @@ int(99)
6761
int(2)
6862
int(99)
6963
int(1)
70-
71-
Warning: ArrayObject::count() expects exactly 0 parameters, 1 given in %s on line %d
72-
NULL
7364
==ArrayIterator==
7465
int(99)
7566
int(0)
@@ -79,6 +70,3 @@ int(99)
7970
int(2)
8071
int(99)
8172
int(1)
82-
83-
Warning: ArrayIterator::count() expects exactly 0 parameters, 1 given in %s on line %d
84-
NULL

ext/spl/tests/arrayObject_exchangeArray_basic3.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $ao = new ArrayObject($original);
2929
try {
3030
$copy = $ao->exchangeArray();
3131
$copy['addedToCopy'] = 'added To Copy';
32-
} catch (Exception $e) {
32+
} catch (TypeError $e) {
3333
echo "Exception:" . $e->getMessage() . "\n";
3434
}
3535
$original->addedToOriginal = 'added To Original';

ext/spl/tests/arrayObject_ksort_basic1.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ $ao1 = new ArrayObject(array(4,2,3));
1414
$ao2 = new ArrayObject(array('b'=>4,'a'=>2,'q'=>3, 99=>'x'));
1515
var_dump($ao1->ksort());
1616
var_dump($ao1);
17-
var_dump($ao2->ksort('blah'));
17+
try {
18+
var_dump($ao2->ksort('blah'));
19+
} catch (TypeError $e) {
20+
echo $e->getMessage(), "\n";
21+
}
1822
var_dump($ao2);
1923
var_dump($ao2->ksort(SORT_STRING));
2024
var_dump($ao2);
@@ -34,9 +38,7 @@ object(ArrayObject)#%d (1) {
3438
int(3)
3539
}
3640
}
37-
38-
Warning: ksort() expects parameter 2 to be int, string given in %sarrayObject_ksort_basic1.php on line %d
39-
bool(false)
41+
ksort() expects parameter 2 to be int, string given
4042
object(ArrayObject)#2 (1) {
4143
["storage":"ArrayObject":private]=>
4244
array(4) {

ext/spl/tests/arrayObject_setIteratorClass_error1.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ try {
88
foreach($ao as $key=>$value) {
99
echo " $key=>$value\n";
1010
}
11-
} catch (Exception $e) {
11+
} catch (TypeError $e) {
1212
var_dump($e->getMessage());
1313
}
1414

@@ -18,7 +18,7 @@ try {
1818
foreach($ao as $key=>$value) {
1919
echo " $key=>$value\n";
2020
}
21-
} catch (Exception $e) {
21+
} catch (TypeError $e) {
2222
var_dump($e->getMessage());
2323
}
2424

ext/spl/tests/bug46051.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Bug #46051 (SplFileInfo::openFile - memory overlap)
66
$x = new splfileinfo(__FILE__);
77

88
try {
9-
$x->openFile(NULL, NULL, NULL);
10-
} catch (Exception $e) { }
9+
$x->openFile(NULL, NULL, NULL);
10+
} catch (TypeError $e) { }
1111

1212
var_dump($x->getPathName());
1313
--EXPECTF--

ext/spl/tests/bug65545.phpt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ $obj = new SplFileObject(__FILE__, 'r');
66
$data = $obj->fread(5);
77
var_dump($data);
88

9-
$data = $obj->fread();
10-
var_dump($data);
11-
129
$data = $obj->fread(0);
1310
var_dump($data);
1411

@@ -20,9 +17,6 @@ var_dump(strlen($data) === filesize(__FILE__) - 5);
2017
--EXPECTF--
2118
string(5) "<?php"
2219

23-
Warning: SplFileObject::fread() expects exactly 1 parameter, 0 given in %s on line %d
24-
NULL
25-
2620
Warning: SplFileObject::fread(): Length parameter must be greater than 0 in %s on line %d
2721
bool(false)
2822
bool(true)

0 commit comments

Comments
 (0)