Annotation of embedaddon/php/ext/standard/tests/array/array_diff_uassoc_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_diff_uassoc() function : usage variation -Passing unexpected values to callback argument
3: --FILE--
4: <?php
5: /* Prototype : array array_diff_uassoc(array arr1, array arr2 [, array ...], callback key_comp_func)
6: * Description: Computes the difference of arrays with additional index check which is performed by a
7: * user supplied callback function
8: * Source code: ext/standard/array.c
9: */
10:
11: echo "*** Testing array_diff_uassoc() : usage variation ***\n";
12:
13: //Initialize array
14: $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
15: $array2 = array("a" => "green", "yellow", "red");
16:
17: //get an unset variable
18: $unset_var = 10;
19: unset ($unset_var);
20:
21: //resource variable
22: $fp = fopen(__FILE__, "r");
23:
24: // define some classes
25: class classWithToString
26: {
27: public function __toString() {
28: return "Class A object";
29: }
30: }
31:
32: class classWithoutToString
33: {
34: }
35:
36: // heredoc string
37: $heredoc = <<<EOT
38: hello world
39: EOT;
40:
41: // add arrays
42: $index_array = array (1, 2, 3);
43: $assoc_array = array ('one' => 1, 'two' => 2);
44:
45: //array of values to iterate over
46: $inputs = array(
47:
48: // int data
49: 'int 0' => 0,
50: 'int 1' => 1,
51: 'int 12345' => 12345,
52: 'int -12345' => -12345,
53:
54: // float data
55: 'float 10.5' => 10.5,
56: 'float -10.5' => -10.5,
57: 'float 12.3456789000e10' => 12.3456789000e10,
58: 'float -12.3456789000e10' => -12.3456789000e10,
59: 'float .5' => .5,
60:
61: // array data
62: 'empty array' => array(),
63: 'int indexed array' => $index_array,
64: 'associative array' => $assoc_array,
65: 'nested arrays' => array('foo', $index_array, $assoc_array),
66:
67: // null data
68: 'uppercase NULL' => NULL,
69: 'lowercase null' => null,
70:
71: // boolean data
72: 'lowercase true' => true,
73: 'lowercase false' =>false,
74: 'uppercase TRUE' =>TRUE,
75: 'uppercase FALSE' =>FALSE,
76:
77: // empty data
78: 'empty string DQ' => "",
79: 'empty string SQ' => '',
80:
81: // string data
82: 'string DQ' => "string",
83: 'string SQ' => 'string',
84: 'mixed case string' => "sTrInG",
85: 'heredoc' => $heredoc,
86:
87: // object data
88: 'instance of classWithToString' => new classWithToString(),
89: 'instance of classWithoutToString' => new classWithoutToString(),
90:
91: // undefined data
92: 'undefined var' => @$undefined_var,
93:
94: // unset data
95: 'unset var' => @$unset_var,
96:
97: // resource data
98: 'resource' => $fp,
99: );
100:
101: // loop through each element of the array for key_comp_func
102:
103: foreach($inputs as $key =>$value) {
104: echo "\n--$key--\n";
105: var_dump( array_diff_uassoc($array1, $array2, $value) );
106: };
107:
108: fclose($fp);
109: ?>
110: ===DONE===
111: --EXPECTF--
112: *** Testing array_diff_uassoc() : usage variation ***
113:
114: --int 0--
115:
116: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
117: NULL
118:
119: --int 1--
120:
121: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
122: NULL
123:
124: --int 12345--
125:
126: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
127: NULL
128:
129: --int -12345--
130:
131: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
132: NULL
133:
134: --float 10.5--
135:
136: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
137: NULL
138:
139: --float -10.5--
140:
141: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
142: NULL
143:
144: --float 12.3456789000e10--
145:
146: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
147: NULL
148:
149: --float -12.3456789000e10--
150:
151: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
152: NULL
153:
154: --float .5--
155:
156: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
157: NULL
158:
159: --empty array--
160:
161: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, array must have exactly two members in %s on line %d
162: NULL
163:
164: --int indexed array--
165:
166: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, array must have exactly two members in %s on line %d
167: NULL
168:
169: --associative array--
170:
171: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, first array member is not a valid class name or object in %s on line %d
172: NULL
173:
174: --nested arrays--
175:
176: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, array must have exactly two members in %s on line %d
177: NULL
178:
179: --uppercase NULL--
180:
181: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
182: NULL
183:
184: --lowercase null--
185:
186: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
187: NULL
188:
189: --lowercase true--
190:
191: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
192: NULL
193:
194: --lowercase false--
195:
196: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
197: NULL
198:
199: --uppercase TRUE--
200:
201: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
202: NULL
203:
204: --uppercase FALSE--
205:
206: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
207: NULL
208:
209: --empty string DQ--
210:
211: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, function '' not found or invalid function name in %s on line %d
212: NULL
213:
214: --empty string SQ--
215:
216: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, function '' not found or invalid function name in %s on line %d
217: NULL
218:
219: --string DQ--
220:
221: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, function 'string' not found or invalid function name in %s on line %d
222: NULL
223:
224: --string SQ--
225:
226: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, function 'string' not found or invalid function name in %s on line %d
227: NULL
228:
229: --mixed case string--
230:
231: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, function 'sTrInG' not found or invalid function name in %s on line %d
232: NULL
233:
234: --heredoc--
235:
236: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, function 'hello world' not found or invalid function name in %s on line %d
237: NULL
238:
239: --instance of classWithToString--
240:
241: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
242: NULL
243:
244: --instance of classWithoutToString--
245:
246: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
247: NULL
248:
249: --undefined var--
250:
251: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
252: NULL
253:
254: --unset var--
255:
256: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
257: NULL
258:
259: --resource--
260:
261: Warning: array_diff_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
262: NULL
263: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>