1--TEST--
2Test session_set_save_handler() function : error functionality
3--SKIPIF--
4<?php include('skipif.inc'); ?>
5--FILE--
6<?php
7
8ob_start();
9
10/*
11 * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc)
12 * Description : Sets user-level session storage functions
13 * Source code : ext/session/session.c
14 */
15
16echo "*** Testing session_set_save_handler() : 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_set_save_handler($input, NULL, NULL, NULL, NULL, NULL));
88    $iterator++;
89};
90
91fclose($fp);
92echo "Done";
93ob_end_flush();
94?>
95--EXPECTF--
96*** Testing session_set_save_handler() : error functionality ***
97
98-- Iteration 1 --
99
100Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
101bool(false)
102
103-- Iteration 2 --
104
105Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
106bool(false)
107
108-- Iteration 3 --
109
110Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
111bool(false)
112
113-- Iteration 4 --
114
115Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
116bool(false)
117
118-- Iteration 5 --
119
120Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
121bool(false)
122
123-- Iteration 6 --
124
125Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
126bool(false)
127
128-- Iteration 7 --
129
130Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
131bool(false)
132
133-- Iteration 8 --
134
135Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
136bool(false)
137
138-- Iteration 9 --
139
140Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
141bool(false)
142
143-- Iteration 10 --
144
145Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
146bool(false)
147
148-- Iteration 11 --
149
150Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
151bool(false)
152
153-- Iteration 12 --
154
155Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
156bool(false)
157
158-- Iteration 13 --
159
160Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
161bool(false)
162
163-- Iteration 14 --
164
165Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
166bool(false)
167
168-- Iteration 15 --
169
170Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
171bool(false)
172
173-- Iteration 16 --
174
175Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
176bool(false)
177
178-- Iteration 17 --
179
180Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
181bool(false)
182
183-- Iteration 18 --
184
185Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
186bool(false)
187
188-- Iteration 19 --
189
190Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
191bool(false)
192
193-- Iteration 20 --
194
195Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
196bool(false)
197
198-- Iteration 21 --
199
200Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
201bool(false)
202
203-- Iteration 22 --
204
205Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
206bool(false)
207
208-- Iteration 23 --
209
210Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
211bool(false)
212
213-- Iteration 24 --
214
215Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
216bool(false)
217Done
218