Skip to content

Commit 117f876

Browse files
committed
ext/spl: ArrayObject improve ZPP test for usort() methods
1 parent 11a9574 commit 117f876

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed
Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
--TEST--
2-
Test ArrayObject::uasort() function : wrong arg count
2+
ArrayObject::uasort() function: non callable error
33
--FILE--
44
<?php
5-
/* Sort the entries by values user defined function.
6-
* Source code: ext/spl/spl_array.c
7-
* Alias to functions:
8-
*/
95

106
$ao = new ArrayObject();
117

128
try {
13-
$ao->uasort();
14-
} catch (ArgumentCountError $e) {
15-
echo $e->getMessage() . "\n";
9+
$ao->uasort('not_a_valid_function');
10+
} catch (Throwable $e) {
11+
echo $e::class, ': ', $e->getMessage(), "\n";
1612
}
1713

18-
try {
19-
$ao->uasort(1,2);
20-
} catch (ArgumentCountError $e) {
21-
echo $e->getMessage() . "\n";
22-
}
2314
?>
2415
--EXPECT--
25-
ArrayObject::uasort() expects exactly 1 argument, 0 given
26-
ArrayObject::uasort() expects exactly 1 argument, 2 given
16+
TypeError: uasort(): Argument #2 ($callback) must be a valid callback, function "not_a_valid_function" not found or invalid function name
Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
--TEST--
2-
Test ArrayObject::uksort() function : wrong arg count
2+
ArrayObject::uksort() function: non callable error
33
--FILE--
44
<?php
5-
/* Sort the entries by key using user defined function.
6-
* Source code: ext/spl/spl_array.c
7-
* Alias to functions:
8-
*/
95

106
$ao = new ArrayObject();
117

128
try {
13-
$ao->uksort();
14-
} catch (ArgumentCountError $e) {
15-
echo $e->getMessage() . "\n";
9+
$ao->uksort('not_a_valid_function');
10+
} catch (Throwable $e) {
11+
echo $e::class, ': ', $e->getMessage(), "\n";
1612
}
1713

18-
try {
19-
$ao->uksort(1,2);
20-
} catch (ArgumentCountError $e) {
21-
echo $e->getMessage() . "\n";
22-
}
2314
?>
2415
--EXPECT--
25-
ArrayObject::uksort() expects exactly 1 argument, 0 given
26-
ArrayObject::uksort() expects exactly 1 argument, 2 given
16+
TypeError: uksort(): Argument #2 ($callback) must be a valid callback, function "not_a_valid_function" not found or invalid function name

0 commit comments

Comments
 (0)