1--TEST--
2Test session_start() function : error functionality
3--SKIPIF--
4<?php include('skipif.inc'); ?>
5--FILE--
6<?php
7
8ob_start();
9
10/*
11 * Prototype : bool session_start(void)
12 * Description : Initialize session data
13 * Source code : ext/session/session.c
14 */
15
16echo "*** Testing session_start() : error functionality ***\n";
17
18// Get an unset variable
19$unset_var = 10;
20unset($unset_var);
21
22class classA
23{
24    public function __toString() {
25        return "Hello World!";
26    }
27}
28
29$heredoc = <<<EOT
30Hello World!
31EOT;
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
84$iterator = 1;
85foreach($inputs as $input) {
86    echo "\n-- Iteration $iterator --\n";
87    var_dump(session_start($input));
88    var_dump(session_destroy());
89    $iterator++;
90};
91
92fclose($fp);
93echo "Done";
94ob_end_flush();
95?>
96--EXPECTF--
97*** Testing session_start() : error functionality ***
98
99-- Iteration 1 --
100
101Warning: session_start() expects parameter 1 to be array, integer given in %s on line %d
102bool(false)
103
104Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
105bool(false)
106
107-- Iteration 2 --
108
109Warning: session_start() expects parameter 1 to be array, integer given in %s on line %d
110bool(false)
111
112Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
113bool(false)
114
115-- Iteration 3 --
116
117Warning: session_start() expects parameter 1 to be array, integer given in %s on line %d
118bool(false)
119
120Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
121bool(false)
122
123-- Iteration 4 --
124
125Warning: session_start() expects parameter 1 to be array, integer given in %s on line %d
126bool(false)
127
128Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
129bool(false)
130
131-- Iteration 5 --
132
133Warning: session_start() expects parameter 1 to be array, float given in %s on line %d
134bool(false)
135
136Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
137bool(false)
138
139-- Iteration 6 --
140
141Warning: session_start() expects parameter 1 to be array, float given in %s on line %d
142bool(false)
143
144Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
145bool(false)
146
147-- Iteration 7 --
148
149Warning: session_start() expects parameter 1 to be array, float given in %s on line %d
150bool(false)
151
152Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
153bool(false)
154
155-- Iteration 8 --
156
157Warning: session_start() expects parameter 1 to be array, float given in %s on line %d
158bool(false)
159
160Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
161bool(false)
162
163-- Iteration 9 --
164
165Warning: session_start() expects parameter 1 to be array, float given in %s on line %d
166bool(false)
167
168Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
169bool(false)
170
171-- Iteration 10 --
172
173Warning: session_start() expects parameter 1 to be array, null given in %s on line %d
174bool(false)
175
176Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
177bool(false)
178
179-- Iteration 11 --
180
181Warning: session_start() expects parameter 1 to be array, null given in %s on line %d
182bool(false)
183
184Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
185bool(false)
186
187-- Iteration 12 --
188
189Warning: session_start() expects parameter 1 to be array, boolean given in %s on line %d
190bool(false)
191
192Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
193bool(false)
194
195-- Iteration 13 --
196
197Warning: session_start() expects parameter 1 to be array, boolean given in %s on line %d
198bool(false)
199
200Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
201bool(false)
202
203-- Iteration 14 --
204
205Warning: session_start() expects parameter 1 to be array, boolean given in %s on line %d
206bool(false)
207
208Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
209bool(false)
210
211-- Iteration 15 --
212
213Warning: session_start() expects parameter 1 to be array, boolean given in %s on line %d
214bool(false)
215
216Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
217bool(false)
218
219-- Iteration 16 --
220
221Warning: session_start() expects parameter 1 to be array, string given in %s on line %d
222bool(false)
223
224Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
225bool(false)
226
227-- Iteration 17 --
228
229Warning: session_start() expects parameter 1 to be array, string given in %s on line %d
230bool(false)
231
232Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
233bool(false)
234
235-- Iteration 18 --
236
237Warning: session_start() expects parameter 1 to be array, string given in %s on line %d
238bool(false)
239
240Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
241bool(false)
242
243-- Iteration 19 --
244
245Warning: session_start() expects parameter 1 to be array, string given in %s on line %d
246bool(false)
247
248Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
249bool(false)
250
251-- Iteration 20 --
252
253Warning: session_start() expects parameter 1 to be array, string given in %s on line %d
254bool(false)
255
256Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
257bool(false)
258
259-- Iteration 21 --
260
261Warning: session_start() expects parameter 1 to be array, object given in %s on line %d
262bool(false)
263
264Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
265bool(false)
266
267-- Iteration 22 --
268
269Warning: session_start() expects parameter 1 to be array, null given in %s on line %d
270bool(false)
271
272Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
273bool(false)
274
275-- Iteration 23 --
276
277Warning: session_start() expects parameter 1 to be array, null given in %s on line %d
278bool(false)
279
280Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
281bool(false)
282
283-- Iteration 24 --
284
285Warning: session_start() expects parameter 1 to be array, resource given in %s on line %d
286bool(false)
287
288Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
289bool(false)
290Done
291