Annotation of embedaddon/php/ext/standard/tests/strings/get_html_translation_table_variation1.phpt, revision 1.1.1.1
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()
68: // when $table arugment is supplied with different values
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));
78: else
79: var_dump($v);
80:
81: $v = get_html_translation_table($table, $quote_style, "UTF-8");
82: if (is_array($v) && count($v) > 100)
83: var_dump(count($v));
84: else
85: var_dump($v);
86:
87: $counter ++;
88: }
89:
90: // close resource
91: fclose($fp);
92:
93: echo "Done\n";
94: ?>
95: --EXPECTF--
96: *** Testing get_html_translation_table() : usage variations ***
97:
98: --- Testing get_html_translation_table() by supplying different values for 'table' argument ---
99: -- Iteration 1 --
100:
101: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
102: NULL
103:
104: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
105: NULL
106: -- Iteration 2 --
107:
108: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
109: NULL
110:
111: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
112: NULL
113: -- Iteration 3 --
114:
115: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
116: NULL
117:
118: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
119: NULL
120: -- Iteration 4 --
121:
122: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
123: NULL
124:
125: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
126: NULL
127: -- Iteration 5 --
128:
129: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
130: NULL
131:
132: Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
133: NULL
134: -- Iteration 6 --
135: int(252)
136: int(252)
137: -- Iteration 7 --
138: array(4) {
139: ["&"]=>
140: string(5) "&"
141: ["""]=>
142: string(6) """
143: ["<"]=>
144: string(4) "<"
145: [">"]=>
146: string(4) ">"
147: }
148: array(4) {
149: ["&"]=>
150: string(5) "&"
151: ["""]=>
152: string(6) """
153: ["<"]=>
154: string(4) "<"
155: [">"]=>
156: string(4) ">"
157: }
158: -- Iteration 8 --
159: int(252)
160: int(252)
161: -- Iteration 9 --
162: array(4) {
163: ["&"]=>
164: string(5) "&"
165: ["""]=>
166: string(6) """
167: ["<"]=>
168: string(4) "<"
169: [">"]=>
170: string(4) ">"
171: }
172: array(4) {
173: ["&"]=>
174: string(5) "&"
175: ["""]=>
176: string(6) """
177: ["<"]=>
178: string(4) "<"
179: [">"]=>
180: string(4) ">"
181: }
182: -- Iteration 10 --
183:
184: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
185: NULL
186:
187: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
188: NULL
189: -- Iteration 11 --
190:
191: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
192: NULL
193:
194: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
195: NULL
196: -- Iteration 12 --
197:
198: Warning: get_html_translation_table() expects parameter 1 to be long, object given in %s on line %d
199: NULL
200:
201: Warning: get_html_translation_table() expects parameter 1 to be long, object given in %s on line %d
202: NULL
203: -- Iteration 13 --
204:
205: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
206: NULL
207:
208: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
209: NULL
210: -- Iteration 14 --
211:
212: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
213: NULL
214:
215: Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
216: NULL
217: -- Iteration 15 --
218: array(4) {
219: ["&"]=>
220: string(5) "&"
221: ["""]=>
222: string(6) """
223: ["<"]=>
224: string(4) "<"
225: [">"]=>
226: string(4) ">"
227: }
228: array(4) {
229: ["&"]=>
230: string(5) "&"
231: ["""]=>
232: string(6) """
233: ["<"]=>
234: string(4) "<"
235: [">"]=>
236: string(4) ">"
237: }
238: -- Iteration 16 --
239: array(4) {
240: ["&"]=>
241: string(5) "&"
242: ["""]=>
243: string(6) """
244: ["<"]=>
245: string(4) "<"
246: [">"]=>
247: string(4) ">"
248: }
249: array(4) {
250: ["&"]=>
251: string(5) "&"
252: ["""]=>
253: string(6) """
254: ["<"]=>
255: string(4) "<"
256: [">"]=>
257: string(4) ">"
258: }
259: -- Iteration 17 --
260:
261: Warning: get_html_translation_table() expects parameter 1 to be long, resource given in %s on line %d
262: NULL
263:
264: Warning: get_html_translation_table() expects parameter 1 to be long, resource given in %s on line %d
265: NULL
266: -- Iteration 18 --
267: array(4) {
268: ["&"]=>
269: string(5) "&"
270: ["""]=>
271: string(6) """
272: ["<"]=>
273: string(4) "<"
274: [">"]=>
275: string(4) ">"
276: }
277: array(4) {
278: ["&"]=>
279: string(5) "&"
280: ["""]=>
281: string(6) """
282: ["<"]=>
283: string(4) "<"
284: [">"]=>
285: string(4) ">"
286: }
287: -- Iteration 19 --
288: array(4) {
289: ["&"]=>
290: string(5) "&"
291: ["""]=>
292: string(6) """
293: ["<"]=>
294: string(4) "<"
295: [">"]=>
296: string(4) ">"
297: }
298: array(4) {
299: ["&"]=>
300: string(5) "&"
301: ["""]=>
302: string(6) """
303: ["<"]=>
304: string(4) "<"
305: [">"]=>
306: string(4) ">"
307: }
308: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>