Return to array_diff_ukey_error.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array |
1.1 misho 1: --TEST-- 2: Test array_diff_ukey() function : error conditions 3: --FILE-- 4: <?php 5: /* Prototype : array array_diff_ukey(array arr1, array arr2 [, array ...], callback key_comp_func) 6: * Description: Returns the entries of arr1 that have keys which are not present in any of the others arguments. 7: * Source code: ext/standard/array.c 8: */ 9: 10: echo "*** Testing array_diff_ukey() : error conditions ***\n"; 11: 12: // Initialize 13: $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); 14: $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); 15: $extra_arg = 10; 16: 17: function key_compare_func($key1, $key2) 18: { 19: if ($key1 == $key2) { 20: return 0; 21: } 22: return ($key1 > $key2)? 1:-1; 23: } 24: 25: //Test array_diff_ukey with one more than the expected number of arguments 26: echo "\n-- Testing array_diff_ukey() function with more than expected no. of arguments --\n"; 27: var_dump( array_diff_ukey($array1, $array2, 'key_compare_func', $extra_arg) ); 28: 29: // Testing array_diff_ukey with one less than the expected number of arguments 30: echo "\n-- Testing array_diff_ukey() function with less than expected no. of arguments --\n"; 31: var_dump( array_diff_ukey($array1, $array2) ); 32: 33: // Testing array_diff_ukey with one less than the expected number of arguments 34: echo "\n-- Testing array_diff_ukey() function with no arguments --\n"; 35: var_dump( array_diff_ukey() ); 36: ?> 37: ===DONE=== 38: --EXPECTF-- 39: *** Testing array_diff_ukey() : error conditions *** 40: 41: -- Testing array_diff_ukey() function with more than expected no. of arguments -- 42: 43: Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d 44: NULL 45: 46: -- Testing array_diff_ukey() function with less than expected no. of arguments -- 47: 48: Warning: array_diff_ukey(): at least 3 parameters are required, 2 given in %s on line %d 49: NULL 50: 51: -- Testing array_diff_ukey() function with no arguments -- 52: 53: Warning: array_diff_ukey(): at least 3 parameters are required, 0 given in %s on line %d 54: NULL 55: ===DONE===