1--TEST--
2Test array_udiff_assoc() function : usage variation - incorrect comparison functions
3--FILE--
4<?php
5/* Prototype  : array array_udiff_assoc(array arr1, array arr2 [, array ...], callback key_comp_func)
6 * Description: Returns the entries of arr1 that have values which are not present in any of the others arguments but do additional checks whether the keys are equal. Keys are compared by user supplied function.
7 * Source code: ext/standard/array.c
8 * Alias to functions:
9 */
10
11
12echo "*** Testing array_udiff_assoc() : usage variation - differing comparison functions***\n";
13
14$arr1 = array(1);
15$arr2 = array(1,2);
16
17echo "\n-- comparison function with an incorrect return value --\n";
18function incorrect_return_value ($val1, $val2) {
19  return array(1);
20}
21var_dump(array_udiff_assoc($arr1, $arr2, 'incorrect_return_value'));
22
23echo "\n-- comparison function taking too many parameters --\n";
24function too_many_parameters ($val1, $val2, $val3) {
25  return 1;
26}
27var_dump(array_udiff_assoc($arr1, $arr2, 'too_many_parameters'));
28
29echo "\n-- comparison function taking too few parameters --\n";
30function too_few_parameters ($val1) {
31  return 1;
32}
33var_dump(array_udiff_assoc($arr1, $arr2, 'too_few_parameters'));
34
35
36?>
37===DONE===
38--EXPECTF--
39*** Testing array_udiff_assoc() : usage variation - differing comparison functions***
40
41-- comparison function with an incorrect return value --
42array(1) {
43  [0]=>
44  int(1)
45}
46
47-- comparison function taking too many parameters --
48
49Warning: Missing argument 3 for too_many_parameters() in %sarray_udiff_assoc_variation5.php on line %d
50array(1) {
51  [0]=>
52  int(1)
53}
54
55-- comparison function taking too few parameters --
56array(1) {
57  [0]=>
58  int(1)
59}
60===DONE===
61