1--TEST--
2Test array_rand() function : error conditions
3--FILE--
4<?php
5/* Prototype  : mixed array_rand(array input [, int num_req])
6 * Description: Return key/keys for random entry/entries in the array
7 * Source code: ext/standard/array.c
8*/
9
10echo "*** Testing array_rand() : error conditions ***\n";
11
12// Zero arguments
13echo "\n-- Testing array_rand() function with Zero arguments --\n";
14var_dump( array_rand() );
15
16//Test array_rand with one more than the expected number of arguments
17echo "\n-- Testing array_rand() function with more than expected no. of arguments --\n";
18$input = array(1, 2);
19$num_req = 10;
20$extra_arg = 10;
21var_dump( array_rand($input,$num_req, $extra_arg) );
22
23echo "Done";
24?>
25--EXPECTF--
26*** Testing array_rand() : error conditions ***
27
28-- Testing array_rand() function with Zero arguments --
29
30Warning: array_rand() expects at least 1 parameter, 0 given in %s on line %d
31NULL
32
33-- Testing array_rand() function with more than expected no. of arguments --
34
35Warning: array_rand() expects at most 2 parameters, 3 given in %s on line %d
36NULL
37Done
38