Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_ukey_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test array_intersect_ukey() function : usage variation - Passing unexpected values to first argument
! 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() : usage variation ***\n";
! 11:
! 12: //Initialise arguments
! 13: $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
! 14: $array3 = array('green' => 5, '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: //get an unset variable
! 26: $unset_var = 10;
! 27: unset ($unset_var);
! 28:
! 29: //resource variable
! 30: $fp = fopen(__FILE__, "r");
! 31:
! 32: // define some classes
! 33: class classWithToString
! 34: {
! 35: public function __toString() {
! 36: return "Class A object";
! 37: }
! 38: }
! 39:
! 40: class classWithoutToString
! 41: {
! 42: }
! 43:
! 44: // heredoc string
! 45: $heredoc = <<<EOT
! 46: hello world
! 47: EOT;
! 48:
! 49: //array of values to iterate over
! 50: $inputs = array(
! 51:
! 52: // int data
! 53: 'int 0' => 0,
! 54: 'int 1' => 1,
! 55: 'int 12345' => 12345,
! 56: 'int -12345' => -12345,
! 57:
! 58: // float data
! 59: 'float 10.5' => 10.5,
! 60: 'float -10.5' => -10.5,
! 61: 'float 12.3456789000e10' => 12.3456789000e10,
! 62: 'float -12.3456789000e10' => -12.3456789000e10,
! 63: 'float .5' => .5,
! 64:
! 65: // null data
! 66: 'uppercase NULL' => NULL,
! 67: 'lowercase null' => null,
! 68:
! 69: // boolean data
! 70: 'lowercase true' => true,
! 71: 'lowercase false' =>false,
! 72: 'uppercase TRUE' =>TRUE,
! 73: 'uppercase FALSE' =>FALSE,
! 74:
! 75: // empty data
! 76: 'empty string DQ' => "",
! 77: 'empty string SQ' => '',
! 78:
! 79: // string data
! 80: 'string DQ' => "string",
! 81: 'string SQ' => 'string',
! 82: 'mixed case string' => "sTrInG",
! 83: 'heredoc' => $heredoc,
! 84:
! 85: // object data
! 86: 'instance of classWithToString' => new classWithToString(),
! 87: 'instance of classWithoutToString' => new classWithoutToString(),
! 88:
! 89: // undefined data
! 90: 'undefined var' => @$undefined_var,
! 91:
! 92: // unset data
! 93: 'unset var' => @$unset_var,
! 94:
! 95: // resource data
! 96: 'resource var' => $fp,
! 97: );
! 98:
! 99: // loop through each element of the array for arr1
! 100:
! 101: foreach($inputs as $key =>$value) {
! 102: echo "\n--$key--\n";
! 103: var_dump( array_intersect_ukey($value, $array2, 'key_compare_func') );
! 104: var_dump( array_intersect_ukey($value, $array2, $array3, 'key_compare_func') );
! 105: };
! 106:
! 107: fclose($fp);
! 108: ?>
! 109: ===DONE===
! 110: --EXPECTF--
! 111: *** Testing array_intersect_ukey() : usage variation ***
! 112:
! 113: --int 0--
! 114:
! 115: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 116: NULL
! 117:
! 118: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 119: NULL
! 120:
! 121: --int 1--
! 122:
! 123: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 124: NULL
! 125:
! 126: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 127: NULL
! 128:
! 129: --int 12345--
! 130:
! 131: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 132: NULL
! 133:
! 134: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 135: NULL
! 136:
! 137: --int -12345--
! 138:
! 139: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 140: NULL
! 141:
! 142: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 143: NULL
! 144:
! 145: --float 10.5--
! 146:
! 147: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 148: NULL
! 149:
! 150: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 151: NULL
! 152:
! 153: --float -10.5--
! 154:
! 155: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 156: NULL
! 157:
! 158: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 159: NULL
! 160:
! 161: --float 12.3456789000e10--
! 162:
! 163: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 164: NULL
! 165:
! 166: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 167: NULL
! 168:
! 169: --float -12.3456789000e10--
! 170:
! 171: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 172: NULL
! 173:
! 174: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 175: NULL
! 176:
! 177: --float .5--
! 178:
! 179: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 180: NULL
! 181:
! 182: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 183: NULL
! 184:
! 185: --uppercase NULL--
! 186:
! 187: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 188: NULL
! 189:
! 190: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 191: NULL
! 192:
! 193: --lowercase null--
! 194:
! 195: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 196: NULL
! 197:
! 198: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 199: NULL
! 200:
! 201: --lowercase true--
! 202:
! 203: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 204: NULL
! 205:
! 206: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 207: NULL
! 208:
! 209: --lowercase false--
! 210:
! 211: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 212: NULL
! 213:
! 214: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 215: NULL
! 216:
! 217: --uppercase TRUE--
! 218:
! 219: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 220: NULL
! 221:
! 222: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 223: NULL
! 224:
! 225: --uppercase FALSE--
! 226:
! 227: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 228: NULL
! 229:
! 230: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 231: NULL
! 232:
! 233: --empty string DQ--
! 234:
! 235: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 236: NULL
! 237:
! 238: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 239: NULL
! 240:
! 241: --empty string SQ--
! 242:
! 243: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 244: NULL
! 245:
! 246: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 247: NULL
! 248:
! 249: --string DQ--
! 250:
! 251: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 252: NULL
! 253:
! 254: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 255: NULL
! 256:
! 257: --string SQ--
! 258:
! 259: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 260: NULL
! 261:
! 262: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 263: NULL
! 264:
! 265: --mixed case string--
! 266:
! 267: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 268: NULL
! 269:
! 270: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 271: NULL
! 272:
! 273: --heredoc--
! 274:
! 275: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 276: NULL
! 277:
! 278: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 279: NULL
! 280:
! 281: --instance of classWithToString--
! 282:
! 283: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 284: NULL
! 285:
! 286: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 287: NULL
! 288:
! 289: --instance of classWithoutToString--
! 290:
! 291: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 292: NULL
! 293:
! 294: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 295: NULL
! 296:
! 297: --undefined var--
! 298:
! 299: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 300: NULL
! 301:
! 302: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 303: NULL
! 304:
! 305: --unset var--
! 306:
! 307: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 308: NULL
! 309:
! 310: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 311: NULL
! 312:
! 313: --resource var--
! 314:
! 315: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 316: NULL
! 317:
! 318: Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d
! 319: NULL
! 320: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>