1--TEST--
2Test session_save_path() function : error functionality
3--INI--
4session.gc_probability=0
5session.save_path=
6session.name=PHPSESSID
7--SKIPIF--
8<?php include('skipif.inc'); ?>
9--FILE--
10<?php
11
12ob_start();
13
14/*
15 * Prototype : string session_save_path([string $path])
16 * Description : Get and/or set the current session save path
17 * Source code : ext/session/session.c
18 */
19
20echo "*** Testing session_save_path() : error functionality ***\n";
21
22// Get an unset variable
23$unset_var = 10;
24unset($unset_var);
25
26class classA
27{
28    public function __toString() {
29        return "Hello World!";
30    }
31}
32
33$heredoc = <<<EOT
34Hello World!
35EOT;
36
37$fp = fopen(__FILE__, "r");
38
39// Unexpected values to be passed as arguments
40$inputs = array(
41
42       // Integer data
43/*1*/  0,
44       1,
45       12345,
46       -2345,
47
48       // Float data
49/*5*/  10.5,
50       -10.5,
51       12.3456789000e10,
52       12.3456789000E-10,
53       .5,
54
55       // Null data
56/*10*/ NULL,
57       null,
58
59       // Boolean data
60/*12*/ true,
61       false,
62       TRUE,
63       FALSE,
64
65       // Empty strings
66/*16*/ "",
67       '',
68
69       // Invalid string data
70/*18*/ "Nothing",
71       'Nothing',
72       $heredoc,
73
74       // Object data
75/*21*/ new classA(),
76
77       // Undefined data
78/*22*/ @$undefined_var,
79
80       // Unset data
81/*23*/ @$unset_var,
82
83       // Resource variable
84/*24*/ $fp
85);
86
87session_start();
88
89$iterator = 1;
90foreach($inputs as $input) {
91    echo "\n-- Iteration $iterator --\n";
92    var_dump(session_save_path($input));
93    $iterator++;
94};
95
96session_destroy();
97fclose($fp);
98echo "Done";
99ob_end_flush();
100?>
101--EXPECTF--
102*** Testing session_save_path() : error functionality ***
103
104-- Iteration 1 --
105string(0) ""
106
107-- Iteration 2 --
108string(1) "0"
109
110-- Iteration 3 --
111string(1) "1"
112
113-- Iteration 4 --
114string(5) "12345"
115
116-- Iteration 5 --
117string(5) "-2345"
118
119-- Iteration 6 --
120string(4) "10.5"
121
122-- Iteration 7 --
123string(5) "-10.5"
124
125-- Iteration 8 --
126string(12) "123456789000"
127
128-- Iteration 9 --
129string(13) "1.23456789E-9"
130
131-- Iteration 10 --
132string(3) "0.5"
133
134-- Iteration 11 --
135string(0) ""
136
137-- Iteration 12 --
138string(0) ""
139
140-- Iteration 13 --
141string(1) "1"
142
143-- Iteration 14 --
144string(0) ""
145
146-- Iteration 15 --
147string(1) "1"
148
149-- Iteration 16 --
150string(0) ""
151
152-- Iteration 17 --
153string(0) ""
154
155-- Iteration 18 --
156string(0) ""
157
158-- Iteration 19 --
159string(7) "Nothing"
160
161-- Iteration 20 --
162string(7) "Nothing"
163
164-- Iteration 21 --
165string(12) "Hello World!"
166
167-- Iteration 22 --
168string(12) "Hello World!"
169
170-- Iteration 23 --
171string(0) ""
172
173-- Iteration 24 --
174
175Warning: session_save_path() expects parameter 1 to be string, resource given in %s on line %d
176NULL
177Done
178
179