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