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 --
103bool(true)
104bool(true)
105bool(true)
106bool(true)
107bool(true)
108bool(true)
109
110-- Iteration 2 --
111bool(true)
112bool(true)
113bool(true)
114bool(true)
115bool(true)
116bool(true)
117
118-- Iteration 3 --
119bool(true)
120bool(true)
121bool(true)
122bool(true)
123bool(true)
124bool(true)
125
126-- Iteration 4 --
127
128Warning: session_set_cookie_params(): CookieLifetime cannot be negative in %s on line 81
129bool(false)
130bool(true)
131bool(true)
132bool(true)
133bool(true)
134bool(true)
135
136-- Iteration 5 --
137bool(true)
138bool(true)
139bool(true)
140bool(true)
141bool(true)
142bool(true)
143
144-- Iteration 6 --
145
146Warning: session_set_cookie_params(): CookieLifetime cannot be negative in %s on line 81
147bool(false)
148bool(true)
149bool(true)
150bool(true)
151bool(true)
152bool(true)
153
154-- Iteration 7 --
155bool(true)
156bool(true)
157bool(true)
158bool(true)
159bool(true)
160bool(true)
161
162-- Iteration 8 --
163bool(true)
164bool(true)
165bool(true)
166bool(true)
167bool(true)
168bool(true)
169
170-- Iteration 9 --
171bool(true)
172bool(true)
173bool(true)
174bool(true)
175bool(true)
176bool(true)
177
178-- Iteration 10 --
179bool(true)
180bool(true)
181bool(true)
182bool(true)
183bool(true)
184bool(true)
185
186-- Iteration 11 --
187bool(true)
188bool(true)
189bool(true)
190bool(true)
191bool(true)
192bool(true)
193
194-- Iteration 12 --
195bool(true)
196bool(true)
197bool(true)
198bool(true)
199bool(true)
200bool(true)
201
202-- Iteration 13 --
203bool(true)
204bool(true)
205bool(true)
206bool(true)
207bool(true)
208bool(true)
209
210-- Iteration 14 --
211bool(true)
212bool(true)
213bool(true)
214bool(true)
215bool(true)
216bool(true)
217
218-- Iteration 15 --
219bool(true)
220bool(true)
221bool(true)
222bool(true)
223bool(true)
224bool(true)
225
226-- Iteration 16 --
227bool(true)
228bool(true)
229bool(true)
230bool(true)
231bool(true)
232bool(true)
233
234-- Iteration 17 --
235bool(true)
236bool(true)
237bool(true)
238bool(true)
239bool(true)
240bool(true)
241
242-- Iteration 18 --
243bool(true)
244bool(true)
245bool(true)
246bool(true)
247bool(true)
248bool(true)
249
250-- Iteration 19 --
251bool(true)
252bool(true)
253bool(true)
254bool(true)
255bool(true)
256bool(true)
257
258-- Iteration 20 --
259bool(true)
260bool(true)
261bool(true)
262bool(true)
263bool(true)
264bool(true)
265
266-- Iteration 21 --
267bool(true)
268bool(true)
269bool(true)
270
271Warning: session_set_cookie_params() expects parameter 4 to be bool, object given in %s on line 84
272NULL
273
274Warning: session_set_cookie_params() expects parameter 5 to be bool, object given in %s on line 85
275NULL
276bool(true)
277
278-- Iteration 22 --
279bool(true)
280bool(true)
281bool(true)
282bool(true)
283bool(true)
284bool(true)
285
286-- Iteration 23 --
287bool(true)
288bool(true)
289bool(true)
290bool(true)
291bool(true)
292bool(true)
293
294-- Iteration 24 --
295bool(true)
296
297Warning: session_set_cookie_params() expects parameter 2 to be string, resource given in %s on line 82
298NULL
299
300Warning: session_set_cookie_params() expects parameter 3 to be string, resource given in %s on line 83
301NULL
302
303Warning: session_set_cookie_params() expects parameter 4 to be bool, resource given in %s on line 84
304NULL
305
306Warning: session_set_cookie_params() expects parameter 5 to be bool, resource given in %s on line 85
307NULL
308bool(true)
309Done
310