Annotation of embedaddon/php/ext/session/tests/session_decode_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test session_decode() function : error functionality
3: --SKIPIF--
4: <?php include('skipif.inc'); ?>
5: --FILE--
6: <?php
7:
8: ob_start();
9:
10: /*
11: * Prototype : string session_decode(void)
12: * Description : Decodes session data from a string
13: * Source code : ext/session/session.c
14: */
15:
16: echo "*** Testing session_decode() : error functionality ***\n";
17:
18: // Get an unset variable
19: $unset_var = 10;
20: unset($unset_var);
21:
22: class classA
23: {
24: public function __toString() {
25: return "Hello World!";
26: }
27: }
28:
29: $heredoc = <<<EOT
30: Hello World!
31: EOT;
32:
33: $fp = fopen(__FILE__, "r");
34:
35: // Unexpected values to be passed as arguments
36: $inputs = array(
37:
38: // Integer data
39: /*1*/ 0,
40: 1,
41: 12345,
42: -2345,
43:
44: // Float data
45: /*5*/ 10.5,
46: -10.5,
47: 12.3456789000e10,
48: 12.3456789000E-10,
49: .5,
50:
51: // Null data
52: /*10*/ NULL,
53: null,
54:
55: // Boolean data
56: /*12*/ true,
57: false,
58: TRUE,
59: FALSE,
60:
61: // Empty strings
62: /*16*/ "",
63: '',
64:
65: // Invalid string data
66: /*18*/ "Nothing",
67: 'Nothing',
68: $heredoc,
69:
70: // Object data
71: /*21*/ new classA(),
72:
73: // Undefined data
74: /*22*/ @$undefined_var,
75:
76: // Unset data
77: /*23*/ @$unset_var,
78:
79: // Resource variable
80: /*24*/ $fp
81: );
82:
83: var_dump(session_start());
84: $iterator = 1;
85: foreach($inputs as $input) {
86: echo "\n-- Iteration $iterator --\n";
87: var_dump(session_decode($input));
88: var_dump($_SESSION);
89: $iterator++;
90: };
91:
92: var_dump(session_destroy());
93: fclose($fp);
94: echo "Done";
95: ob_end_flush();
96: ?>
97: --EXPECTF--
98: *** Testing session_decode() : error functionality ***
99: bool(true)
100:
101: -- Iteration 1 --
102: bool(true)
103: array(0) {
104: }
105:
106: -- Iteration 2 --
107: bool(true)
108: array(0) {
109: }
110:
111: -- Iteration 3 --
112: bool(true)
113: array(0) {
114: }
115:
116: -- Iteration 4 --
117: bool(true)
118: array(0) {
119: }
120:
121: -- Iteration 5 --
122: bool(true)
123: array(0) {
124: }
125:
126: -- Iteration 6 --
127: bool(true)
128: array(0) {
129: }
130:
131: -- Iteration 7 --
132: bool(true)
133: array(0) {
134: }
135:
136: -- Iteration 8 --
137: bool(true)
138: array(0) {
139: }
140:
141: -- Iteration 9 --
142: bool(true)
143: array(0) {
144: }
145:
146: -- Iteration 10 --
147: bool(true)
148: array(0) {
149: }
150:
151: -- Iteration 11 --
152: bool(true)
153: array(0) {
154: }
155:
156: -- Iteration 12 --
157: bool(true)
158: array(0) {
159: }
160:
161: -- Iteration 13 --
162: bool(true)
163: array(0) {
164: }
165:
166: -- Iteration 14 --
167: bool(true)
168: array(0) {
169: }
170:
171: -- Iteration 15 --
172: bool(true)
173: array(0) {
174: }
175:
176: -- Iteration 16 --
177: bool(true)
178: array(0) {
179: }
180:
181: -- Iteration 17 --
182: bool(true)
183: array(0) {
184: }
185:
186: -- Iteration 18 --
187: bool(true)
188: array(0) {
189: }
190:
191: -- Iteration 19 --
192: bool(true)
193: array(0) {
194: }
195:
196: -- Iteration 20 --
197: bool(true)
198: array(0) {
199: }
200:
201: -- Iteration 21 --
202: bool(true)
203: array(0) {
204: }
205:
206: -- Iteration 22 --
207: bool(true)
208: array(0) {
209: }
210:
211: -- Iteration 23 --
212: bool(true)
213: array(0) {
214: }
215:
216: -- Iteration 24 --
217:
218: Warning: session_decode() expects parameter 1 to be string, resource given in %s on line %d
219: NULL
220: array(0) {
221: }
222: bool(true)
223: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>