Return to array_udiff_uassoc_variation4.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array |
1.1 misho 1: --TEST-- 2: Test array_udiff_uassoc() function : usage variation 3: --FILE-- 4: <?php 5: /* Prototype : array array_udiff_uassoc(array arr1, array arr2 [, array ...], callback data_comp_func, 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 and elements are compared by user supplied functions. 7: * Source code: ext/standard/array.c 8: * Alias to functions: 9: */ 10: 11: echo "*** Testing array_udiff_uassoc() : usage variation ***\n"; 12: 13: // Initialise function arguments not being substituted (if any) 14: $arr1 = array(1, 2); 15: $arr2 = array(1, 2); 16: 17: include('compare_function.inc'); 18: $data_comp_func = 'compare_function'; 19: 20: //get an unset variable 21: $unset_var = 10; 22: unset ($unset_var); 23: 24: // define some classes 25: class classWithToString 26: { 27: public function __toString() { 28: return "Class A object"; 29: } 30: } 31: 32: class classWithoutToString 33: { 34: } 35: 36: // heredoc string 37: $heredoc = <<<EOT 38: hello world 39: EOT; 40: 41: // add arrays 42: $index_array = array (1, 2, 3); 43: $assoc_array = array ('one' => 1, 'two' => 2); 44: 45: //array of values to iterate over 46: $inputs = array( 47: 48: // int data 49: 'int 0' => 0, 50: 'int 1' => 1, 51: 'int 12345' => 12345, 52: 'int -12345' => -2345, 53: 54: // float data 55: 'float 10.5' => 10.5, 56: 'float -10.5' => -10.5, 57: 'float 12.3456789000e10' => 12.3456789000e10, 58: 'float -12.3456789000e10' => -12.3456789000e10, 59: 'float .5' => .5, 60: 61: // array data 62: 'empty array' => array(), 63: 'int indexed array' => $index_array, 64: 'associative array' => $assoc_array, 65: 'nested arrays' => array('foo', $index_array, $assoc_array), 66: 67: // null data 68: 'uppercase NULL' => NULL, 69: 'lowercase null' => null, 70: 71: // boolean data 72: 'lowercase true' => true, 73: 'lowercase false' =>false, 74: 'uppercase TRUE' =>TRUE, 75: 'uppercase FALSE' =>FALSE, 76: 77: // empty data 78: 'empty string DQ' => "", 79: 'empty string SQ' => '', 80: 81: // string data 82: 'string DQ' => "string", 83: 'string SQ' => 'string', 84: 'mixed case string' => "sTrInG", 85: 'heredoc' => $heredoc, 86: 87: // object data 88: 'instance of classWithToString' => new classWithToString(), 89: 'instance of classWithoutToString' => new classWithoutToString(), 90: 91: // undefined data 92: 'undefined var' => @$undefined_var, 93: 94: // unset data 95: 'unset var' => @$unset_var, 96: ); 97: 98: // loop through each element of the array for key_comp_func 99: 100: foreach($inputs as $key =>$value) { 101: echo "\n--$key--\n"; 102: var_dump( array_udiff_uassoc($arr1, $arr2, $data_comp_func, $value) ); 103: }; 104: 105: ?> 106: ===DONE=== 107: --EXPECTF-- 108: *** Testing array_udiff_uassoc() : usage variation *** 109: 110: --int 0-- 111: 112: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 113: NULL 114: 115: --int 1-- 116: 117: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 118: NULL 119: 120: --int 12345-- 121: 122: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 123: NULL 124: 125: --int -12345-- 126: 127: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 128: NULL 129: 130: --float 10.5-- 131: 132: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 133: NULL 134: 135: --float -10.5-- 136: 137: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 138: NULL 139: 140: --float 12.3456789000e10-- 141: 142: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 143: NULL 144: 145: --float -12.3456789000e10-- 146: 147: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 148: NULL 149: 150: --float .5-- 151: 152: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 153: NULL 154: 155: --empty array-- 156: 157: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, array must have exactly two members in %sarray_udiff_uassoc_variation4.php on line %d 158: NULL 159: 160: --int indexed array-- 161: 162: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, array must have exactly two members in %sarray_udiff_uassoc_variation4.php on line %d 163: NULL 164: 165: --associative array-- 166: 167: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, first array member is not a valid class name or object in %sarray_udiff_uassoc_variation4.php on line %d 168: NULL 169: 170: --nested arrays-- 171: 172: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, array must have exactly two members in %sarray_udiff_uassoc_variation4.php on line %d 173: NULL 174: 175: --uppercase NULL-- 176: 177: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 178: NULL 179: 180: --lowercase null-- 181: 182: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 183: NULL 184: 185: --lowercase true-- 186: 187: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 188: NULL 189: 190: --lowercase false-- 191: 192: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 193: NULL 194: 195: --uppercase TRUE-- 196: 197: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 198: NULL 199: 200: --uppercase FALSE-- 201: 202: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 203: NULL 204: 205: --empty string DQ-- 206: 207: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, function '' not found or invalid function name in %sarray_udiff_uassoc_variation4.php on line %d 208: NULL 209: 210: --empty string SQ-- 211: 212: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, function '' not found or invalid function name in %sarray_udiff_uassoc_variation4.php on line %d 213: NULL 214: 215: --string DQ-- 216: 217: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, function 'string' not found or invalid function name in %sarray_udiff_uassoc_variation4.php on line %d 218: NULL 219: 220: --string SQ-- 221: 222: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, function 'string' not found or invalid function name in %sarray_udiff_uassoc_variation4.php on line %d 223: NULL 224: 225: --mixed case string-- 226: 227: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, function 'sTrInG' not found or invalid function name in %sarray_udiff_uassoc_variation4.php on line %d 228: NULL 229: 230: --heredoc-- 231: 232: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, function 'hello world' not found or invalid function name in %sarray_udiff_uassoc_variation4.php on line %d 233: NULL 234: 235: --instance of classWithToString-- 236: 237: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 238: NULL 239: 240: --instance of classWithoutToString-- 241: 242: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 243: NULL 244: 245: --undefined var-- 246: 247: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 248: NULL 249: 250: --unset var-- 251: 252: Warning: array_udiff_uassoc() expects parameter 4 to be a valid callback, no array or string given in %sarray_udiff_uassoc_variation4.php on line %d 253: NULL 254: ===DONE===