Annotation of embedaddon/php/ext/standard/tests/strings/get_html_translation_table_variation1.phpt, revision 1.1.1.3
1.1 misho 1: --TEST--
2: Test get_html_translation_table() function : usage variations - unexpected table values
3: --FILE--
4: <?php
5: /* Prototype : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
6: * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
7: * Source code: ext/standard/html.c
8: */
9:
10: /*
11: * test get_html_translation_table() with unexpected value for argument $table
12: */
13:
14: echo "*** Testing get_html_translation_table() : usage variations ***\n";
15: // initialize all required variables
16: $quote_style = ENT_COMPAT;
17:
18: // get an unset variable
19: $unset_var = 10;
20: unset($unset_var);
21:
22: // a resource variable
23: $fp = fopen(__FILE__, "r");
24:
25: // array with different values
26: $values = array (
27:
28: // array values
29: array(),
30: array(0),
31: array(1),
32: array(1, 2),
33: array('color' => 'red', 'item' => 'pen'),
34:
35: // boolean values
36: true,
37: false,
38: TRUE,
39: FALSE,
40:
41: // string values
42: "string",
43: 'string',
44:
45: // objects
46: new stdclass(),
47:
48: // empty string
49: "",
50: '',
51:
52: // null vlaues
53: NULL,
54: null,
55:
56: // resource var
57: $fp,
58:
59: // undefined variable
60: @$undefined_var,
61:
62: // unset variable
63: @$unset_var
64: );
65:
66:
67: // loop through each element of the array and check the working of get_html_translation_table()
1.1.1.3 ! misho 68: // when $table argument is supplied with different values
1.1 misho 69: echo "\n--- Testing get_html_translation_table() by supplying different values for 'table' argument ---\n";
70: $counter = 1;
71: for($index = 0; $index < count($values); $index ++) {
72: echo "-- Iteration $counter --\n";
73: $table = $values [$index];
74:
75: $v = get_html_translation_table($table, ENT_COMPAT, "UTF-8");
76: if (is_array($v) && count($v) > 100)
77: var_dump(count($v));
1.1.1.2 misho 78: elseif (is_array($v)) {
79: asort($v);
1.1 misho 80: var_dump($v);
1.1.1.2 misho 81: } else {
82: var_dump($v);
83: }
1.1 misho 84:
85: $v = get_html_translation_table($table, $quote_style, "UTF-8");
86: if (is_array($v) && count($v) > 100)
87: var_dump(count($v));
1.1.1.2 misho 88: elseif (is_array($v)) {
89: asort($v);
90: var_dump($v);
91: } else {
1.1 misho 92: var_dump($v);
1.1.1.2 misho 93: }
1.1 misho 94:
95: $counter ++;
96: }
97:
98: // close resource
99: fclose($fp);
100:
101: echo "Done\n";
102: ?>
103: --EXPECTF--
104: *** Testing get_html_translation_table() : usage variations ***
105:
106: --- Testing get_html_translation_table() by supplying different values for 'table' argument ---
107: -- Iteration 1 --
108:
109: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
110: NULL
111:
112: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
113: NULL
114: -- Iteration 2 --
115:
116: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
117: NULL
118:
119: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
120: NULL
121: -- Iteration 3 --
122:
123: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
124: NULL
125:
126: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
127: NULL
128: -- Iteration 4 --
129:
130: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
131: NULL
132:
133: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
134: NULL
135: -- Iteration 5 --
136:
137: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
138: NULL
139:
140: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
141: NULL
142: -- Iteration 6 --
143: int(252)
144: int(252)
145: -- Iteration 7 --
146: array(4) {
147: ["&"]=>
148: string(5) "&"
149: [">"]=>
150: string(4) ">"
1.1.1.2 misho 151: ["<"]=>
152: string(4) "<"
153: ["""]=>
154: string(6) """
1.1 misho 155: }
156: array(4) {
157: ["&"]=>
158: string(5) "&"
159: [">"]=>
160: string(4) ">"
1.1.1.2 misho 161: ["<"]=>
162: string(4) "<"
163: ["""]=>
164: string(6) """
1.1 misho 165: }
166: -- Iteration 8 --
167: int(252)
168: int(252)
169: -- Iteration 9 --
170: array(4) {
171: ["&"]=>
172: string(5) "&"
173: [">"]=>
174: string(4) ">"
1.1.1.2 misho 175: ["<"]=>
176: string(4) "<"
177: ["""]=>
178: string(6) """
1.1 misho 179: }
180: array(4) {
181: ["&"]=>
182: string(5) "&"
183: [">"]=>
184: string(4) ">"
1.1.1.2 misho 185: ["<"]=>
186: string(4) "<"
187: ["""]=>
188: string(6) """
1.1 misho 189: }
190: -- Iteration 10 --
191:
192: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
193: NULL
194:
195: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
196: NULL
197: -- Iteration 11 --
198:
199: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
200: NULL
201:
202: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
203: NULL
204: -- Iteration 12 --
205:
206: Warning: get_html_translation_table() expects parameter 1 to be long, object given in %s on line %d
207: NULL
208:
209: Warning: get_html_translation_table() expects parameter 1 to be long, object given in %s on line %d
210: NULL
211: -- Iteration 13 --
212:
213: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
214: NULL
215:
216: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
217: NULL
218: -- Iteration 14 --
219:
220: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
221: NULL
222:
223: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
224: NULL
225: -- Iteration 15 --
226: array(4) {
227: ["&"]=>
228: string(5) "&"
229: [">"]=>
230: string(4) ">"
1.1.1.2 misho 231: ["<"]=>
232: string(4) "<"
233: ["""]=>
234: string(6) """
1.1 misho 235: }
236: array(4) {
237: ["&"]=>
238: string(5) "&"
239: [">"]=>
240: string(4) ">"
1.1.1.2 misho 241: ["<"]=>
242: string(4) "<"
243: ["""]=>
244: string(6) """
1.1 misho 245: }
246: -- Iteration 16 --
247: array(4) {
248: ["&"]=>
249: string(5) "&"
250: [">"]=>
251: string(4) ">"
1.1.1.2 misho 252: ["<"]=>
253: string(4) "<"
254: ["""]=>
255: string(6) """
1.1 misho 256: }
257: array(4) {
258: ["&"]=>
259: string(5) "&"
260: [">"]=>
261: string(4) ">"
1.1.1.2 misho 262: ["<"]=>
263: string(4) "<"
264: ["""]=>
265: string(6) """
1.1 misho 266: }
267: -- Iteration 17 --
268:
269: Warning: get_html_translation_table() expects parameter 1 to be long, resource given in %s on line %d
270: NULL
271:
272: Warning: get_html_translation_table() expects parameter 1 to be long, resource given in %s on line %d
273: NULL
274: -- Iteration 18 --
275: array(4) {
276: ["&"]=>
277: string(5) "&"
278: [">"]=>
279: string(4) ">"
1.1.1.2 misho 280: ["<"]=>
281: string(4) "<"
282: ["""]=>
283: string(6) """
1.1 misho 284: }
285: array(4) {
286: ["&"]=>
287: string(5) "&"
288: [">"]=>
289: string(4) ">"
1.1.1.2 misho 290: ["<"]=>
291: string(4) "<"
292: ["""]=>
293: string(6) """
1.1 misho 294: }
295: -- Iteration 19 --
296: array(4) {
297: ["&"]=>
298: string(5) "&"
299: [">"]=>
300: string(4) ">"
1.1.1.2 misho 301: ["<"]=>
302: string(4) "<"
303: ["""]=>
304: string(6) """
1.1 misho 305: }
306: array(4) {
307: ["&"]=>
308: string(5) "&"
309: [">"]=>
310: string(4) ">"
1.1.1.2 misho 311: ["<"]=>
312: string(4) "<"
313: ["""]=>
314: string(6) """
1.1 misho 315: }
316: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>