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
11echo "*** Testing xml_parser_set_option() : usage variations ***\n";
12
13class aClass {
14   function __toString() {
15       return "Some Ascii Data";
16   }
17}
18// Initialise function arguments not being substituted (if any)
19
20$parser = xml_parser_create();
21$option = 1;
22
23//get an unset variable
24$unset_var = 10;
25unset ($unset_var);
26
27$fp = fopen(__FILE__, "r");
28
29//array of values to iterate over
30$values = array(
31
32      // int data
33      0,
34      1,
35      12345,
36      -2345,
37
38      // float data
39      10.5,
40      -10.5,
41      10.1234567e10,
42      10.7654321E-10,
43      .5,
44
45      // array data
46      array(),
47      array(0),
48      array(1),
49      array(1, 2),
50      array('color' => 'red', 'item' => 'pen'),
51
52      // null data
53      NULL,
54      null,
55
56      // boolean data
57      true,
58      false,
59      TRUE,
60      FALSE,
61
62      // empty data
63      "",
64      '',
65
66      // string data
67      "string",
68      'string',
69
70      // object data
71      new aClass(),
72
73      // resource data
74      $fp,
75);
76
77// loop through each element of the array for value
78
79foreach($values as $value) {
80  echo @"\nArg value $value \n";
81  var_dump(xml_parser_set_option($parser, $option, $value));
82}
83
84fclose($fp);
85xml_parser_free($parser);
86echo "Done";
87?>
88--EXPECTF--
89*** Testing xml_parser_set_option() : usage variations ***
90
91Arg value 0
92bool(true)
93
94Arg value 1
95bool(true)
96
97Arg value 12345
98bool(true)
99
100Arg value -2345
101bool(true)
102
103Arg value 10.5
104bool(true)
105
106Arg value -10.5
107bool(true)
108
109Arg value 101234567000
110bool(true)
111
112Arg value 1.07654321E-9
113bool(true)
114
115Arg value 0.5
116bool(true)
117
118Arg value Array
119bool(true)
120
121Arg value Array
122bool(true)
123
124Arg value Array
125bool(true)
126
127Arg value Array
128bool(true)
129
130Arg value Array
131bool(true)
132
133Arg value
134bool(true)
135
136Arg value
137bool(true)
138
139Arg value 1
140bool(true)
141
142Arg value
143bool(true)
144
145Arg value 1
146bool(true)
147
148Arg value
149bool(true)
150
151Arg value
152bool(true)
153
154Arg value
155bool(true)
156
157Arg value string
158bool(true)
159
160Arg value string
161bool(true)
162
163Arg value Some Ascii Data
164
165Warning: Object of class aClass could not be converted to int in %s on line %d
166bool(true)
167
168Arg value Resource id %s
169bool(true)
170Done
171