1--TEST--
2Test krsort() function : error conditions
3--FILE--
4<?php
5/* Prototype  : bool krsort(array &array_arg [, int asort_flags])
6 * Description: Sort an array
7 * Source code: ext/standard/array.c
8*/
9
10/*
11* Testing krsort() function with all possible error conditions
12*/
13
14echo "*** Testing krsort() : error conditions ***\n";
15
16// Zero arguments
17echo "\n-- Testing krsort() function with zero arguments --\n";
18var_dump( krsort() );
19
20//Test krsort with more than the expected number of arguments
21echo "\n-- Testing krsort() function with more than expected no. of arguments --\n";
22$array_arg = array(1 => 1, 2 => 2);
23$flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING, "SORT_NUMERIC" => SORT_NUMERIC);
24$extra_arg = 10;
25
26// loop through $flag_value array and call krsort with all possible sort flag values
27foreach($flags as $key => $flag){
28  echo "\n- Sort flag = $key -\n";
29  $temp_array = $array_arg;
30  var_dump( krsort($temp_array,$flag, $extra_arg) );
31  var_dump($temp_array);
32}
33
34echo "Done";
35?>
36--EXPECTF--
37*** Testing krsort() : error conditions ***
38
39-- Testing krsort() function with zero arguments --
40
41Warning: krsort() expects at least 1 parameter, 0 given in %s on line %d
42bool(false)
43
44-- Testing krsort() function with more than expected no. of arguments --
45
46- Sort flag = SORT_REGULAR -
47
48Warning: krsort() expects at most 2 parameters, 3 given in %s on line %d
49bool(false)
50array(2) {
51  [1]=>
52  int(1)
53  [2]=>
54  int(2)
55}
56
57- Sort flag = SORT_STRING -
58
59Warning: krsort() expects at most 2 parameters, 3 given in %s on line %d
60bool(false)
61array(2) {
62  [1]=>
63  int(1)
64  [2]=>
65  int(2)
66}
67
68- Sort flag = SORT_NUMERIC -
69
70Warning: krsort() expects at most 2 parameters, 3 given in %s on line %d
71bool(false)
72array(2) {
73  [1]=>
74  int(1)
75  [2]=>
76  int(2)
77}
78Done
79