Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_ukey_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_intersect_ukey() function : error conditions
3: --FILE--
4: <?php
5: /* Prototype : array array_intersect_ukey(array arr1, array arr2 [, array ...], callback key_compare_func)
6: * Description: Computes the intersection of arrays using a callback function on the keys for comparison.
7: * Source code: ext/standard/array.c
8: */
9:
10: echo "*** Testing array_intersect_ukey() : error conditions ***\n";
11:
12: //Initialise arguments
13: $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
14: $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
15:
16: //Call back function
17: function key_compare_func($key1, $key2)
18: {
19: if ($key1 == $key2)
20: return 0;
21: else
22: return ($key1 > $key2)? 1:-1;
23: }
24:
25: //Test array_intersect_ukey with one more than the expected number of arguments
26: echo "\n-- Testing array_intersect_ukey() function with more than expected no. of arguments --\n";
27: $extra_arg = 10;
28: var_dump( array_intersect_ukey($array1, $array2, 'key_compare_func',$extra_arg) );
29:
30: // Testing array_intersect_ukey with one less than the expected number of arguments
31: echo "\n-- Testing array_intersect_ukey() function with less than expected no. of arguments --\n";
32: var_dump( array_intersect_ukey($array1, $array2) );
33:
34: // Testing array_intersect_ukey with no arguments
35: echo "\n-- Testing array_intersect_ukey() function with no arguments --\n";
36: var_dump( array_intersect_ukey() );
37: ?>
38: ===DONE===
39: --EXPECTF--
40: *** Testing array_intersect_ukey() : error conditions ***
41:
42: -- Testing array_intersect_ukey() function with more than expected no. of arguments --
43:
44: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
45: NULL
46:
47: -- Testing array_intersect_ukey() function with less than expected no. of arguments --
48:
49: Warning: array_intersect_ukey(): at least 3 parameters are required, 2 given in %s on line %d
50: NULL
51:
52: -- Testing array_intersect_ukey() function with no arguments --
53:
54: Warning: array_intersect_ukey(): at least 3 parameters are required, 0 given in %s on line %d
55: NULL
56: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>