1--TEST--
2Test xml_parser_set_option() function : usage variations
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_parser_set_option(resource parser, int option, mixed value)
12 * Description: Set options in an XML parser
13 * Source code: ext/xml/xml.c
14 * Alias to functions:
15 */
16
17echo "*** Testing xml_parser_set_option() : 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$parser = xml_parser_create();
27
28//get an unset variable
29$unset_var = 10;
30unset ($unset_var);
31
32//array of values to iterate over
33$values = array(
34
35      // outside of range int data
36      12345,
37      -2345,
38
39      // float data
40      10.5,
41      -10.5,
42      10.1234567e10,
43      10.7654321E-10,
44      .5,
45
46      // array data
47      array(),
48      array(0),
49      array(1),
50      array(1, 2),
51      array('color' => 'red', 'item' => 'pen'),
52
53      // null data
54      NULL,
55      null,
56
57      // boolean data
58      true,
59      false,
60      TRUE,
61      FALSE,
62
63      // empty data
64      "",
65      '',
66
67      // string data
68      "string",
69      'string',
70
71      // object data
72      new aClass(),
73
74      // undefined data
75      $undefined_var,
76
77      // unset data
78      $unset_var,
79);
80
81// loop through each element of the array for option
82
83foreach($values as $value) {
84      echo "\nArg value $value \n";
85      var_dump( xml_parser_set_option($parser, $value, 1) );
86};
87
88xml_parser_free($parser);
89echo "Done";
90?>
91--EXPECTF--
92*** Testing xml_parser_set_option() : usage variations ***
93
94Arg value 12345
95
96Warning: xml_parser_set_option(): Unknown option in %s on line %d
97bool(false)
98
99Arg value -2345
100
101Warning: xml_parser_set_option(): Unknown option in %s on line %d
102bool(false)
103
104Arg value 10.5
105
106Warning: xml_parser_set_option(): Unknown option in %s on line %d
107bool(false)
108
109Arg value -10.5
110
111Warning: xml_parser_set_option(): Unknown option in %s on line %d
112bool(false)
113
114Arg value 101234567000
115
116Warning: xml_parser_set_option(): Unknown option in %s on line %d
117bool(false)
118
119Arg value 1.07654321E-9
120
121Warning: xml_parser_set_option(): Unknown option in %s on line %d
122bool(false)
123
124Arg value 0.5
125
126Warning: xml_parser_set_option(): Unknown option in %s on line %d
127bool(false)
128
129Arg value Array
130
131Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d
132NULL
133
134Arg value Array
135
136Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d
137NULL
138
139Arg value Array
140
141Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d
142NULL
143
144Arg value Array
145
146Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d
147NULL
148
149Arg value Array
150
151Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d
152NULL
153
154Arg value
155
156Warning: xml_parser_set_option(): Unknown option in %s on line %d
157bool(false)
158
159Arg value
160
161Warning: xml_parser_set_option(): Unknown option in %s on line %d
162bool(false)
163
164Arg value 1
165bool(true)
166
167Arg value
168
169Warning: xml_parser_set_option(): Unknown option in %s on line %d
170bool(false)
171
172Arg value 1
173bool(true)
174
175Arg value
176
177Warning: xml_parser_set_option(): Unknown option in %s on line %d
178bool(false)
179
180Arg value
181
182Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d
183NULL
184
185Arg value
186
187Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d
188NULL
189
190Arg value string
191
192Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d
193NULL
194
195Arg value string
196
197Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d
198NULL
199
200Arg value Some Ascii Data
201
202Warning: xml_parser_set_option() expects parameter 2 to be long, object given in %s on line %d
203NULL
204
205Arg value
206
207Warning: xml_parser_set_option(): Unknown option in %s on line %d
208bool(false)
209
210Arg value
211
212Warning: xml_parser_set_option(): Unknown option in %s on line %d
213bool(false)
214Done
215
216