1--TEST--
2Test xml_set_element_handler() function : usage variations  - test different types for parser
3--SKIPIF--
4<?php
5if (!extension_loaded("xml")) {
6	print "skip - XML extension not loaded";
7}
8?>
9--FILE--
10<?php
11/* Prototype  : proto int xml_set_element_handler(resource parser, string shdl, string ehdl)
12 * Description: Set up start and end element handlers
13 * Source code: ext/xml/xml.c
14 * Alias to functions:
15 */
16
17echo "*** Testing xml_set_element_handler() : usage variations ***\n";
18error_reporting(E_ALL & ~E_NOTICE);
19
20class aClass {
21   function __toString() {
22       return "Some Ascii Data";
23   }
24}
25
26function validHandler(resource $parser ,string $data) {
27}
28
29// Initialise function arguments not being substituted (if any)
30$hdl = 'validHandler';
31
32//get an unset variable
33$unset_var = 10;
34unset ($unset_var);
35
36$fp = fopen(__FILE__, "r");
37
38//array of values to iterate over
39$values = array(
40
41      // int data
42      0,
43      1,
44      12345,
45      -2345,
46
47      // float data
48      10.5,
49      -10.5,
50      10.1234567e10,
51      10.7654321E-10,
52      .5,
53
54      // array data
55      array(),
56      array(0),
57      array(1),
58      array(1, 2),
59      array('color' => 'red', 'item' => 'pen'),
60
61      // null data
62      NULL,
63      null,
64
65      // boolean data
66      true,
67      false,
68      TRUE,
69      FALSE,
70
71      // empty data
72      "",
73      '',
74
75      // string data
76      "string",
77      'string',
78
79      // object data
80      new aClass(),
81
82      // resource data
83      $fp,
84
85      // undefined data
86      $undefined_var,
87
88      // unset data
89      $unset_var,
90);
91
92// loop through each element of the array for parser
93
94foreach($values as $value) {
95      echo @"\nArg value $value \n";
96      var_dump( xml_set_element_handler($value, $hdl, $hdl) );
97};
98
99fclose($fp);
100echo "Done";
101?>
102--EXPECTF--
103*** Testing xml_set_element_handler() : usage variations ***
104
105Arg value 0
106
107Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d
108NULL
109
110Arg value 1
111
112Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d
113NULL
114
115Arg value 12345
116
117Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d
118NULL
119
120Arg value -2345
121
122Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d
123NULL
124
125Arg value 10.5
126
127Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d
128NULL
129
130Arg value -10.5
131
132Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d
133NULL
134
135Arg value 101234567000
136
137Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d
138NULL
139
140Arg value 1.07654321E-9
141
142Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d
143NULL
144
145Arg value 0.5
146
147Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d
148NULL
149
150Arg value Array
151
152Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d
153NULL
154
155Arg value Array
156
157Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d
158NULL
159
160Arg value Array
161
162Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d
163NULL
164
165Arg value Array
166
167Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d
168NULL
169
170Arg value Array
171
172Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d
173NULL
174
175Arg value
176
177Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d
178NULL
179
180Arg value
181
182Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d
183NULL
184
185Arg value 1
186
187Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d
188NULL
189
190Arg value
191
192Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d
193NULL
194
195Arg value 1
196
197Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d
198NULL
199
200Arg value
201
202Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d
203NULL
204
205Arg value
206
207Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d
208NULL
209
210Arg value
211
212Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d
213NULL
214
215Arg value string
216
217Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d
218NULL
219
220Arg value string
221
222Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d
223NULL
224
225Arg value Some Ascii Data
226
227Warning: xml_set_element_handler() expects parameter 1 to be resource, object given in %s on line %d
228NULL
229
230Arg value Resource id %s
231
232Warning: xml_set_element_handler(): supplied resource is not a valid XML Parser resource in %s on line %d
233bool(false)
234
235Arg value
236
237Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d
238NULL
239
240Arg value
241
242Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d
243NULL
244Done
245
246