1--TEST--
2Test array_intersect_uassoc() function : error conditions
3--FILE--
4<?php
5/* Prototype  : array array_intersect_uassoc(array arr1, array arr2 [, array ...], callback key_compare_func)
6 * Description: Computes the intersection of arrays with additional index check, compares indexes by a callback function
7 * Source code: ext/standard/array.c
8 */
9
10echo "*** Testing array_intersect_uassoc() : error conditions ***\n";
11
12// Initialise function arguments
13$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
14$array2 = array("a" => "green", "yellow", "red");
15$array3 = array("a"=>"green", "brown");
16$extra_arg = 10;
17
18//Callback function
19function key_compare_func($a, $b) {
20    if ($a === $b) {
21        return 0;
22    }
23    return ($a > $b) ? 1 : -1;
24}
25
26//Test array_intersect_uassoc with one more than the expected number of arguments
27echo "\n-- Testing array_intersect_uassoc() function with more than expected no. of arguments --\n";
28var_dump( array_intersect_uassoc($array1, $array2, 'key_compare_func',$extra_arg) );
29
30// Testing array_intersect_uassoc with one less than the expected number of arguments
31echo "\n-- Testing array_intersect_uassoc() function with less than expected no. of arguments --\n";
32var_dump( array_intersect_uassoc($array1, $array2) );
33var_dump( array_intersect_uassoc($array1, $array2, $array3) );
34
35// Testing array_intersect_uassoc with no arguments
36echo "\n-- Testing array_intersect_uassoc() function with no arguments --\n";
37var_dump( array_intersect_uassoc() );
38?>
39===DONE===
40--EXPECTF--
41*** Testing array_intersect_uassoc() : error conditions ***
42
43-- Testing array_intersect_uassoc() function with more than expected no. of arguments --
44
45Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
46NULL
47
48-- Testing array_intersect_uassoc() function with less than expected no. of arguments --
49
50Warning: array_intersect_uassoc(): at least 3 parameters are required, 2 given in %s on line %d
51NULL
52
53Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, second array member is not a valid method in %s on line %d
54NULL
55
56-- Testing array_intersect_uassoc() function with no arguments --
57
58Warning: array_intersect_uassoc(): at least 3 parameters are required, 0 given in %s on line %d
59NULL
60===DONE===
61