Annotation of embedaddon/php/ext/standard/tests/strings/htmlspecialchars_decode_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test htmlspecialchars_decode() function : usage variations - unexpected values for 'string' 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() with unexpected input values for $string argument
12: */
13:
14: echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
15:
16: //get a class
17: class classA
18: {
19: function __toString() {
20: return "ClassAObject";
21: }
22: }
23:
24: //get a resource variable
25: $file_handle=fopen(__FILE__, "r");
26:
27: //get an unset variable
28: $unset_var = 10;
29: unset($unset_var);
30:
31: //array of values to iterate over
32: $values = array(
33:
34: // int data
35: 0,
36: 1,
37: 12345,
38: -2345,
39:
40: // float data
41: 10.5,
42: -10.5,
43: 10.1234567e10,
44: 10.7654321E-10,
45: .5,
46:
47: // array data
48: array(),
49: array(0),
50: array(1),
51: array(1, 2),
52: array('color' => 'red', 'item' => 'pen'),
53:
54: // null data
55: NULL,
56: null,
57:
58: // boolean data
59: true,
60: false,
61: TRUE,
62: FALSE,
63:
64: // empty data
65: "",
66: '',
67:
68: // object data
69: new classA(),
70:
71: // undefined data
72: @$undefined_var,
73:
74: // unset data
75: @$unset_var,
76:
77: //resource
78: $file_handle
79: );
80:
81: // loop through each element of the array for string
82: $iterator = 1;
83: foreach($values as $value) {
84: echo "-- Iterator $iterator --\n";
85: var_dump( htmlspecialchars_decode($value) );
86: $iterator++;
87: };
88:
89: // close the file resource used
90: fclose($file_handle);
91:
92: ?>
93: ===DONE===
94: --EXPECTF--
95: *** Testing htmlspecialchars_decode() : usage variations ***
96: -- Iterator 1 --
97: string(1) "0"
98: -- Iterator 2 --
99: string(1) "1"
100: -- Iterator 3 --
101: string(5) "12345"
102: -- Iterator 4 --
103: string(5) "-2345"
104: -- Iterator 5 --
105: string(4) "10.5"
106: -- Iterator 6 --
107: string(5) "-10.5"
108: -- Iterator 7 --
109: string(12) "101234567000"
110: -- Iterator 8 --
111: string(13) "1.07654321E-9"
112: -- Iterator 9 --
113: string(3) "0.5"
114: -- Iterator 10 --
115:
116: Warning: htmlspecialchars_decode() expects parameter 1 to be string, array given in %s on line %d
117: NULL
118: -- Iterator 11 --
119:
120: Warning: htmlspecialchars_decode() expects parameter 1 to be string, array given in %s on line %d
121: NULL
122: -- Iterator 12 --
123:
124: Warning: htmlspecialchars_decode() expects parameter 1 to be string, array given in %s on line %d
125: NULL
126: -- Iterator 13 --
127:
128: Warning: htmlspecialchars_decode() expects parameter 1 to be string, array given in %s on line %d
129: NULL
130: -- Iterator 14 --
131:
132: Warning: htmlspecialchars_decode() expects parameter 1 to be string, array given in %s on line %d
133: NULL
134: -- Iterator 15 --
135: string(0) ""
136: -- Iterator 16 --
137: string(0) ""
138: -- Iterator 17 --
139: string(1) "1"
140: -- Iterator 18 --
141: string(0) ""
142: -- Iterator 19 --
143: string(1) "1"
144: -- Iterator 20 --
145: string(0) ""
146: -- Iterator 21 --
147: string(0) ""
148: -- Iterator 22 --
149: string(0) ""
150: -- Iterator 23 --
151: string(12) "ClassAObject"
152: -- Iterator 24 --
153: string(0) ""
154: -- Iterator 25 --
155: string(0) ""
156: -- Iterator 26 --
157:
158: Warning: htmlspecialchars_decode() expects parameter 1 to be string, resource given in %s on line %d
159: NULL
160: ===DONE===
161:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>