Skip to content

Commit 7e8f115

Browse files
Fabien Villepintecmb69
Fabien Villepinte
authored andcommitted
Make some session tests more robust
1 parent d26eb10 commit 7e8f115

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

ext/session/tests/session_set_save_handler_class_017.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class MySession2 extends SessionHandler {
5555
}
5656

5757
public function create_sid() {
58-
return 'my_sid';
58+
return pathinfo(__FILE__)['filename'];
5959
}
6060
}
6161

@@ -72,12 +72,12 @@ session_unset();
7272

7373
session_start();
7474
var_dump($_SESSION);
75-
76-
session_write_close();
77-
session_unset();
78-
--EXPECTF--
75+
--CLEAN--
76+
<?php
77+
@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_class_017');
78+
--EXPECT--
7979
*** Testing session_set_save_handler() function: class with create_sid ***
80-
string(%d) "my_sid"
80+
string(34) "session_set_save_handler_class_017"
8181
string(4) "user"
8282
array(1) {
8383
["foo"]=>

ext/session/tests/session_set_save_handler_class_018.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MySession2 extends SessionHandler {
3434
}
3535

3636
public function read($id) {
37-
return @file_get_contents($this->path . $id);
37+
return (string)@file_get_contents($this->path . $id);
3838
}
3939

4040
public function write($id, $data) {
@@ -55,11 +55,11 @@ class MySession2 extends SessionHandler {
5555
}
5656

5757
public function create_sid() {
58-
return 'my_sid';
58+
return pathinfo(__FILE__)['filename'];
5959
}
6060

6161
public function validate_sid($id) {
62-
return 'my_sid'===$id;
62+
return pathinfo(__FILE__)['filename']===$id;
6363
}
6464
}
6565

@@ -76,12 +76,12 @@ session_unset();
7676

7777
session_start();
7878
var_dump($_SESSION);
79-
80-
session_write_close();
81-
session_unset();
82-
--EXPECTF--
79+
--CLEAN--
80+
<?php
81+
@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_class_018');
82+
--EXPECT--
8383
*** Testing session_set_save_handler() function: class with validate_sid ***
84-
string(%d) "my_sid"
84+
string(34) "session_set_save_handler_class_018"
8585
string(4) "user"
8686
array(1) {
8787
["foo"]=>

ext/session/tests/session_set_save_handler_iface_003.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MySession2 implements SessionHandlerInterface, SessionIdInterface {
3434
}
3535

3636
public function read($id) {
37-
return @file_get_contents($this->path . $id);
37+
return (string)@file_get_contents($this->path . $id);
3838
}
3939

4040
public function write($id, $data) {
@@ -56,7 +56,7 @@ class MySession2 implements SessionHandlerInterface, SessionIdInterface {
5656
}
5757

5858
public function create_sid() {
59-
return 'my_sid';
59+
return pathinfo(__FILE__)['filename'];
6060
}
6161
}
6262

@@ -73,12 +73,12 @@ session_unset();
7373

7474
session_start();
7575
var_dump($_SESSION);
76-
77-
session_write_close();
78-
session_unset();
79-
--EXPECTF--
76+
--CLEAN--
77+
<?php
78+
@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_iface_003');
79+
--EXPECT--
8080
*** Testing session_set_save_handler() function: id interface ***
81-
string(%d) "my_sid"
81+
string(34) "session_set_save_handler_iface_003"
8282
string(4) "user"
8383
array(1) {
8484
["foo"]=>

ext/session/tests/session_set_save_handler_sid_001.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MySession2 {
2828
}
2929

3030
public function read($id) {
31-
return @file_get_contents($this->path . $id);
31+
return (string)@file_get_contents($this->path . $id);
3232
}
3333

3434
public function write($id, $data) {
@@ -50,7 +50,7 @@ class MySession2 {
5050
}
5151

5252
public function create_sid() {
53-
return 'my_sid';
53+
return pathinfo(__FILE__)['filename'];
5454
}
5555
}
5656

@@ -68,12 +68,12 @@ session_unset();
6868

6969
session_start();
7070
var_dump($_SESSION);
71-
72-
session_write_close();
73-
session_unset();
74-
--EXPECTF--
71+
--CLEAN--
72+
<?php
73+
@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_sid_001');
74+
--EXPECT--
7575
*** Testing session_set_save_handler() function: create_sid ***
76-
string(%d) "my_sid"
76+
string(32) "session_set_save_handler_sid_001"
7777
string(4) "user"
7878
array(1) {
7979
["foo"]=>

0 commit comments

Comments
 (0)