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