Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_variation2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test array_intersect() function : usage variations - unexpected values for 'arr2' argument
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
! 6: * Description: Returns the entries of arr1 that have values which are present in all the other arguments
! 7: * Source code: ext/standard/array.c
! 8: */
! 9:
! 10: /*
! 11: * Testing array_intersect() function by passing values to $arr2 argument other than arrays
! 12: * and see that function emits proper warning messages wherever expected.
! 13: * The $arr1 argument is a fixed array.
! 14: */
! 15:
! 16: echo "*** Testing array_intersect() : Passing non-array values to \$arr2 argument ***\n";
! 17:
! 18: // array to be passsed to $arr1 as default argument
! 19: $arr1 = array(1, 2);
! 20:
! 21: // arrays to be passed to optional argument
! 22: $arr3 = array(1, 2, "one" => 1, "two" => 2);
! 23:
! 24: // get an unset variable
! 25: $unset_var = 10;
! 26: unset ($unset_var);
! 27:
! 28: // get a class
! 29: class classA
! 30: {
! 31: public function __toString() {
! 32: return "Class A object";
! 33: }
! 34: }
! 35:
! 36: // heredoc string
! 37: $heredoc = <<<EOT
! 38: hello world
! 39: EOT;
! 40:
! 41: // get a resource variable
! 42: $fp = fopen(__FILE__, "r");
! 43:
! 44: // unexpected values to be passed to $arr2 argument
! 45: $arrays = array(
! 46:
! 47: // int data
! 48: /*1*/ 0,
! 49: 1,
! 50: 12345,
! 51: -2345,
! 52:
! 53: // float data
! 54: /*5*/ 10.5,
! 55: -10.5,
! 56: 12.3456789000e10,
! 57: 12.3456789000E-10,
! 58: .5,
! 59:
! 60: // null data
! 61: /*10*/ NULL,
! 62: null,
! 63:
! 64: // boolean data
! 65: /*12*/ true,
! 66: false,
! 67: TRUE,
! 68: FALSE,
! 69:
! 70: // empty data
! 71: /*16*/ "",
! 72: '',
! 73:
! 74: // string data
! 75: /*18*/ "string",
! 76: 'string',
! 77: $heredoc,
! 78:
! 79: // object data
! 80: /*21*/ new classA(),
! 81:
! 82: // undefined data
! 83: /*22*/ @$undefined_var,
! 84:
! 85: // unset data
! 86: /*23*/ @$unset_var,
! 87:
! 88: // resource variable
! 89: /*24*/ $fp
! 90: );
! 91:
! 92: // loop through each sub-array within $arrrays to check the behavior of array_intersect()
! 93: $iterator = 1;
! 94: foreach($arrays as $unexpected_value) {
! 95: echo "\n-- Iterator $iterator --";
! 96:
! 97: // Calling array_intersect() with default arguments
! 98: var_dump( array_intersect($arr1,$unexpected_value) );
! 99:
! 100: // Calling array_intersect() with more arguments
! 101: var_dump( array_intersect($arr1, $unexpected_value, $arr3) );
! 102:
! 103: $iterator++;
! 104: }
! 105:
! 106: // close the file resource used
! 107: fclose($fp);
! 108:
! 109: echo "Done";
! 110: ?>
! 111: --EXPECTF--
! 112: *** Testing array_intersect() : Passing non-array values to $arr2 argument ***
! 113:
! 114: -- Iterator 1 --
! 115: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 116: NULL
! 117:
! 118: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 119: NULL
! 120:
! 121: -- Iterator 2 --
! 122: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 123: NULL
! 124:
! 125: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 126: NULL
! 127:
! 128: -- Iterator 3 --
! 129: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 130: NULL
! 131:
! 132: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 133: NULL
! 134:
! 135: -- Iterator 4 --
! 136: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 137: NULL
! 138:
! 139: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 140: NULL
! 141:
! 142: -- Iterator 5 --
! 143: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 144: NULL
! 145:
! 146: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 147: NULL
! 148:
! 149: -- Iterator 6 --
! 150: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 151: NULL
! 152:
! 153: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 154: NULL
! 155:
! 156: -- Iterator 7 --
! 157: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 158: NULL
! 159:
! 160: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 161: NULL
! 162:
! 163: -- Iterator 8 --
! 164: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 165: NULL
! 166:
! 167: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 168: NULL
! 169:
! 170: -- Iterator 9 --
! 171: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 172: NULL
! 173:
! 174: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 175: NULL
! 176:
! 177: -- Iterator 10 --
! 178: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 179: NULL
! 180:
! 181: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 182: NULL
! 183:
! 184: -- Iterator 11 --
! 185: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 186: NULL
! 187:
! 188: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 189: NULL
! 190:
! 191: -- Iterator 12 --
! 192: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 193: NULL
! 194:
! 195: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 196: NULL
! 197:
! 198: -- Iterator 13 --
! 199: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 200: NULL
! 201:
! 202: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 203: NULL
! 204:
! 205: -- Iterator 14 --
! 206: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 207: NULL
! 208:
! 209: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 210: NULL
! 211:
! 212: -- Iterator 15 --
! 213: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 214: NULL
! 215:
! 216: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 217: NULL
! 218:
! 219: -- Iterator 16 --
! 220: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 221: NULL
! 222:
! 223: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 224: NULL
! 225:
! 226: -- Iterator 17 --
! 227: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 228: NULL
! 229:
! 230: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 231: NULL
! 232:
! 233: -- Iterator 18 --
! 234: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 235: NULL
! 236:
! 237: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 238: NULL
! 239:
! 240: -- Iterator 19 --
! 241: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 242: NULL
! 243:
! 244: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 245: NULL
! 246:
! 247: -- Iterator 20 --
! 248: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 249: NULL
! 250:
! 251: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 252: NULL
! 253:
! 254: -- Iterator 21 --
! 255: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 256: NULL
! 257:
! 258: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 259: NULL
! 260:
! 261: -- Iterator 22 --
! 262: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 263: NULL
! 264:
! 265: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 266: NULL
! 267:
! 268: -- Iterator 23 --
! 269: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 270: NULL
! 271:
! 272: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 273: NULL
! 274:
! 275: -- Iterator 24 --
! 276: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 277: NULL
! 278:
! 279: Warning: array_intersect(): Argument #2 is not an array in %s on line %d
! 280: NULL
! 281: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>