1: --TEST--
2: Test session_name() function : error functionality
3: --INI--
4: session.save_path=
5: session.name=PHPSESSID
6: --SKIPIF--
7: <?php include('skipif.inc'); ?>
8: --FILE--
9: <?php
10:
11: ob_start();
12:
13: /*
14: * Prototype : string session_name([string $name])
15: * Description : Get and/or set the current session name
16: * Source code : ext/session/session.c
17: */
18:
19: echo "*** Testing session_name() : error functionality ***\n";
20:
21: // Get an unset variable
22: $unset_var = 10;
23: unset($unset_var);
24:
25: class classA
26: {
27: public function __toString() {
28: return "Hello World!";
29: }
30: }
31:
32: $heredoc = <<<EOT
33: Hello World!
34: EOT;
35:
36: $fp = fopen(__FILE__, "r");
37:
38: // Unexpected values to be passed as arguments
39: $inputs = array(
40:
41: // Integer data
42: /*1*/ 0,
43: 1,
44: 12345,
45: -2345,
46:
47: // Float data
48: /*5*/ 10.5,
49: -10.5,
50: 12.3456789000e10,
51: 12.3456789000E-10,
52: .5,
53:
54: // Null data
55: /*10*/ NULL,
56: null,
57:
58: // Boolean data
59: /*12*/ true,
60: false,
61: TRUE,
62: FALSE,
63:
64: // Empty strings
65: /*16*/ "",
66: '',
67:
68: // Invalid string data
69: /*18*/ "Nothing",
70: 'Nothing',
71: $heredoc,
72:
73: // Object data
74: /*21*/ new classA(),
75:
76: // Undefined data
77: /*22*/ @$undefined_var,
78:
79: // Unset data
80: /*23*/ @$unset_var,
81:
82: // Resource variable
83: /*24*/ $fp
84: );
85:
86: $iterator = 1;
87: foreach($inputs as $input) {
88: echo "\n-- Iteration $iterator --\n";
89: var_dump($input, session_name($input));
90: $iterator++;
91: };
92:
93: fclose($fp);
94: echo "Done";
95: ob_end_flush();
96: ?>
97: --EXPECTF--
98: *** Testing session_name() : error functionality ***
99:
100: -- Iteration 1 --
101:
102: Warning: session_name(): session.name cannot be a numeric or empty '0' in %s on line %d
103: int(0)
104: string(9) "PHPSESSID"
105:
106: -- Iteration 2 --
107:
108: Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
109: int(1)
110: string(9) "PHPSESSID"
111:
112: -- Iteration 3 --
113:
114: Warning: session_name(): session.name cannot be a numeric or empty '12345' in %s on line %d
115: int(12345)
116: string(9) "PHPSESSID"
117:
118: -- Iteration 4 --
119:
120: Warning: session_name(): session.name cannot be a numeric or empty '-2345' in %s on line %d
121: int(-2345)
122: string(9) "PHPSESSID"
123:
124: -- Iteration 5 --
125:
126: Warning: session_name(): session.name cannot be a numeric or empty '10.5' in %s on line %d
127: float(10.5)
128: string(9) "PHPSESSID"
129:
130: -- Iteration 6 --
131:
132: Warning: session_name(): session.name cannot be a numeric or empty '-10.5' in %s on line %d
133: float(-10.5)
134: string(9) "PHPSESSID"
135:
136: -- Iteration 7 --
137:
138: Warning: session_name(): session.name cannot be a numeric or empty '123456789000' in %s on line %d
139: float(123456789000)
140: string(9) "PHPSESSID"
141:
142: -- Iteration 8 --
143:
144: Warning: session_name(): session.name cannot be a numeric or empty '1.23456789E-9' in %s on line %d
145: float(1.23456789E-9)
146: string(9) "PHPSESSID"
147:
148: -- Iteration 9 --
149:
150: Warning: session_name(): session.name cannot be a numeric or empty '0.5' in %s on line %d
151: float(0.5)
152: string(9) "PHPSESSID"
153:
154: -- Iteration 10 --
155:
156: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
157: NULL
158: string(9) "PHPSESSID"
159:
160: -- Iteration 11 --
161:
162: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
163: NULL
164: string(9) "PHPSESSID"
165:
166: -- Iteration 12 --
167:
168: Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
169: bool(true)
170: string(9) "PHPSESSID"
171:
172: -- Iteration 13 --
173:
174: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
175: bool(false)
176: string(9) "PHPSESSID"
177:
178: -- Iteration 14 --
179:
180: Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
181: bool(true)
182: string(9) "PHPSESSID"
183:
184: -- Iteration 15 --
185:
186: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
187: bool(false)
188: string(9) "PHPSESSID"
189:
190: -- Iteration 16 --
191:
192: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
193: string(0) ""
194: string(9) "PHPSESSID"
195:
196: -- Iteration 17 --
197:
198: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
199: string(0) ""
200: string(9) "PHPSESSID"
201:
202: -- Iteration 18 --
203: string(7) "Nothing"
204: string(9) "PHPSESSID"
205:
206: -- Iteration 19 --
207: string(7) "Nothing"
208: string(7) "Nothing"
209:
210: -- Iteration 20 --
211: string(12) "Hello World!"
212: string(7) "Nothing"
213:
214: -- Iteration 21 --
215: object(classA)#1 (0) {
216: }
217: string(12) "Hello World!"
218:
219: -- Iteration 22 --
220:
221: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
222: NULL
223: string(12) "Hello World!"
224:
225: -- Iteration 23 --
226:
227: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
228: NULL
229: string(12) "Hello World!"
230:
231: -- Iteration 24 --
232:
233: Warning: session_name() expects parameter 1 to be string, resource given in %s on line %d
234: resource(5) of type (stream)
235: NULL
236: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>