diff options
Diffstat (limited to 'ext/session/tests')
52 files changed, 831 insertions, 9 deletions
diff --git a/ext/session/tests/003.phpt b/ext/session/tests/003.phpt index 03c3b95766..8725f06a69 100644 --- a/ext/session/tests/003.phpt +++ b/ext/session/tests/003.phpt @@ -4,6 +4,7 @@ session object deserialization <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/004.phpt b/ext/session/tests/004.phpt index aeb2c8b363..4547c65574 100644 --- a/ext/session/tests/004.phpt +++ b/ext/session/tests/004.phpt @@ -4,6 +4,7 @@ session_set_save_handler test <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.name=PHPSESSID session.serialize_handler=php diff --git a/ext/session/tests/005.phpt b/ext/session/tests/005.phpt index a970e6b71d..796d9c377e 100644 --- a/ext/session/tests/005.phpt +++ b/ext/session/tests/005.phpt @@ -4,6 +4,7 @@ custom save handler, multiple session_start()s, complex data structure test. <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.name=PHPSESSID session.serialize_handler=php diff --git a/ext/session/tests/006.phpt b/ext/session/tests/006.phpt index 03fca10381..dba6894c7e 100644 --- a/ext/session/tests/006.phpt +++ b/ext/session/tests/006.phpt @@ -4,6 +4,7 @@ correct instantiation of references between variables in sessions <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/009.phpt b/ext/session/tests/009.phpt index d73bc238c9..6d8d11c331 100644 --- a/ext/session/tests/009.phpt +++ b/ext/session/tests/009.phpt @@ -4,6 +4,7 @@ unset($_SESSION["name"]); test <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/012.phpt b/ext/session/tests/012.phpt index 8708011273..c555d2ca1e 100644 --- a/ext/session/tests/012.phpt +++ b/ext/session/tests/012.phpt @@ -4,6 +4,7 @@ registering $_SESSION should not segfault <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/013.phpt b/ext/session/tests/013.phpt index 8d0f284b17..32909eb58c 100644 --- a/ext/session/tests/013.phpt +++ b/ext/session/tests/013.phpt @@ -4,6 +4,7 @@ redefining SID should not cause warnings <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/014.phpt b/ext/session/tests/014.phpt index 73bc28ea66..cbf22b142d 100644 --- a/ext/session/tests/014.phpt +++ b/ext/session/tests/014.phpt @@ -5,6 +5,7 @@ a script should not be able to modify session.use_trans_sid --INI-- session.use_trans_sid=0 session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.name=PHPSESSID session.serialize_handler=php diff --git a/ext/session/tests/015.phpt b/ext/session/tests/015.phpt index 7d7b737340..527b86bc1d 100644 --- a/ext/session/tests/015.phpt +++ b/ext/session/tests/015.phpt @@ -6,6 +6,7 @@ use_trans_sid should not affect SID session.use_trans_sid=1 session.use_cookies=0 session.use_only_cookies=0 +session.use_strict_mode=0 session.cache_limiter= arg_separator.output=& session.name=PHPSESSID diff --git a/ext/session/tests/016.phpt b/ext/session/tests/016.phpt index 83703294a3..0e368e2f82 100644 --- a/ext/session/tests/016.phpt +++ b/ext/session/tests/016.phpt @@ -16,10 +16,11 @@ session.serialize_handler=php <?php error_reporting(E_ALL); -@session_start(); +session_start(); $HTTP_SESSION_VARS["test"] = 1; -@session_write_close(); +session_write_close(); print "I live\n"; ?> ---EXPECT-- +--EXPECTF-- +Warning: session_write_close(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (123;:/really\completely:::/invalid;;,23123;213) in %s on line %d I live diff --git a/ext/session/tests/018.phpt b/ext/session/tests/018.phpt index def1f419ce..5ec132b34f 100644 --- a/ext/session/tests/018.phpt +++ b/ext/session/tests/018.phpt @@ -5,6 +5,7 @@ rewriter correctly handles attribute names which contain dashes --INI-- session.use_cookies=0 session.use_only_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.use_trans_sid=1 session.name=PHPSESSID diff --git a/ext/session/tests/019.phpt b/ext/session/tests/019.phpt index 3ee8ccd420..0f06add5a1 100644 --- a/ext/session/tests/019.phpt +++ b/ext/session/tests/019.phpt @@ -4,6 +4,7 @@ serializing references test case using globals <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/020.phpt b/ext/session/tests/020.phpt index 0141129820..267e52191c 100644 --- a/ext/session/tests/020.phpt +++ b/ext/session/tests/020.phpt @@ -5,6 +5,7 @@ rewriter uses arg_separator.output for modifying URLs --INI-- session.use_cookies=0 session.use_only_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.use_trans_sid=1 arg_separator.output="&" diff --git a/ext/session/tests/021.phpt b/ext/session/tests/021.phpt index 1ad3c5d5f7..e199972899 100644 --- a/ext/session/tests/021.phpt +++ b/ext/session/tests/021.phpt @@ -5,6 +5,7 @@ rewriter handles form and fieldset tags correctly --INI-- session.use_cookies=0 session.use_only_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.use_trans_sid=1 url_rewriter.tags="a=href,area=href,frame=src,input=src,form=,fieldset=" diff --git a/ext/session/tests/023.phpt b/ext/session/tests/023.phpt index 42b1e5b1be..592b4a8c3b 100644 --- a/ext/session/tests/023.phpt +++ b/ext/session/tests/023.phpt @@ -4,6 +4,7 @@ session object deserialization <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/024.phpt b/ext/session/tests/024.phpt index 2ad26067a5..2b273e2b2e 100644 --- a/ext/session/tests/024.phpt +++ b/ext/session/tests/024.phpt @@ -4,6 +4,7 @@ session_set_save_handler test <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.name=PHPSESSID session.serialize_handler=php diff --git a/ext/session/tests/025.phpt b/ext/session/tests/025.phpt index 4fd095f817..a9ad8fb649 100644 --- a/ext/session/tests/025.phpt +++ b/ext/session/tests/025.phpt @@ -4,6 +4,7 @@ custom save handler, multiple session_start()s, complex data structure test. <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.name=PHPSESSID session.serialize_handler=php diff --git a/ext/session/tests/026.phpt b/ext/session/tests/026.phpt index 06c135d046..44f0ae0ec0 100644 --- a/ext/session/tests/026.phpt +++ b/ext/session/tests/026.phpt @@ -4,6 +4,7 @@ correct instantiation of references between variables in sessions <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/027.phpt b/ext/session/tests/027.phpt index 600a992f7f..63828522fb 100644 --- a/ext/session/tests/027.phpt +++ b/ext/session/tests/027.phpt @@ -4,6 +4,7 @@ unset($_SESSION["name"]); should work <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/030.phpt b/ext/session/tests/030.phpt index 8d0f284b17..32909eb58c 100644 --- a/ext/session/tests/030.phpt +++ b/ext/session/tests/030.phpt @@ -4,6 +4,7 @@ redefining SID should not cause warnings <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/bug41600.phpt b/ext/session/tests/bug41600.phpt index 690347ac8d..79d5e12841 100644 --- a/ext/session/tests/bug41600.phpt +++ b/ext/session/tests/bug41600.phpt @@ -5,6 +5,7 @@ Bug #41600 (url rewriter tags doesn't work with namespaced tags) --INI-- session.use_cookies=0 session.use_only_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.use_trans_sid=1 arg_separator.output="&" diff --git a/ext/session/tests/bug65475.phpt b/ext/session/tests/bug65475.phpt new file mode 100644 index 0000000000..7dc5463879 --- /dev/null +++ b/ext/session/tests/bug65475.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #65475: Session ID is not initialized when session.usr_strict_mode=1 +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +ob_start(); + +echo "Testing file module".PHP_EOL; +session_start(); +$_SESSION['foo'] = 1234; +$_SESSION['cnt'] = 1; +$session_id = session_id(); +session_write_close(); + +session_start(); +var_dump($session_id === session_id()); +$_SESSION['cnt']++; +session_write_close(); + +session_start(); +var_dump($session_id === session_id()); +var_dump($_SESSION['cnt']); // Should be int(2) +session_write_close(); + +--EXPECTF-- +Testing file module +bool(true) +bool(true) +int(2) + diff --git a/ext/session/tests/bug66481-win32.phpt b/ext/session/tests/bug66481-win32.phpt index 4a3b07735b..cf06cb6b95 100644 --- a/ext/session/tests/bug66481-win32.phpt +++ b/ext/session/tests/bug66481-win32.phpt @@ -14,3 +14,4 @@ var_dump(session_name("bar")); Warning: PHP Startup: session.name cannot be a numeric or empty '' in Unknown on line 0 string(9) "PHPSESSID" string(3) "foo" +PHP Warning: PHP Startup: session.name cannot be a numeric or empty '' in Unknown on line 0 diff --git a/ext/session/tests/bug67972.phpt b/ext/session/tests/bug67972.phpt new file mode 100644 index 0000000000..63ed3a95b8 --- /dev/null +++ b/ext/session/tests/bug67972.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #67972: SessionHandler Invalid memory read create_sid() +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +(new SessionHandler)->create_sid(); +--EXPECTF-- +Fatal error: SessionHandler::create_sid(): Cannot call default session handler in %s on line %d diff --git a/ext/session/tests/rfc1867.phpt b/ext/session/tests/rfc1867.phpt index dc44e8b443..6b14bcb4ef 100644 --- a/ext/session/tests/rfc1867.phpt +++ b/ext/session/tests/rfc1867.phpt @@ -7,6 +7,7 @@ comment=debug builds show some additional E_NOTICE errors upload_max_filesize=1024 session.save_path= session.name=PHPSESSID +session.use_strict_mode=0 session.use_cookies=1 session.use_only_cookies=0 session.upload_progress.enabled=1 diff --git a/ext/session/tests/rfc1867_cleanup.phpt b/ext/session/tests/rfc1867_cleanup.phpt index f70b395d22..f84385bada 100644 --- a/ext/session/tests/rfc1867_cleanup.phpt +++ b/ext/session/tests/rfc1867_cleanup.phpt @@ -7,6 +7,7 @@ comment=debug builds show some additional E_NOTICE errors upload_max_filesize=1024 session.save_path= session.name=PHPSESSID +session.use_strict_mode=0 session.use_cookies=1 session.use_only_cookies=0 session.upload_progress.enabled=1 diff --git a/ext/session/tests/rfc1867_disabled.phpt b/ext/session/tests/rfc1867_disabled.phpt index 4490055791..550ee3a7a2 100644 --- a/ext/session/tests/rfc1867_disabled.phpt +++ b/ext/session/tests/rfc1867_disabled.phpt @@ -7,6 +7,7 @@ comment=debug builds show some additional E_NOTICE errors upload_max_filesize=1024 session.save_path= session.name=PHPSESSID +session.use_strict_mode=0 session.use_cookies=1 session.use_only_cookies=0 session.upload_progress.enabled=0 diff --git a/ext/session/tests/rfc1867_disabled_2.phpt b/ext/session/tests/rfc1867_disabled_2.phpt index e878f4619f..83e97eeed1 100644 --- a/ext/session/tests/rfc1867_disabled_2.phpt +++ b/ext/session/tests/rfc1867_disabled_2.phpt @@ -7,6 +7,7 @@ comment=debug builds show some additional E_NOTICE errors upload_max_filesize=1024 session.save_path= session.name=PHPSESSID +session.use_strict_mode=0 session.use_cookies=1 session.use_only_cookies=0 session.upload_progress.enabled=1 diff --git a/ext/session/tests/rfc1867_inter.phpt b/ext/session/tests/rfc1867_inter.phpt index 768637105c..4d9b262230 100644 --- a/ext/session/tests/rfc1867_inter.phpt +++ b/ext/session/tests/rfc1867_inter.phpt @@ -7,6 +7,7 @@ comment=debug builds show some additional E_NOTICE errors upload_max_filesize=1024 session.save_path= session.name=PHPSESSID +session.use_strict_mode=0 session.use_cookies=1 session.use_only_cookies=0 session.upload_progress.enabled=1 diff --git a/ext/session/tests/rfc1867_no_name.phpt b/ext/session/tests/rfc1867_no_name.phpt index c1dda8156e..d68a61d929 100644 --- a/ext/session/tests/rfc1867_no_name.phpt +++ b/ext/session/tests/rfc1867_no_name.phpt @@ -7,6 +7,7 @@ comment=debug builds show some additional E_NOTICE errors upload_max_filesize=1024 session.save_path= session.name=PHPSESSID +session.use_strict_mode=0 session.use_cookies=1 session.use_only_cookies=0 session.upload_progress.enabled=1 diff --git a/ext/session/tests/rfc1867_sid_cookie.phpt b/ext/session/tests/rfc1867_sid_cookie.phpt index 735a5ac201..2864799335 100644 --- a/ext/session/tests/rfc1867_sid_cookie.phpt +++ b/ext/session/tests/rfc1867_sid_cookie.phpt @@ -7,6 +7,7 @@ comment=debug builds show some additional E_NOTICE errors upload_max_filesize=1024 session.save_path= session.name=PHPSESSID +session.use_strict_mode=0 session.use_cookies=1 session.use_only_cookies=0 session.upload_progress.enabled=1 diff --git a/ext/session/tests/rfc1867_sid_get.phpt b/ext/session/tests/rfc1867_sid_get.phpt index cc5a793e7b..e3a48a1c13 100644 --- a/ext/session/tests/rfc1867_sid_get.phpt +++ b/ext/session/tests/rfc1867_sid_get.phpt @@ -7,6 +7,7 @@ comment=debug builds show some additional E_NOTICE errors upload_max_filesize=1024 session.save_path= session.name=PHPSESSID +session.use_strict_mode=0 session.use_cookies=1 session.use_only_cookies=0 session.upload_progress.enabled=1 diff --git a/ext/session/tests/rfc1867_sid_get_2.phpt b/ext/session/tests/rfc1867_sid_get_2.phpt index 1d22e5930b..e21ca4ca2b 100644 --- a/ext/session/tests/rfc1867_sid_get_2.phpt +++ b/ext/session/tests/rfc1867_sid_get_2.phpt @@ -7,6 +7,7 @@ comment=debug builds show some additional E_NOTICE errors upload_max_filesize=1024 session.save_path= session.name=PHPSESSID +session.use_strict_mode=0 session.use_cookies=0 session.use_only_cookies=0 session.upload_progress.enabled=1 diff --git a/ext/session/tests/rfc1867_sid_invalid.phpt b/ext/session/tests/rfc1867_sid_invalid.phpt index b28a2e341b..4dd8f1f979 100644 --- a/ext/session/tests/rfc1867_sid_invalid.phpt +++ b/ext/session/tests/rfc1867_sid_invalid.phpt @@ -46,6 +46,16 @@ session_destroy(); ?> --EXPECTF-- Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 + +Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 + +Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0 + +Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 + +Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 + +Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0 string(%d) "%s" bool(true) array(2) { diff --git a/ext/session/tests/rfc1867_sid_only_cookie.phpt b/ext/session/tests/rfc1867_sid_only_cookie.phpt index 9a0105668f..41f6761fb9 100644 --- a/ext/session/tests/rfc1867_sid_only_cookie.phpt +++ b/ext/session/tests/rfc1867_sid_only_cookie.phpt @@ -7,6 +7,7 @@ comment=debug builds show some additional E_NOTICE errors upload_max_filesize=1024 session.save_path= session.name=PHPSESSID +session.use_strict_mode=0 session.use_cookies=1 session.use_only_cookies=1 session.upload_progress.enabled=1 diff --git a/ext/session/tests/rfc1867_sid_post.phpt b/ext/session/tests/rfc1867_sid_post.phpt index 7c1eb2de5d..107957f8db 100644 --- a/ext/session/tests/rfc1867_sid_post.phpt +++ b/ext/session/tests/rfc1867_sid_post.phpt @@ -7,6 +7,7 @@ comment=debug builds show some additional E_NOTICE errors upload_max_filesize=1024 session.save_path= session.name=PHPSESSID +session.use_strict_mode=0 session.use_cookies=1 session.use_only_cookies=0 session.upload_progress.enabled=1 diff --git a/ext/session/tests/session_commit_variation4.phpt b/ext/session/tests/session_commit_variation4.phpt index 57f42539d2..69854a6cf9 100644 --- a/ext/session/tests/session_commit_variation4.phpt +++ b/ext/session/tests/session_commit_variation4.phpt @@ -2,6 +2,8 @@ Test session_commit() function : variation --SKIPIF-- <?php include('skipif.inc'); ?> +--INI-- +session.use_strict_mode=0 --FILE-- <?php diff --git a/ext/session/tests/session_decode_basic_serialize.phpt b/ext/session/tests/session_decode_basic_serialize.phpt new file mode 100644 index 0000000000..dd88438e15 --- /dev/null +++ b/ext/session/tests/session_decode_basic_serialize.phpt @@ -0,0 +1,274 @@ +--TEST-- +Test session_decode() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : basic functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +ini_set('session.serialize_handler', 'php_serialize'); +var_dump(session_start()); +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + $_SESSION["data"] = $input; + $encoded = session_encode(); + var_dump(session_decode($encoded)); + var_dump($_SESSION); + $iterator++; +}; + +var_dump(session_destroy()); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : basic functionality *** +bool(true) + +-- Iteration 1 -- +bool(true) +array(1) { + ["data"]=> + int(0) +} + +-- Iteration 2 -- +bool(true) +array(1) { + ["data"]=> + int(1) +} + +-- Iteration 3 -- +bool(true) +array(1) { + ["data"]=> + int(12345) +} + +-- Iteration 4 -- +bool(true) +array(1) { + ["data"]=> + int(-2345) +} + +-- Iteration 5 -- +bool(true) +array(1) { + ["data"]=> + float(10.5) +} + +-- Iteration 6 -- +bool(true) +array(1) { + ["data"]=> + float(-10.5) +} + +-- Iteration 7 -- +bool(true) +array(1) { + ["data"]=> + float(123456789000) +} + +-- Iteration 8 -- +bool(true) +array(1) { + ["data"]=> + float(1.23456789E-9) +} + +-- Iteration 9 -- +bool(true) +array(1) { + ["data"]=> + float(0.5) +} + +-- Iteration 10 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 11 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 12 -- +bool(true) +array(1) { + ["data"]=> + bool(true) +} + +-- Iteration 13 -- +bool(true) +array(1) { + ["data"]=> + bool(false) +} + +-- Iteration 14 -- +bool(true) +array(1) { + ["data"]=> + bool(true) +} + +-- Iteration 15 -- +bool(true) +array(1) { + ["data"]=> + bool(false) +} + +-- Iteration 16 -- +bool(true) +array(1) { + ["data"]=> + string(0) "" +} + +-- Iteration 17 -- +bool(true) +array(1) { + ["data"]=> + string(0) "" +} + +-- Iteration 18 -- +bool(true) +array(1) { + ["data"]=> + string(7) "Nothing" +} + +-- Iteration 19 -- +bool(true) +array(1) { + ["data"]=> + string(7) "Nothing" +} + +-- Iteration 20 -- +bool(true) +array(1) { + ["data"]=> + string(12) "Hello World!" +} + +-- Iteration 21 -- +bool(true) +array(1) { + ["data"]=> + object(classA)#2 (0) { + } +} + +-- Iteration 22 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 23 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 24 -- +bool(true) +array(1) { + ["data"]=> + int(0) +} +bool(true) +Done + diff --git a/ext/session/tests/session_encode_serialize.phpt b/ext/session/tests/session_encode_serialize.phpt new file mode 100644 index 0000000000..41c79c3e51 --- /dev/null +++ b/ext/session/tests/session_encode_serialize.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test session_encode() function : Numeric key raise error. bug65359 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +ob_start(); + +ini_set('session.serialize_handler', 'php_serialize'); +var_dump(session_start()); +$_SESSION[-3] = 'foo'; +$_SESSION[3] = 'bar'; +$_SESSION['var'] = 123; +var_dump(session_encode()); +session_write_close(); + +// Should finish without errors +echo 'Done'.PHP_EOL; +?> +--EXPECTF-- +bool(true) +string(51) "a:3:{i:-3;s:3:"foo";i:3;s:3:"bar";s:3:"var";i:123;}" +Done + diff --git a/ext/session/tests/session_id_basic.phpt b/ext/session/tests/session_id_basic.phpt index 5cb13c25ea..852d2f9578 100644 --- a/ext/session/tests/session_id_basic.phpt +++ b/ext/session/tests/session_id_basic.phpt @@ -20,6 +20,8 @@ var_dump(session_id("test")); var_dump(session_id()); var_dump(session_id("1234567890")); var_dump(session_id()); +// Turn off strice mode, since it does not allow uninitialized session ID +ini_set('session.use_strict_mode',false); var_dump(session_start()); var_dump(session_id()); var_dump(session_destroy()); diff --git a/ext/session/tests/session_name_error.phpt b/ext/session/tests/session_name_error.phpt index 1b99d4ea35..9f0101d98b 100644 --- a/ext/session/tests/session_name_error.phpt +++ b/ext/session/tests/session_name_error.phpt @@ -231,6 +231,6 @@ string(12) "Hello World!" -- Iteration 24 -- Warning: session_name() expects parameter 1 to be string, resource given in %s on line %d -resource(5) of type (stream) +resource(%d) of type (stream) NULL Done
\ No newline at end of file diff --git a/ext/session/tests/session_save_path_variation2.phpt b/ext/session/tests/session_save_path_variation2.phpt index 6b08480312..dff070100c 100644 --- a/ext/session/tests/session_save_path_variation2.phpt +++ b/ext/session/tests/session_save_path_variation2.phpt @@ -32,7 +32,7 @@ ob_end_flush(); *** Testing session_save_path() : variation *** string(5) "/blah" -Warning: session_start(): open(%s, O_RDWR) failed: No such file or directory (2) in %s on line %d +Warning: session_start(): open(/blah/%s, O_RDWR) failed: No such file or directory (2) in %s on line %d bool(true) string(5) "/blah" bool(true) diff --git a/ext/session/tests/session_save_path_variation5.phpt b/ext/session/tests/session_save_path_variation5.phpt index 5407b5e15a..c015dcc95c 100644 --- a/ext/session/tests/session_save_path_variation5.phpt +++ b/ext/session/tests/session_save_path_variation5.phpt @@ -9,7 +9,6 @@ if(substr(PHP_OS, 0, 3) == "WIN") session.save_handler=files session.save_path= session.name=PHPSESSID -open_basedir=. --FILE-- <?php @@ -25,7 +24,7 @@ $directory = dirname(__FILE__); $sessions = ($directory."/sessions"); chdir($directory); - +ini_set('open_basedir', '.'); // Delete the existing directory if (file_exists($sessions) === TRUE) { @rmdir($sessions); diff --git a/ext/session/tests/session_set_save_handler_class_016.phpt b/ext/session/tests/session_set_save_handler_class_016.phpt new file mode 100644 index 0000000000..2de03c0682 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_016.phpt @@ -0,0 +1,90 @@ +--TEST-- +Test session_set_save_handler() function: class with create_sid +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandlerInterface $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() function: class with create_sid ***\n"; + +class MySession2 extends SessionHandler { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return parent::create_sid(); + } +} + +$handler = new MySession2; +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() function: class with create_sid *** +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_class_017.phpt b/ext/session/tests/session_set_save_handler_class_017.phpt new file mode 100644 index 0000000000..756dc55d03 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_017.phpt @@ -0,0 +1,90 @@ +--TEST-- +Test session_set_save_handler() function: class with create_sid +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandlerInterface $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() function: class with create_sid ***\n"; + +class MySession2 extends SessionHandler { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return 'my_sid'; + } +} + +$handler = new MySession2; +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() function: class with create_sid *** +string(%d) "my_sid" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_error2.phpt b/ext/session/tests/session_set_save_handler_error2.phpt index 03ba3b04d0..1f2a8b9e6a 100644 --- a/ext/session/tests/session_set_save_handler_error2.phpt +++ b/ext/session/tests/session_set_save_handler_error2.phpt @@ -2,6 +2,8 @@ Test session_set_save_handler() function : error functionality --SKIPIF-- <?php include('skipif.inc'); ?> +--INI-- +error_reporting=0 --FILE-- <?php diff --git a/ext/session/tests/session_set_save_handler_error3.phpt b/ext/session/tests/session_set_save_handler_error3.phpt index 446ef7b75b..cb07b0d8de 100644 --- a/ext/session/tests/session_set_save_handler_error3.phpt +++ b/ext/session/tests/session_set_save_handler_error3.phpt @@ -40,4 +40,3 @@ Stack trace: #1 %s(%d): session_start() #2 {main} thrown in %s on line %d - diff --git a/ext/session/tests/session_set_save_handler_error4.phpt b/ext/session/tests/session_set_save_handler_error4.phpt index 4debde5b0f..d286f07d99 100644 --- a/ext/session/tests/session_set_save_handler_error4.phpt +++ b/ext/session/tests/session_set_save_handler_error4.phpt @@ -39,4 +39,3 @@ Warning: session_set_save_handler(): Argument 4 is not a valid callback in %s on Warning: session_set_save_handler(): Argument 5 is not a valid callback in %s on line %d Warning: session_set_save_handler(): Argument 6 is not a valid callback in %s on line %d - diff --git a/ext/session/tests/session_set_save_handler_iface_003.phpt b/ext/session/tests/session_set_save_handler_iface_003.phpt new file mode 100644 index 0000000000..bd757dce63 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_iface_003.phpt @@ -0,0 +1,90 @@ +--TEST-- +Test session_set_save_handler() function: id interface +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandlerInterface $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() function: id interface ***\n"; + +class MySession2 implements SessionHandlerInterface, SessionIdInterface { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return 'my_sid'; + } +} + +$handler = new MySession2; +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() function: id interface *** +string(%d) "my_sid" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_sid_001.phpt b/ext/session/tests/session_set_save_handler_sid_001.phpt new file mode 100644 index 0000000000..0dc4fc11cf --- /dev/null +++ b/ext/session/tests/session_set_save_handler_sid_001.phpt @@ -0,0 +1,85 @@ +--TEST-- +Test session_set_save_handler() function: create_sid +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +echo "*** Testing session_set_save_handler() function: create_sid ***\n"; + +class MySession2 { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return 'my_sid'; + } +} + +$handler = new MySession2; +session_set_save_handler(array($handler, 'open'), array($handler, 'close'), + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'), array($handler, 'create_sid')); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() function: create_sid *** +string(%d) "my_sid" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_sid_002.phpt b/ext/session/tests/session_set_save_handler_sid_002.phpt new file mode 100644 index 0000000000..f9a72aebca --- /dev/null +++ b/ext/session/tests/session_set_save_handler_sid_002.phpt @@ -0,0 +1,77 @@ +--TEST-- +Test session_set_save_handler() function: create_sid +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +echo "*** Testing session_set_save_handler() function: create_sid ***\n"; + +class MySession2 { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return null; + } +} + +$handler = new MySession2; +session_set_save_handler(array($handler, 'open'), array($handler, 'close'), + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'), array($handler, 'create_sid')); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() function: create_sid *** + +Fatal error: session_start(): Session id must be a string in %s on line %d diff --git a/ext/session/tests/session_write_close_variation4.phpt b/ext/session/tests/session_write_close_variation4.phpt index 249c1555c0..9076dcf4a4 100644 --- a/ext/session/tests/session_write_close_variation4.phpt +++ b/ext/session/tests/session_write_close_variation4.phpt @@ -2,6 +2,8 @@ Test session_write_close() function : variation --SKIPIF-- <?php include('skipif.inc'); ?> +--INI-- +session.use_strict_mode=0 --FILE-- <?php |