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