mirror of
https://github.com/php/php-src.git
synced 2024-11-27 20:03:40 +08:00
Make some session tests more robust
This commit is contained in:
parent
d26eb10f08
commit
7e8f11531e
@ -55,7 +55,7 @@ class MySession2 extends SessionHandler {
|
||||
}
|
||||
|
||||
public function create_sid() {
|
||||
return 'my_sid';
|
||||
return pathinfo(__FILE__)['filename'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,12 +72,12 @@ session_unset();
|
||||
|
||||
session_start();
|
||||
var_dump($_SESSION);
|
||||
|
||||
session_write_close();
|
||||
session_unset();
|
||||
--EXPECTF--
|
||||
--CLEAN--
|
||||
<?php
|
||||
@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_class_017');
|
||||
--EXPECT--
|
||||
*** Testing session_set_save_handler() function: class with create_sid ***
|
||||
string(%d) "my_sid"
|
||||
string(34) "session_set_save_handler_class_017"
|
||||
string(4) "user"
|
||||
array(1) {
|
||||
["foo"]=>
|
||||
|
@ -34,7 +34,7 @@ class MySession2 extends SessionHandler {
|
||||
}
|
||||
|
||||
public function read($id) {
|
||||
return @file_get_contents($this->path . $id);
|
||||
return (string)@file_get_contents($this->path . $id);
|
||||
}
|
||||
|
||||
public function write($id, $data) {
|
||||
@ -55,11 +55,11 @@ class MySession2 extends SessionHandler {
|
||||
}
|
||||
|
||||
public function create_sid() {
|
||||
return 'my_sid';
|
||||
return pathinfo(__FILE__)['filename'];
|
||||
}
|
||||
|
||||
public function validate_sid($id) {
|
||||
return 'my_sid'===$id;
|
||||
return pathinfo(__FILE__)['filename']===$id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,12 +76,12 @@ session_unset();
|
||||
|
||||
session_start();
|
||||
var_dump($_SESSION);
|
||||
|
||||
session_write_close();
|
||||
session_unset();
|
||||
--EXPECTF--
|
||||
--CLEAN--
|
||||
<?php
|
||||
@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_class_018');
|
||||
--EXPECT--
|
||||
*** Testing session_set_save_handler() function: class with validate_sid ***
|
||||
string(%d) "my_sid"
|
||||
string(34) "session_set_save_handler_class_018"
|
||||
string(4) "user"
|
||||
array(1) {
|
||||
["foo"]=>
|
||||
|
@ -34,7 +34,7 @@ class MySession2 implements SessionHandlerInterface, SessionIdInterface {
|
||||
}
|
||||
|
||||
public function read($id) {
|
||||
return @file_get_contents($this->path . $id);
|
||||
return (string)@file_get_contents($this->path . $id);
|
||||
}
|
||||
|
||||
public function write($id, $data) {
|
||||
@ -56,7 +56,7 @@ class MySession2 implements SessionHandlerInterface, SessionIdInterface {
|
||||
}
|
||||
|
||||
public function create_sid() {
|
||||
return 'my_sid';
|
||||
return pathinfo(__FILE__)['filename'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,12 +73,12 @@ session_unset();
|
||||
|
||||
session_start();
|
||||
var_dump($_SESSION);
|
||||
|
||||
session_write_close();
|
||||
session_unset();
|
||||
--EXPECTF--
|
||||
--CLEAN--
|
||||
<?php
|
||||
@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_iface_003');
|
||||
--EXPECT--
|
||||
*** Testing session_set_save_handler() function: id interface ***
|
||||
string(%d) "my_sid"
|
||||
string(34) "session_set_save_handler_iface_003"
|
||||
string(4) "user"
|
||||
array(1) {
|
||||
["foo"]=>
|
||||
|
@ -28,7 +28,7 @@ class MySession2 {
|
||||
}
|
||||
|
||||
public function read($id) {
|
||||
return @file_get_contents($this->path . $id);
|
||||
return (string)@file_get_contents($this->path . $id);
|
||||
}
|
||||
|
||||
public function write($id, $data) {
|
||||
@ -50,7 +50,7 @@ class MySession2 {
|
||||
}
|
||||
|
||||
public function create_sid() {
|
||||
return 'my_sid';
|
||||
return pathinfo(__FILE__)['filename'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,12 +68,12 @@ session_unset();
|
||||
|
||||
session_start();
|
||||
var_dump($_SESSION);
|
||||
|
||||
session_write_close();
|
||||
session_unset();
|
||||
--EXPECTF--
|
||||
--CLEAN--
|
||||
<?php
|
||||
@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_sid_001');
|
||||
--EXPECT--
|
||||
*** Testing session_set_save_handler() function: create_sid ***
|
||||
string(%d) "my_sid"
|
||||
string(32) "session_set_save_handler_sid_001"
|
||||
string(4) "user"
|
||||
array(1) {
|
||||
["foo"]=>
|
||||
|
Loading…
Reference in New Issue
Block a user