1--TEST--
2Test array_udiff() function : usage variation
3--FILE--
4<?php
5echo "*** Testing array_udiff() : usage variation ***\n";
6
7// Initialise function arguments not being substituted (if any)
8$array1 = array(1, 2);
9
10include('compare_function.inc');
11$data_comp_func = 'compare_function';
12
13//get an unset variable
14$unset_var = 10;
15unset ($unset_var);
16
17// define some classes
18class classWithToString
19{
20    public function __toString() {
21        return "Class A object";
22    }
23}
24
25class classWithoutToString
26{
27}
28
29// heredoc string
30$heredoc = <<<EOT
31hello world
32EOT;
33
34// add arrays
35$index_array = array (1, 2, 3);
36$assoc_array = array ('one' => 1, 'two' => 2);
37
38//array of values to iterate over
39$inputs = array(
40
41      // int data
42      'int 0' => 0,
43      'int 1' => 1,
44      'int 12345' => 12345,
45      'int -12345' => -2345,
46
47      // float data
48      'float 10.5' => 10.5,
49      'float -10.5' => -10.5,
50      'float 12.3456789000e10' => 12.3456789000e10,
51      'float -12.3456789000e10' => -12.3456789000e10,
52      'float .5' => .5,
53
54      // null data
55      'uppercase NULL' => NULL,
56      'lowercase null' => null,
57
58      // boolean data
59      'lowercase true' => true,
60      'lowercase false' =>false,
61      'uppercase TRUE' =>TRUE,
62      'uppercase FALSE' =>FALSE,
63
64      // empty data
65      'empty string DQ' => "",
66      'empty string SQ' => '',
67
68      // string data
69      'string DQ' => "string",
70      'string SQ' => 'string',
71      'mixed case string' => "sTrInG",
72      'heredoc' => $heredoc,
73
74      // object data
75      'instance of classWithToString' => new classWithToString(),
76      'instance of classWithoutToString' => new classWithoutToString(),
77
78      // undefined data
79      'undefined var' => @$undefined_var,
80
81      // unset data
82      'unset var' => @$unset_var,
83);
84
85// loop through each element of the array for array2
86
87foreach($inputs as $key =>$value) {
88    echo "\n--$key--\n";
89    try {
90        var_dump( array_udiff($array1, $value, $data_comp_func) );
91    } catch (TypeError $e) {
92        echo $e->getMessage(), "\n";
93    }
94};
95
96?>
97--EXPECT--
98*** Testing array_udiff() : usage variation ***
99
100--int 0--
101array_udiff(): Argument #2 must be of type array, int given
102
103--int 1--
104array_udiff(): Argument #2 must be of type array, int given
105
106--int 12345--
107array_udiff(): Argument #2 must be of type array, int given
108
109--int -12345--
110array_udiff(): Argument #2 must be of type array, int given
111
112--float 10.5--
113array_udiff(): Argument #2 must be of type array, float given
114
115--float -10.5--
116array_udiff(): Argument #2 must be of type array, float given
117
118--float 12.3456789000e10--
119array_udiff(): Argument #2 must be of type array, float given
120
121--float -12.3456789000e10--
122array_udiff(): Argument #2 must be of type array, float given
123
124--float .5--
125array_udiff(): Argument #2 must be of type array, float given
126
127--uppercase NULL--
128array_udiff(): Argument #2 must be of type array, null given
129
130--lowercase null--
131array_udiff(): Argument #2 must be of type array, null given
132
133--lowercase true--
134array_udiff(): Argument #2 must be of type array, true given
135
136--lowercase false--
137array_udiff(): Argument #2 must be of type array, false given
138
139--uppercase TRUE--
140array_udiff(): Argument #2 must be of type array, true given
141
142--uppercase FALSE--
143array_udiff(): Argument #2 must be of type array, false given
144
145--empty string DQ--
146array_udiff(): Argument #2 must be of type array, string given
147
148--empty string SQ--
149array_udiff(): Argument #2 must be of type array, string given
150
151--string DQ--
152array_udiff(): Argument #2 must be of type array, string given
153
154--string SQ--
155array_udiff(): Argument #2 must be of type array, string given
156
157--mixed case string--
158array_udiff(): Argument #2 must be of type array, string given
159
160--heredoc--
161array_udiff(): Argument #2 must be of type array, string given
162
163--instance of classWithToString--
164array_udiff(): Argument #2 must be of type array, classWithToString given
165
166--instance of classWithoutToString--
167array_udiff(): Argument #2 must be of type array, classWithoutToString given
168
169--undefined var--
170array_udiff(): Argument #2 must be of type array, null given
171
172--unset var--
173array_udiff(): Argument #2 must be of type array, null given
174