1--TEST--
2Test array_diff_uassoc() function : usage variation -Passing unexpected values to second 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
11echo "*** Testing array_diff_uassoc() : usage variation ***\n";
12
13//Initialize variables
14$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
15
16function key_compare_func($a, $b)
17{
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' => -2345,
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 arr2
103
104foreach($inputs as $key =>$value) {
105      echo "\n--$key--\n";
106      var_dump( array_diff_uassoc($array1, $value, "key_compare_func") );
107};
108
109fclose($fp);
110?>
111===DONE===
112--EXPECTF--
113*** Testing array_diff_uassoc() : usage variation ***
114
115--int 0--
116
117Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
118NULL
119
120--int 1--
121
122Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
123NULL
124
125--int 12345--
126
127Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
128NULL
129
130--int -12345--
131
132Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
133NULL
134
135--float 10.5--
136
137Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
138NULL
139
140--float -10.5--
141
142Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
143NULL
144
145--float 12.3456789000e10--
146
147Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
148NULL
149
150--float -12.3456789000e10--
151
152Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
153NULL
154
155--float .5--
156
157Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
158NULL
159
160--uppercase NULL--
161
162Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
163NULL
164
165--lowercase null--
166
167Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
168NULL
169
170--lowercase true--
171
172Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
173NULL
174
175--lowercase false--
176
177Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
178NULL
179
180--uppercase TRUE--
181
182Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
183NULL
184
185--uppercase FALSE--
186
187Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
188NULL
189
190--empty string DQ--
191
192Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
193NULL
194
195--empty string SQ--
196
197Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
198NULL
199
200--string DQ--
201
202Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
203NULL
204
205--string SQ--
206
207Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
208NULL
209
210--mixed case string--
211
212Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
213NULL
214
215--heredoc--
216
217Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
218NULL
219
220--instance of classWithToString--
221
222Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
223NULL
224
225--instance of classWithoutToString--
226
227Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
228NULL
229
230--undefined var--
231
232Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
233NULL
234
235--unset var--
236
237Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
238NULL
239
240--resource--
241
242Warning: array_diff_uassoc(): Argument #2 is not an array in %s on line %d
243NULL
244===DONE===
245