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