Skip to content

Commit 00f9028

Browse files
committed
session: add create_sid and validateId methods to some tests
1 parent f3341ac commit 00f9028

18 files changed

Lines changed: 134 additions & 1 deletion

ext/session/tests/gh12504.phpt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ class TestSessionHandler implements SessionHandlerInterface
3434
echo $data . PHP_EOL;
3535
return true;
3636
}
37+
38+
private int $id = 0;
39+
public function create_sid(): string {
40+
return ++$this->id;
41+
}
42+
43+
public function validateId(string $id): bool {
44+
return $id > 0 && $id <= $this->id;
45+
}
3746
}
3847

3948
register_shutdown_function(function() {

ext/session/tests/session_module_name_variation2.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ class MySessionHandler implements SessionHandlerInterface {
1818
public function write($id, $session_data): bool { return false; }
1919
public function destroy($id): bool { return false; }
2020
public function gc($maxlifetime): int { return 1; }
21+
22+
private int $id = 0;
23+
public function create_sid(): string {
24+
return ++$this->id;
25+
}
26+
public function validateId(string $id): bool {
27+
return $id > 0 && $id <= $this->id;
28+
}
2129
}
2230

2331
var_dump(session_module_name("files"));

ext/session/tests/session_module_name_variation3.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ class MySessionHandler implements SessionHandlerInterface {
2424
public function write($id, $session_data): bool { return true; }
2525
public function destroy($id): bool { return true; }
2626
public function gc($maxlifetime): int { return 1; }
27+
28+
private int $id = 0;
29+
public function create_sid(): string {
30+
return ++$this->id;
31+
}
32+
public function validateId(string $id): bool {
33+
return $id > 0 && $id <= $this->id;
34+
}
2735
}
2836

2937
var_dump(session_module_name("files"));

ext/session/tests/user_session_module/basic_set_save_handler_test.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ class handler implements SessionHandlerInterface {
4444
}
4545

4646
function gc($max_lifetime): int { return 1; }
47+
48+
private int $id = 0;
49+
public function create_sid(): string {
50+
return ++$this->id;
51+
}
52+
public function validateId(string $id): bool {
53+
return $id > 0 && $id <= $this->id;
54+
}
4755
}
4856

4957
$hnd = new handler;

ext/session/tests/user_session_module/basic_set_save_handler_test02.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ class handler implements SessionHandlerInterface {
4545
}
4646

4747
function gc($max_lifetime): int { return 1; }
48+
49+
private int $id = 0;
50+
public function create_sid(): string {
51+
return ++$this->id;
52+
}
53+
public function validateId(string $id): bool {
54+
return $id > 0 && $id <= $this->id;
55+
}
4856
}
4957

5058
$hnd = new handler;

ext/session/tests/user_session_module/bug32330.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ class MySessionHandler implements SessionHandlerInterface {
4949
echo "gc: maxlifetime = {$maxlifetime}\n";
5050
return 1;
5151
}
52+
53+
private int $id = 0;
54+
public function create_sid(): string {
55+
return ++$this->id;
56+
}
57+
public function validateId(string $id): bool {
58+
return $id > 0 && $id <= $this->id;
59+
}
5260
}
5361

5462
session_set_save_handler(new MySessionHandler());

ext/session/tests/user_session_module/bug60634.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ class MySessionHandler implements SessionHandlerInterface {
3535
function gc($maxlifetime): int {
3636
return 1;
3737
}
38+
39+
private int $id = 0;
40+
public function create_sid(): string {
41+
return ++$this->id;
42+
}
43+
public function validateId(string $id): bool {
44+
return $id > 0 && $id <= $this->id;
45+
}
3846
}
3947

4048
session_set_save_handler(new MySessionHandler());

ext/session/tests/user_session_module/bug60634_error_1.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ class MySessionHandler implements SessionHandlerInterface {
3737
function gc($maxlifetime): int {
3838
return 1;
3939
}
40+
41+
private int $id = 0;
42+
public function create_sid(): string {
43+
return ++$this->id;
44+
}
45+
public function validateId(string $id): bool {
46+
return $id > 0 && $id <= $this->id;
47+
}
4048
}
4149
session_set_save_handler(new MySessionHandler());
4250
session_start();

ext/session/tests/user_session_module/bug60634_error_2.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ class MySessionHandler implements SessionHandlerInterface {
3737
function gc($maxlifetime): int {
3838
return true;
3939
}
40+
41+
private int $id = 0;
42+
public function create_sid(): string {
43+
return ++$this->id;
44+
}
45+
public function validateId(string $id): bool {
46+
return $id > 0 && $id <= $this->id;
47+
}
4048
}
4149

4250
session_set_save_handler(new MySessionHandler());

ext/session/tests/user_session_module/bug60634_error_5.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ class MySessionHandler implements SessionHandlerInterface {
3636
function gc($maxlifetime): int {
3737
return 1;
3838
}
39+
40+
private int $id = 0;
41+
public function create_sid(): string {
42+
return ++$this->id;
43+
}
44+
public function validateId(string $id): bool {
45+
return $id > 0 && $id <= $this->id;
46+
}
3947
}
4048

4149
session_set_save_handler(new MySessionHandler());

0 commit comments

Comments
 (0)