summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/array_rand_variation5.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/tests/array/array_rand_variation5.phpt')
-rw-r--r--ext/standard/tests/array/array_rand_variation5.phpt48
1 files changed, 30 insertions, 18 deletions
diff --git a/ext/standard/tests/array/array_rand_variation5.phpt b/ext/standard/tests/array/array_rand_variation5.phpt
index 30eb7d7801..03e20d6e07 100644
--- a/ext/standard/tests/array/array_rand_variation5.phpt
+++ b/ext/standard/tests/array/array_rand_variation5.phpt
@@ -32,17 +32,36 @@ var_dump( array_rand($input, 1) ); // with valid $num_req value
// with invalid num_req value
echo"\n-- With num_req = 0 --\n";
-var_dump( array_rand($input, 0) ); // with $num_req=0
+try {
+ var_dump( array_rand($input, 0) ); // with $num_req=0
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
+
echo"\n-- With num_req = -1 --\n";
-var_dump( array_rand($input, -1) ); // with $num_req=-1
+try {
+ var_dump( array_rand($input, -1) ); // with $num_req=-1
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
+
echo"\n-- With num_req = -2 --\n";
-var_dump( array_rand($input, -2) ); // with $num_req=-2
-echo"\n-- With num_req more than number of members in 'input' array --\n";
-var_dump( array_rand($input, 13) ); // with $num_req=13
+try {
+ var_dump( array_rand($input, -2) ); // with $num_req=-2
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
+echo"\n-- With num_req more than number of members in 'input' array --\n";
+try {
+ var_dump( array_rand($input, 13) ); // with $num_req=13
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
-echo "Done";
?>
+
+DONE
--EXPECTF--
*** Testing array_rand() : with invalid values for 'req_num' ***
@@ -53,22 +72,15 @@ int(%d)
int(%d)
-- With num_req = 0 --
-
-Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d
-NULL
+Second argument has to be between 1 and the number of elements in the array
-- With num_req = -1 --
-
-Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d
-NULL
+Second argument has to be between 1 and the number of elements in the array
-- With num_req = -2 --
-
-Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d
-NULL
+Second argument has to be between 1 and the number of elements in the array
-- With num_req more than number of members in 'input' array --
+Second argument has to be between 1 and the number of elements in the array
-Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d
-NULL
-Done
+DONE