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