Annotation of embedaddon/php/ext/xml/tests/xml_error_string_variation1.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test xml_error_string() function : usage variations - test different types for code
3: --SKIPIF--
4: <?php
5: if (!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:
17: echo "*** Testing xml_error_string() : usage variations ***\n";
18: error_reporting(E_ALL & ~E_NOTICE);
19:
20: class 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;
30: unset ($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:
79: foreach($values as $value) {
1.1.1.2 ! misho 80: echo @"\nArg value $value \n";
1.1 misho 81: var_dump( xml_error_string($value) );
82: };
83:
84: echo "Done";
85: ?>
86: --EXPECTF--
87: *** Testing xml_error_string() : usage variations ***
88:
89: Arg value 10.5
90: string(22) "XML_ERR_CHARREF_AT_EOF"
91:
92: Arg value -10.5
93: string(7) "Unknown"
94:
95: Arg value 101234567000
96: string(7) "Unknown"
97:
98: Arg value 1.07654321E-9
99: string(8) "No error"
100:
101: Arg value 0.5
102: string(8) "No error"
103:
104: Arg value Array
105:
106: Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d
107: NULL
108:
109: Arg value Array
110:
111: Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d
112: NULL
113:
114: Arg value Array
115:
116: Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d
117: NULL
118:
119: Arg value Array
120:
121: Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d
122: NULL
123:
124: Arg value Array
125:
126: Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d
127: NULL
128:
129: Arg value
130: string(8) "No error"
131:
132: Arg value
133: string(8) "No error"
134:
135: Arg value 1
136: string(9) "No memory"
137:
138: Arg value
139: string(8) "No error"
140:
141: Arg value 1
142: string(9) "No memory"
143:
144: Arg value
145: string(8) "No error"
146:
147: Arg value
148:
149: Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d
150: NULL
151:
152: Arg value
153:
154: Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d
155: NULL
156:
157: Arg value string
158:
159: Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d
160: NULL
161:
162: Arg value string
163:
164: Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d
165: NULL
166:
167: Arg value Some Ascii Data
168:
169: Warning: xml_error_string() expects parameter 1 to be long, object given in %s on line %d
170: NULL
171:
172: Arg value
173: string(8) "No error"
174:
175: Arg value
176: string(8) "No error"
177: Done
178:
179:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>