Annotation of embedaddon/php/ext/standard/tests/array/shuffle_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test shuffle() function : error conditions
3: --FILE--
4: <?php
5: /* Prototype : bool shuffle(array $array_arg)
6: * Description: Randomly shuffle the contents of an array
7: * Source code: ext/standard/array.c
8: */
9:
10: /* Test shuffle() to see that warning messages are emitted
11: * when invalid number of arguments are passed to the function
12: */
13:
14: echo "*** Testing shuffle() : error conditions ***\n";
15:
16: // zero arguments
17: echo "\n-- Testing shuffle() function with Zero arguments --\n";
18: var_dump( shuffle() );
19:
20: // more than the expected number of arguments
21: echo "\n-- Testing shuffle() function with more than expected no. of arguments --\n";
22: $array_arg = array(1, "two" => 2);
23: $extra_arg = 10;
24: var_dump( shuffle($array_arg, $extra_arg) );
25:
26: // printing the input array to check that it is not affected
27: // by above shuffle() function calls
28: echo "\n-- original input array --\n";
29: var_dump( $array_arg );
30:
31: echo "Done";
32: ?>
33: --EXPECTF--
34: *** Testing shuffle() : error conditions ***
35:
36: -- Testing shuffle() function with Zero arguments --
37:
38: Warning: shuffle() expects exactly 1 parameter, 0 given in %s on line %d
39: bool(false)
40:
41: -- Testing shuffle() function with more than expected no. of arguments --
42:
43: Warning: shuffle() expects exactly 1 parameter, 2 given in %s on line %d
44: bool(false)
45:
46: -- original input array --
47: array(2) {
48: [0]=>
49: int(1)
50: ["two"]=>
51: int(2)
52: }
53: Done
54:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>