Annotation of embedaddon/php/ext/standard/tests/strings/get_html_translation_table_variation2.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test get_html_translation_table() function : usage variations - unexpected quote_style 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 unexpteced value for argument $quote_style
12: */
13:
14: //set locale to en_US.UTF-8
15: setlocale(LC_ALL, "en_US.UTF-8");
16:
17: echo "*** Testing get_html_translation_table() : usage variations ***\n";
18: // initialize all required variables
19: $table = HTML_SPECIALCHARS;
20:
21: // get an unset variable
22: $unset_var = 10;
23: unset($unset_var);
24:
25: // a resource var
26: $fp = fopen(__FILE__, "r");
27:
28: // array with different values
29: $values = array (
30:
31: // array values
32: array(),
33: array(0),
34: array(1),
35: array(1, 2),
36: array('color' => 'red', 'item' => 'pen'),
37:
38: // boolean values
39: true,
40: false,
41: TRUE,
42: FALSE,
43:
44: // string values
45: "string",
46: 'string',
47:
48: // objects
49: new stdclass(),
50:
51: // empty string
52: "",
53: '',
54:
55: // null vlaues
56: NULL,
57: null,
58:
59: // resource var
60: $fp,
61:
62: // undefined variable
63: @$undefined_var,
64:
65: // unset variable
66: @$unset_var
67: );
68:
69:
70: // loop through each element of the array and check the working of get_html_translation_table()
1.1.1.2 ! misho 71: // when $quote_style argument is supplied with different values
1.1 misho 72: echo "\n--- Testing get_html_translation_table() by supplying different values for 'quote_style' argument ---\n";
73: $counter = 1;
74: for($index = 0; $index < count($values); $index ++) {
75: echo "-- Iteration $counter --\n";
76: $quote_style = $values [$index];
77:
78: var_dump( get_html_translation_table($table, $quote_style) );
79:
80: $counter ++;
81: }
82:
83: echo "Done\n";
84: ?>
85: --EXPECTF--
86: *** Testing get_html_translation_table() : usage variations ***
87:
88: --- Testing get_html_translation_table() by supplying different values for 'quote_style' argument ---
89: -- Iteration 1 --
90:
91: Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
92: NULL
93: -- Iteration 2 --
94:
95: Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
96: NULL
97: -- Iteration 3 --
98:
99: Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
100: NULL
101: -- Iteration 4 --
102:
103: Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
104: NULL
105: -- Iteration 5 --
106:
107: Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
108: NULL
109: -- Iteration 6 --
110: array(4) {
111: ["&"]=>
112: string(5) "&"
113: ["'"]=>
114: string(6) "'"
115: ["<"]=>
116: string(4) "<"
117: [">"]=>
118: string(4) ">"
119: }
120: -- Iteration 7 --
121: array(3) {
122: ["&"]=>
123: string(5) "&"
124: ["<"]=>
125: string(4) "<"
126: [">"]=>
127: string(4) ">"
128: }
129: -- Iteration 8 --
130: array(4) {
131: ["&"]=>
132: string(5) "&"
133: ["'"]=>
134: string(6) "'"
135: ["<"]=>
136: string(4) "<"
137: [">"]=>
138: string(4) ">"
139: }
140: -- Iteration 9 --
141: array(3) {
142: ["&"]=>
143: string(5) "&"
144: ["<"]=>
145: string(4) "<"
146: [">"]=>
147: string(4) ">"
148: }
149: -- Iteration 10 --
150:
151: Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
152: NULL
153: -- Iteration 11 --
154:
155: Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
156: NULL
157: -- Iteration 12 --
158:
159: Warning: get_html_translation_table() expects parameter 2 to be long, object given in %s on line %s
160: NULL
161: -- Iteration 13 --
162:
163: Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
164: NULL
165: -- Iteration 14 --
166:
167: Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
168: NULL
169: -- Iteration 15 --
170: array(3) {
171: ["&"]=>
172: string(5) "&"
173: ["<"]=>
174: string(4) "<"
175: [">"]=>
176: string(4) ">"
177: }
178: -- Iteration 16 --
179: array(3) {
180: ["&"]=>
181: string(5) "&"
182: ["<"]=>
183: string(4) "<"
184: [">"]=>
185: string(4) ">"
186: }
187: -- Iteration 17 --
188:
189: Warning: get_html_translation_table() expects parameter 2 to be long, resource given in %s on line %s
190: NULL
191: -- Iteration 18 --
192: array(3) {
193: ["&"]=>
194: string(5) "&"
195: ["<"]=>
196: string(4) "<"
197: [">"]=>
198: string(4) ">"
199: }
200: -- Iteration 19 --
201: array(3) {
202: ["&"]=>
203: string(5) "&"
204: ["<"]=>
205: string(4) "<"
206: [">"]=>
207: string(4) ">"
208: }
209: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>