1--TEST--
2Test xml_error_string() function : usage variations  - test different types for code
3--SKIPIF--
4<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64-bit only");
5if (!extension_loaded("xml")) {
6	print "skip - XML extension not loaded";
7}
8?>
9--FILE--
10<?php
11/* Prototype  : proto string xml_error_string(int code)
12 * Description: Get XML parser error string
13 * Source code: ext/xml/xml.c
14 * Alias to functions:
15 */
16
17echo "*** Testing xml_error_string() : usage variations ***\n";
18error_reporting(E_ALL & ~E_NOTICE);
19
20class aClass {
21   function __toString() {
22       return "Some Ascii Data";
23   }
24}
25
26// Initialise function arguments not being substituted (if any)
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      // float data
36      10.5,
37      -10.5,
38      10.1234567e10,
39      10.7654321E-10,
40      .5,
41
42      // array data
43      array(),
44      array(0),
45      array(1),
46      array(1, 2),
47      array('color' => 'red', 'item' => 'pen'),
48
49      // null data
50      NULL,
51      null,
52
53      // boolean data
54      true,
55      false,
56      TRUE,
57      FALSE,
58
59      // empty data
60      "",
61      '',
62
63      // string data
64      "string",
65      'string',
66
67      // object data
68      new aClass(),
69
70      // undefined data
71      $undefined_var,
72
73      // unset data
74      $unset_var,
75);
76
77// loop through each element of the array for code
78
79foreach($values as $value) {
80      echo @"\nArg value $value \n";
81      var_dump( xml_error_string($value) );
82};
83
84echo "Done";
85?>
86--EXPECTF--
87*** Testing xml_error_string() : usage variations ***
88
89Arg value 10.5
90string(22) "XML_ERR_CHARREF_AT_EOF"
91
92Arg value -10.5
93string(7) "Unknown"
94
95Arg value 101234567000
96string(7) "Unknown"
97
98Arg value 1.07654321E-9
99string(8) "No error"
100
101Arg value 0.5
102string(8) "No error"
103
104Arg value Array
105
106Warning: xml_error_string() expects parameter 1 to be int, array given in %s on line %d
107NULL
108
109Arg value Array
110
111Warning: xml_error_string() expects parameter 1 to be int, array given in %s on line %d
112NULL
113
114Arg value Array
115
116Warning: xml_error_string() expects parameter 1 to be int, array given in %s on line %d
117NULL
118
119Arg value Array
120
121Warning: xml_error_string() expects parameter 1 to be int, array given in %s on line %d
122NULL
123
124Arg value Array
125
126Warning: xml_error_string() expects parameter 1 to be int, array given in %s on line %d
127NULL
128
129Arg value
130string(8) "No error"
131
132Arg value
133string(8) "No error"
134
135Arg value 1
136string(9) "No memory"
137
138Arg value
139string(8) "No error"
140
141Arg value 1
142string(9) "No memory"
143
144Arg value
145string(8) "No error"
146
147Arg value
148
149Warning: xml_error_string() expects parameter 1 to be int, string given in %s on line %d
150NULL
151
152Arg value
153
154Warning: xml_error_string() expects parameter 1 to be int, string given in %s on line %d
155NULL
156
157Arg value string
158
159Warning: xml_error_string() expects parameter 1 to be int, string given in %s on line %d
160NULL
161
162Arg value string
163
164Warning: xml_error_string() expects parameter 1 to be int, string given in %s on line %d
165NULL
166
167Arg value Some Ascii Data
168
169Warning: xml_error_string() expects parameter 1 to be int, object given in %s on line %d
170NULL
171
172Arg value
173string(8) "No error"
174
175Arg value
176string(8) "No error"
177Done
178