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