1--TEST--
2Test session_register() function : basic functionality
3--SKIPIF--
4<?php include('skipif.inc'); ?>
5--FILE--
6<?php
7
8ob_start();
9
10/*
11 * Prototype : bool session_register(mixed $name [,mixed $...])
12 * Description : Register one or more global variables with the current session
13 * Source code : ext/session/session.c
14 */
15
16echo "*** Testing session_register() : 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
83
84$iterator = 1;
85foreach($inputs as $input) {
86    echo "\n-- Iteration $iterator --\n";
87    var_dump(session_start());
88    var_dump(session_register($input));
89    var_dump($_SESSION);
90    var_dump(session_destroy());
91    $iterator++;
92};
93
94fclose($fp);
95echo "Done";
96ob_end_flush();
97?>
98--EXPECTF--
99*** Testing session_register() : basic functionality ***
100
101-- Iteration 1 --
102bool(true)
103
104Deprecated: Function session_register() is deprecated in %s on line %d
105bool(true)
106array(1) {
107  ["0"]=>
108  NULL
109}
110bool(true)
111
112-- Iteration 2 --
113bool(true)
114
115Deprecated: Function session_register() is deprecated in %s on line %d
116bool(true)
117array(1) {
118  ["1"]=>
119  NULL
120}
121bool(true)
122
123-- Iteration 3 --
124bool(true)
125
126Deprecated: Function session_register() is deprecated in %s on line %d
127bool(true)
128array(1) {
129  ["12345"]=>
130  NULL
131}
132bool(true)
133
134-- Iteration 4 --
135bool(true)
136
137Deprecated: Function session_register() is deprecated in %s on line %d
138bool(true)
139array(1) {
140  ["-2345"]=>
141  NULL
142}
143bool(true)
144
145-- Iteration 5 --
146bool(true)
147
148Deprecated: Function session_register() is deprecated in %s on line %d
149bool(true)
150array(1) {
151  ["10.5"]=>
152  NULL
153}
154bool(true)
155
156-- Iteration 6 --
157bool(true)
158
159Deprecated: Function session_register() is deprecated in %s on line %d
160bool(true)
161array(1) {
162  ["-10.5"]=>
163  NULL
164}
165bool(true)
166
167-- Iteration 7 --
168bool(true)
169
170Deprecated: Function session_register() is deprecated in %s on line %d
171bool(true)
172array(1) {
173  ["123456789000"]=>
174  NULL
175}
176bool(true)
177
178-- Iteration 8 --
179bool(true)
180
181Deprecated: Function session_register() is deprecated in %s on line %d
182bool(true)
183array(1) {
184  ["1.23456789E-9"]=>
185  NULL
186}
187bool(true)
188
189-- Iteration 9 --
190bool(true)
191
192Deprecated: Function session_register() is deprecated in %s on line %d
193bool(true)
194array(1) {
195  ["0.5"]=>
196  NULL
197}
198bool(true)
199
200-- Iteration 10 --
201bool(true)
202
203Deprecated: Function session_register() is deprecated in %s on line %d
204bool(true)
205array(1) {
206  [""]=>
207  NULL
208}
209bool(true)
210
211-- Iteration 11 --
212bool(true)
213
214Deprecated: Function session_register() is deprecated in %s on line %d
215bool(true)
216array(1) {
217  [""]=>
218  NULL
219}
220bool(true)
221
222-- Iteration 12 --
223bool(true)
224
225Deprecated: Function session_register() is deprecated in %s on line %d
226bool(true)
227array(1) {
228  ["1"]=>
229  NULL
230}
231bool(true)
232
233-- Iteration 13 --
234bool(true)
235
236Deprecated: Function session_register() is deprecated in %s on line %d
237bool(true)
238array(1) {
239  [""]=>
240  NULL
241}
242bool(true)
243
244-- Iteration 14 --
245bool(true)
246
247Deprecated: Function session_register() is deprecated in %s on line %d
248bool(true)
249array(1) {
250  ["1"]=>
251  NULL
252}
253bool(true)
254
255-- Iteration 15 --
256bool(true)
257
258Deprecated: Function session_register() is deprecated in %s on line %d
259bool(true)
260array(1) {
261  [""]=>
262  NULL
263}
264bool(true)
265
266-- Iteration 16 --
267bool(true)
268
269Deprecated: Function session_register() is deprecated in %s on line %d
270bool(true)
271array(1) {
272  [""]=>
273  NULL
274}
275bool(true)
276
277-- Iteration 17 --
278bool(true)
279
280Deprecated: Function session_register() is deprecated in %s on line %d
281bool(true)
282array(1) {
283  [""]=>
284  NULL
285}
286bool(true)
287
288-- Iteration 18 --
289bool(true)
290
291Deprecated: Function session_register() is deprecated in %s on line %d
292bool(true)
293array(1) {
294  ["Nothing"]=>
295  NULL
296}
297bool(true)
298
299-- Iteration 19 --
300bool(true)
301
302Deprecated: Function session_register() is deprecated in %s on line %d
303bool(true)
304array(1) {
305  ["Nothing"]=>
306  NULL
307}
308bool(true)
309
310-- Iteration 20 --
311bool(true)
312
313Deprecated: Function session_register() is deprecated in %s on line %d
314bool(true)
315array(1) {
316  ["Hello World!"]=>
317  NULL
318}
319bool(true)
320
321-- Iteration 21 --
322bool(true)
323
324Deprecated: Function session_register() is deprecated in %s on line %d
325bool(true)
326array(1) {
327  ["Hello World!"]=>
328  NULL
329}
330bool(true)
331
332-- Iteration 22 --
333bool(true)
334
335Deprecated: Function session_register() is deprecated in %s on line %d
336bool(true)
337array(1) {
338  [""]=>
339  NULL
340}
341bool(true)
342
343-- Iteration 23 --
344bool(true)
345
346Deprecated: Function session_register() is deprecated in %s on line %d
347bool(true)
348array(1) {
349  [""]=>
350  NULL
351}
352bool(true)
353
354-- Iteration 24 --
355bool(true)
356
357Deprecated: Function session_register() is deprecated in %s on line %d
358bool(true)
359array(1) {
360  ["Resource id #%d"]=>
361  NULL
362}
363bool(true)
364Done
365