Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_uassoc_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_intersect_uassoc() function : usage variation - Passing unexpected values to second 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:
10: echo "*** Testing array_intersect_uassoc() : usage variation ***\n";
11:
12: // Initialise function arguments
13: $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
14: $array3 = array("a"=>"green", "brown");
15:
16: //Callback function
17: function 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;
26: unset ($unset_var);
27:
28: //resource variable
29: $fp = fopen(__FILE__, "r");
30:
31: // define some classes
32: class classWithToString
33: {
34: public function __toString() {
35: return "Class A object";
36: }
37: }
38:
39: class classWithoutToString
40: {
41: }
42:
43: // heredoc string
44: $heredoc = <<<EOT
45: hello world
46: EOT;
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
103: foreach($inputs as $key =>$value) {
104: echo "\n--$key--\n";
105: var_dump( array_intersect_uassoc($array1, $value, 'key_compare_func') );
106: var_dump( array_intersect_uassoc($array1, $value, $array3, 'key_compare_func') );
107: };
108:
109: fclose($fp);
110: ?>
111: ===DONE===
112: --EXPECTF--
113:
114: *** Testing array_intersect_uassoc() : usage variation ***
115:
116: --int 0--
117:
118: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
119: NULL
120:
121: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
122: NULL
123:
124: --int 1--
125:
126: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
127: NULL
128:
129: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
130: NULL
131:
132: --int 12345--
133:
134: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
135: NULL
136:
137: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
138: NULL
139:
140: --int -12345--
141:
142: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
143: NULL
144:
145: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
146: NULL
147:
148: --float 10.5--
149:
150: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
151: NULL
152:
153: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
154: NULL
155:
156: --float -10.5--
157:
158: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
159: NULL
160:
161: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
162: NULL
163:
164: --float 12.3456789000e10--
165:
166: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
167: NULL
168:
169: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
170: NULL
171:
172: --float -12.3456789000e10--
173:
174: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
175: NULL
176:
177: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
178: NULL
179:
180: --float .5--
181:
182: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
183: NULL
184:
185: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
186: NULL
187:
188: --uppercase NULL--
189:
190: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
191: NULL
192:
193: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
194: NULL
195:
196: --lowercase null--
197:
198: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
199: NULL
200:
201: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
202: NULL
203:
204: --lowercase true--
205:
206: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
207: NULL
208:
209: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
210: NULL
211:
212: --lowercase false--
213:
214: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
215: NULL
216:
217: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
218: NULL
219:
220: --uppercase TRUE--
221:
222: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
223: NULL
224:
225: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
226: NULL
227:
228: --uppercase FALSE--
229:
230: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
231: NULL
232:
233: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
234: NULL
235:
236: --empty string DQ--
237:
238: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
239: NULL
240:
241: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
242: NULL
243:
244: --empty string SQ--
245:
246: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
247: NULL
248:
249: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
250: NULL
251:
252: --string DQ--
253:
254: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
255: NULL
256:
257: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
258: NULL
259:
260: --string SQ--
261:
262: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
263: NULL
264:
265: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
266: NULL
267:
268: --mixed case string--
269:
270: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
271: NULL
272:
273: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
274: NULL
275:
276: --heredoc--
277:
278: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
279: NULL
280:
281: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
282: NULL
283:
284: --instance of classWithToString--
285:
286: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
287: NULL
288:
289: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
290: NULL
291:
292: --instance of classWithoutToString--
293:
294: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
295: NULL
296:
297: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
298: NULL
299:
300: --undefined var--
301:
302: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
303: NULL
304:
305: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
306: NULL
307:
308: --unset var--
309:
310: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
311: NULL
312:
313: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
314: NULL
315:
316: --resource--
317:
318: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
319: NULL
320:
321: Warning: array_intersect_uassoc(): Argument #2 is not an array in %s on line %d
322: NULL
323: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>