1--TEST--
2Test session_set_save_handler() function : error functionality
3--EXTENSIONS--
4session
5--SKIPIF--
6<?php include('skipif.inc'); ?>
7--FILE--
8<?php
9
10ob_start();
11
12echo "*** Testing session_set_save_handler() : error functionality ***\n";
13
14// Get an unset variable
15$unset_var = 10;
16unset($unset_var);
17
18class classA
19{
20    public function __toString() {
21        return "Hello World!";
22    }
23}
24
25$heredoc = <<<EOT
26Hello World!
27EOT;
28
29$fp = fopen(__FILE__, "r");
30
31// Unexpected values to be passed as arguments
32$inputs = array(
33
34       // Integer data
35/*1*/  0,
36       1,
37       12345,
38       -2345,
39
40       // Float data
41/*5*/  10.5,
42       -10.5,
43       12.3456789000e10,
44       12.3456789000E-10,
45       .5,
46
47       // Null data
48/*10*/ NULL,
49       null,
50
51       // Boolean data
52/*12*/ true,
53       false,
54       TRUE,
55       FALSE,
56
57       // Empty strings
58/*16*/ "",
59       '',
60
61       // Invalid string data
62/*18*/ "Nothing",
63       'Nothing',
64       $heredoc,
65
66       // Object data
67/*21*/ new classA(),
68
69       // Undefined data
70/*22*/ @$undefined_var,
71
72       // Unset data
73/*23*/ @$unset_var,
74
75       // Resource variable
76/*24*/ $fp
77);
78
79
80$iterator = 1;
81foreach($inputs as $input) {
82    echo "\n-- Iteration $iterator --\n";
83    try {
84        session_set_save_handler($input, NULL, NULL, NULL, NULL, NULL);
85    } catch (TypeError $exception) {
86        echo $exception->getMessage() . "\n";
87    }
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 --
99session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "0" not found or invalid function name
100
101-- Iteration 2 --
102session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "1" not found or invalid function name
103
104-- Iteration 3 --
105session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "12345" not found or invalid function name
106
107-- Iteration 4 --
108session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "-2345" not found or invalid function name
109
110-- Iteration 5 --
111session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "10.5" not found or invalid function name
112
113-- Iteration 6 --
114session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "-10.5" not found or invalid function name
115
116-- Iteration 7 --
117session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "123456789000" not found or invalid function name
118
119-- Iteration 8 --
120session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "1.23456789E-9" not found or invalid function name
121
122-- Iteration 9 --
123session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "0.5" not found or invalid function name
124
125-- Iteration 10 --
126session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
127
128-- Iteration 11 --
129session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
130
131-- Iteration 12 --
132session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "1" not found or invalid function name
133
134-- Iteration 13 --
135session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
136
137-- Iteration 14 --
138session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "1" not found or invalid function name
139
140-- Iteration 15 --
141session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
142
143-- Iteration 16 --
144session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
145
146-- Iteration 17 --
147session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
148
149-- Iteration 18 --
150session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "Nothing" not found or invalid function name
151
152-- Iteration 19 --
153session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "Nothing" not found or invalid function name
154
155-- Iteration 20 --
156session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "Hello World!" not found or invalid function name
157
158-- Iteration 21 --
159session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "classA::__invoke" not found or invalid function name
160
161-- Iteration 22 --
162session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
163
164-- Iteration 23 --
165session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
166
167-- Iteration 24 --
168session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "Resource id #%d" not found or invalid function name
169Done
170