1--TEST--
2Test usort() function : error conditions - Pass incorrect number of arguments
3--FILE--
4<?php
5/* Prototype  : bool usort(array $array_arg, string $cmp_function)
6 * Description: Sort an array by values using a user-defined comparison function
7 * Source code: ext/standard/array.c
8 */
9
10/*
11 * Pass incorrect number of arguments to usort() to test behaviour
12 */
13
14echo "*** Testing usort() : error conditions ***\n";
15
16//Test usort with one more than the expected number of arguments
17echo "\n-- Testing usort() function with more than expected no. of arguments --\n";
18$array_arg = array(1, 2);
19$cmp_function = 'string_val';
20$extra_arg = 10;
21var_dump( usort($array_arg, $cmp_function, $extra_arg) );
22
23// Testing usort with one less than the expected number of arguments
24echo "\n-- Testing usort() function with less than expected no. of arguments --\n";
25$array_arg = array(1, 2);
26var_dump( usort($array_arg) );
27?>
28===DONE===
29--EXPECTF--
30*** Testing usort() : error conditions ***
31
32-- Testing usort() function with more than expected no. of arguments --
33
34Warning: usort() expects exactly 2 parameters, 3 given in %s on line %d
35NULL
36
37-- Testing usort() function with less than expected no. of arguments --
38
39Warning: usort() expects exactly 2 parameters, 1 given in %s on line %d
40NULL
41===DONE===
42