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