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