1--TEST--
2Test array_intersect_ukey() function : usage variation - Passing unexpected values to second argument
3--FILE--
4<?php
5echo "*** Testing array_intersect_ukey() : usage variation ***\n";
6
7//Initialise arguments
8$array1 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
9$array3 = array('green' => 5, 'cyan'   => 8);
10
11//Call back function
12function key_compare_func($key1, $key2)
13{
14    if ($key1 == $key2)
15        return 0;
16    else
17        return ($key1 > $key2)? 1:-1;
18}
19
20//get an unset variable
21$unset_var = 10;
22unset ($unset_var);
23
24//resource variable
25$fp = fopen(__FILE__, "r");
26
27// define some classes
28class classWithToString
29{
30    public function __toString() {
31        return "Class A object";
32    }
33}
34
35class classWithoutToString
36{
37}
38
39// heredoc string
40$heredoc = <<<EOT
41hello world
42EOT;
43
44//array of values to iterate over
45$inputs = array(
46
47      // int data
48      'int 0' => 0,
49      'int 1' => 1,
50      'int 12345' => 12345,
51      'int -12345' => -12345,
52
53      // float data
54      'float 10.5' => 10.5,
55      'float -10.5' => -10.5,
56      'float 12.3456789000e10' => 12.3456789000e10,
57      'float -12.3456789000e10' => -12.3456789000e10,
58      'float .5' => .5,
59
60      // null data
61      'uppercase NULL' => NULL,
62      'lowercase null' => null,
63
64      // boolean data
65      'lowercase true' => true,
66      'lowercase false' =>false,
67      'uppercase TRUE' =>TRUE,
68      'uppercase FALSE' =>FALSE,
69
70      // empty data
71      'empty string DQ' => "",
72      'empty string SQ' => '',
73
74      // string data
75      'string DQ' => "string",
76      'string SQ' => 'string',
77      'mixed case string' => "sTrInG",
78      'heredoc' => $heredoc,
79
80      // object data
81      'instance of classWithToString' => new classWithToString(),
82      'instance of classWithoutToString' => new classWithoutToString(),
83
84      // undefined data
85      'undefined var' => @$undefined_var,
86
87      // unset data
88      'unset var' => @$unset_var,
89
90      // resource data
91      'resource var' => $fp,
92);
93
94// loop through each element of the array for array2
95
96foreach($inputs as $key =>$value) {
97    echo "\n--$key--\n";
98    try {
99        var_dump( array_intersect_ukey($array1, $value, 'key_compare_func') );
100    } catch (TypeError $e) {
101        echo $e->getMessage(), "\n";
102    }
103    try {
104        var_dump( array_intersect_ukey($array1, $value, $array3, 'key_compare_func') );
105    } catch (TypeError $e) {
106        echo $e->getMessage(), "\n";
107    }
108};
109
110fclose($fp);
111?>
112--EXPECT--
113*** Testing array_intersect_ukey() : usage variation ***
114
115--int 0--
116array_intersect_ukey(): Argument #2 must be of type array, int given
117array_intersect_ukey(): Argument #2 must be of type array, int given
118
119--int 1--
120array_intersect_ukey(): Argument #2 must be of type array, int given
121array_intersect_ukey(): Argument #2 must be of type array, int given
122
123--int 12345--
124array_intersect_ukey(): Argument #2 must be of type array, int given
125array_intersect_ukey(): Argument #2 must be of type array, int given
126
127--int -12345--
128array_intersect_ukey(): Argument #2 must be of type array, int given
129array_intersect_ukey(): Argument #2 must be of type array, int given
130
131--float 10.5--
132array_intersect_ukey(): Argument #2 must be of type array, float given
133array_intersect_ukey(): Argument #2 must be of type array, float given
134
135--float -10.5--
136array_intersect_ukey(): Argument #2 must be of type array, float given
137array_intersect_ukey(): Argument #2 must be of type array, float given
138
139--float 12.3456789000e10--
140array_intersect_ukey(): Argument #2 must be of type array, float given
141array_intersect_ukey(): Argument #2 must be of type array, float given
142
143--float -12.3456789000e10--
144array_intersect_ukey(): Argument #2 must be of type array, float given
145array_intersect_ukey(): Argument #2 must be of type array, float given
146
147--float .5--
148array_intersect_ukey(): Argument #2 must be of type array, float given
149array_intersect_ukey(): Argument #2 must be of type array, float given
150
151--uppercase NULL--
152array_intersect_ukey(): Argument #2 must be of type array, null given
153array_intersect_ukey(): Argument #2 must be of type array, null given
154
155--lowercase null--
156array_intersect_ukey(): Argument #2 must be of type array, null given
157array_intersect_ukey(): Argument #2 must be of type array, null given
158
159--lowercase true--
160array_intersect_ukey(): Argument #2 must be of type array, true given
161array_intersect_ukey(): Argument #2 must be of type array, true given
162
163--lowercase false--
164array_intersect_ukey(): Argument #2 must be of type array, false given
165array_intersect_ukey(): Argument #2 must be of type array, false given
166
167--uppercase TRUE--
168array_intersect_ukey(): Argument #2 must be of type array, true given
169array_intersect_ukey(): Argument #2 must be of type array, true given
170
171--uppercase FALSE--
172array_intersect_ukey(): Argument #2 must be of type array, false given
173array_intersect_ukey(): Argument #2 must be of type array, false given
174
175--empty string DQ--
176array_intersect_ukey(): Argument #2 must be of type array, string given
177array_intersect_ukey(): Argument #2 must be of type array, string given
178
179--empty string SQ--
180array_intersect_ukey(): Argument #2 must be of type array, string given
181array_intersect_ukey(): Argument #2 must be of type array, string given
182
183--string DQ--
184array_intersect_ukey(): Argument #2 must be of type array, string given
185array_intersect_ukey(): Argument #2 must be of type array, string given
186
187--string SQ--
188array_intersect_ukey(): Argument #2 must be of type array, string given
189array_intersect_ukey(): Argument #2 must be of type array, string given
190
191--mixed case string--
192array_intersect_ukey(): Argument #2 must be of type array, string given
193array_intersect_ukey(): Argument #2 must be of type array, string given
194
195--heredoc--
196array_intersect_ukey(): Argument #2 must be of type array, string given
197array_intersect_ukey(): Argument #2 must be of type array, string given
198
199--instance of classWithToString--
200array_intersect_ukey(): Argument #2 must be of type array, classWithToString given
201array_intersect_ukey(): Argument #2 must be of type array, classWithToString given
202
203--instance of classWithoutToString--
204array_intersect_ukey(): Argument #2 must be of type array, classWithoutToString given
205array_intersect_ukey(): Argument #2 must be of type array, classWithoutToString given
206
207--undefined var--
208array_intersect_ukey(): Argument #2 must be of type array, null given
209array_intersect_ukey(): Argument #2 must be of type array, null given
210
211--unset var--
212array_intersect_ukey(): Argument #2 must be of type array, null given
213array_intersect_ukey(): Argument #2 must be of type array, null given
214
215--resource var--
216array_intersect_ukey(): Argument #2 must be of type array, resource given
217array_intersect_ukey(): Argument #2 must be of type array, resource given
218