Annotation of embedaddon/php/ext/standard/tests/strings/htmlspecialchars_decode_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test htmlspecialchars_decode() function : usage variations - unexpected values for 'quote_style' argument
3: --FILE--
4: <?php
5: /* Prototype : string htmlspecialchars_decode(string $string [, int $quote_style])
6: * Description: Convert special HTML entities back to characters
7: * Source code: ext/standard/html.c
8: */
9:
10: /*
11: * testing htmlspecialchars_decode() by giving unexpected input values for $quote_style argument
12: */
13:
14: echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
15:
16: // Initialise function arguments
17: // value initialized = Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "
18: $string = "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>";
19:
20: //get a class
21: class classA {
22: function __toString() {
23: return "Class A Object";
24: }
25: }
26:
27: //get a resource variable
28: $file_handle = fopen(__FILE__, "r");
29:
30: //get an unset variable
31: $unset_var = 10;
32: unset($unset_var);
33:
34: //array of values to iterate over
35: $values = array(
36:
37: // float data
38: 10.5,
39: -10.5,
40: 10.5e20,
41: 10.6E-10,
42: .5,
43:
44: // array data
45: array(),
46: array(0),
47: array(1),
48: array(1, 2),
49: array('color' => 'red', 'item' => 'pen'),
50:
51: // null data
52: NULL,
53: null,
54:
55: // boolean data
56: true,
57: false,
58: TRUE,
59: FALSE,
60:
61: // empty data
62: "",
63: '',
64:
65: // string data
66: "string",
67: 'string',
68:
69: // object data
70: new classA(),
71:
72: // undefined data
73: @$undefined_var,
74:
75: // unset data
76: @$unset_var,
77:
78: //resource
79: $file_handle
80: );
81:
82: // loop through each element of the array for quote_style
83: $iterator = 1;
84: foreach($values as $value) {
85: echo "\n-- Iteration $iterator --\n";
86: var_dump( htmlspecialchars_decode($string, $value) );
87: $iterator++;
88: }
89:
90: // close the file resource used
91: fclose($file_handle);
92:
93: echo "Done";
94: ?>
95: --EXPECTF--
96: *** Testing htmlspecialchars_decode() : usage variations ***
97:
98: -- Iteration 1 --
99: string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
100:
101: -- Iteration 2 --
102: string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
103:
104: -- Iteration 3 --
105: string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
106:
107: -- Iteration 4 --
108: string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
109:
110: -- Iteration 5 --
111: string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
112:
113: -- Iteration 6 --
114:
115: Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d
116: NULL
117:
118: -- Iteration 7 --
119:
120: Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d
121: NULL
122:
123: -- Iteration 8 --
124:
125: Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d
126: NULL
127:
128: -- Iteration 9 --
129:
130: Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d
131: NULL
132:
133: -- Iteration 10 --
134:
135: Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d
136: NULL
137:
138: -- Iteration 11 --
139: string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
140:
141: -- Iteration 12 --
142: string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
143:
144: -- Iteration 13 --
145: string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
146:
147: -- Iteration 14 --
148: string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
149:
150: -- Iteration 15 --
151: string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
152:
153: -- Iteration 16 --
154: string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
155:
156: -- Iteration 17 --
157:
158: Warning: htmlspecialchars_decode() expects parameter 2 to be long, string given in %shtmlspecialchars_decode_variation2.php on line %d
159: NULL
160:
161: -- Iteration 18 --
162:
163: Warning: htmlspecialchars_decode() expects parameter 2 to be long, string given in %shtmlspecialchars_decode_variation2.php on line %d
164: NULL
165:
166: -- Iteration 19 --
167:
168: Warning: htmlspecialchars_decode() expects parameter 2 to be long, string given in %shtmlspecialchars_decode_variation2.php on line %d
169: NULL
170:
171: -- Iteration 20 --
172:
173: Warning: htmlspecialchars_decode() expects parameter 2 to be long, string given in %shtmlspecialchars_decode_variation2.php on line %d
174: NULL
175:
176: -- Iteration 21 --
177:
178: Warning: htmlspecialchars_decode() expects parameter 2 to be long, object given in %shtmlspecialchars_decode_variation2.php on line %d
179: NULL
180:
181: -- Iteration 22 --
182: string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
183:
184: -- Iteration 23 --
185: string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
186:
187: -- Iteration 24 --
188:
189: Warning: htmlspecialchars_decode() expects parameter 2 to be long, resource given in %shtmlspecialchars_decode_variation2.php on line %d
190: NULL
191: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>