1--TEST--
2array_rand() tests
3--FILE--
4<?php
5
6var_dump(array_rand());
7var_dump(array_rand(array()));
8var_dump(array_rand(array(), 0));
9var_dump(array_rand(0, 0));
10var_dump(array_rand(array(1,2,3), 0));
11var_dump(array_rand(array(1,2,3), -1));
12var_dump(array_rand(array(1,2,3), 10));
13var_dump(array_rand(array(1,2,3), 3));
14var_dump(array_rand(array(1,2,3), 2));
15
16echo "Done\n";
17?>
18--EXPECTF--
19Warning: array_rand() expects at least 1 parameter, 0 given in %s on line %d
20NULL
21
22Warning: array_rand(): Array is empty in %s on line %d
23NULL
24
25Warning: array_rand(): Array is empty in %s on line %d
26NULL
27
28Warning: array_rand() expects parameter 1 to be array, int given in %s on line %d
29NULL
30
31Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d
32NULL
33
34Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d
35NULL
36
37Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d
38NULL
39array(3) {
40  [0]=>
41  int(%d)
42  [1]=>
43  int(%d)
44  [2]=>
45  int(%d)
46}
47array(2) {
48  [0]=>
49  int(%d)
50  [1]=>
51  int(%d)
52}
53Done
54