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