Skip to content

Commit 4829b8f

Browse files
authored
ext/session: Add test for session_start with read_and_close option (php#13799)
1 parent 6df8111 commit 4829b8f

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
Test session_start() with flag read_and_close
3+
--EXTENSIONS--
4+
session
5+
--SKIPIF--
6+
<?php include('skipif.inc'); ?>
7+
--FILE--
8+
<?php
9+
10+
ob_start();
11+
12+
$valuesEnablingReadAndClose = [true, 1, "1", "777", 777, -1];
13+
14+
$valuesDisablingReadAndClose = ["true", false, "false", 0, "0", "no", "00000"];
15+
16+
foreach ($valuesEnablingReadAndClose as $value) {
17+
session_start(["read_and_close" => $value]);
18+
var_dump(session_status() === PHP_SESSION_NONE);
19+
}
20+
21+
foreach ($valuesDisablingReadAndClose as $value) {
22+
session_start(["read_and_close" => $value]);
23+
var_dump(session_status() === PHP_SESSION_ACTIVE);
24+
session_write_close();
25+
}
26+
27+
try {
28+
session_start(["read_and_close" => 1.0]);
29+
} catch (Throwable $e) {
30+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
31+
}
32+
33+
ob_end_flush();
34+
?>
35+
--EXPECTF--
36+
bool(true)
37+
bool(true)
38+
bool(true)
39+
bool(true)
40+
bool(true)
41+
bool(true)
42+
bool(true)
43+
bool(true)
44+
bool(true)
45+
bool(true)
46+
bool(true)
47+
bool(true)
48+
bool(true)
49+
TypeError: session_start(): Option "read_and_close" must be of type string|int|bool, float given

0 commit comments

Comments
 (0)