diff options
Diffstat (limited to 'ext/session/tests')
68 files changed, 2654 insertions, 1968 deletions
diff --git a/ext/session/tests/001.phpt b/ext/session/tests/001.phpt index 543eba713..eb04dc114 100644 --- a/ext/session/tests/001.phpt +++ b/ext/session/tests/001.phpt @@ -5,7 +5,6 @@ session object serialization --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.serialize_handler=php session.save_handler=files --FILE-- @@ -24,17 +23,14 @@ $baz->method(); $arr[3] = new foo; $arr[3]->method(); -session_register("baz"); -session_register("arr"); +session_start(); + +$_SESSION["baz"] = $baz; +$_SESSION["arr"] = $arr; print session_encode()."\n"; session_destroy(); ---EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 - -Deprecated: Function session_register() is deprecated in %s on line %d - -Deprecated: Function session_register() is deprecated in %s on line %d +--EXPECT-- baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}} diff --git a/ext/session/tests/003.phpt b/ext/session/tests/003.phpt index 677a958e8..03c3b9576 100644 --- a/ext/session/tests/003.phpt +++ b/ext/session/tests/003.phpt @@ -5,7 +5,6 @@ session object deserialization --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.serialize_handler=php session.save_handler=files --FILE-- @@ -21,14 +20,13 @@ session_id("abtest"); session_start(); session_decode('baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'); -$baz->method(); -$arr[3]->method(); +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); -var_dump($baz); -var_dump($arr); +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); session_destroy(); --EXPECT-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 object(foo)#1 (2) { ["bar"]=> string(2) "ok" diff --git a/ext/session/tests/004.phpt b/ext/session/tests/004.phpt index 3e6de2523..aeb2c8b36 100644 --- a/ext/session/tests/004.phpt +++ b/ext/session/tests/004.phpt @@ -5,7 +5,6 @@ session_set_save_handler test --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.name=PHPSESSID session.serialize_handler=php --FILE-- @@ -56,24 +55,23 @@ session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, session_id("abtest"); session_start(); -$baz->method(); -$arr[3]->method(); +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); -var_dump($baz); -var_dump($arr); +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); session_write_close(); session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); session_start(); -var_dump($baz); -var_dump($arr); +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); session_destroy(); ?> --EXPECT-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 OPEN: PHPSESSID READ: abtest object(foo)#2 (2) { @@ -94,7 +92,7 @@ array(1) { WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}} OPEN: PHPSESSID READ: abtest -object(foo)#4 (2) { +object(foo)#3 (2) { ["bar"]=> string(2) "ok" ["yes"]=> diff --git a/ext/session/tests/005.phpt b/ext/session/tests/005.phpt index 4e6682c86..a970e6b71 100644 --- a/ext/session/tests/005.phpt +++ b/ext/session/tests/005.phpt @@ -5,7 +5,6 @@ custom save handler, multiple session_start()s, complex data structure test. --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.name=PHPSESSID session.serialize_handler=php --FILE-- @@ -58,37 +57,41 @@ session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, session_id("abtest"); session_start(); -$baz->method(); -$arr[3]->method(); +session_decode($hnd->data); -var_dump($baz); -var_dump($arr); +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); + +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); session_write_close(); session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); session_start(); -$baz->method(); -$arr[3]->method(); +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); -$c = 123; -session_register("c"); -var_dump($baz); var_dump($arr); var_dump($c); +$_SESSION["c"] = 123; +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); +var_dump($_SESSION["c"]); session_write_close(); session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); session_start(); -var_dump($baz); var_dump($arr); var_dump($c); +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); +var_dump($_SESSION["c"]); session_destroy(); ?> --EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 OPEN: PHPSESSID READ: abtest -object(foo)#2 (2) { +object(foo)#4 (2) { ["bar"]=> string(2) "ok" ["yes"]=> @@ -96,7 +99,7 @@ object(foo)#2 (2) { } array(1) { [3]=> - object(foo)#3 (2) { + object(foo)#2 (2) { ["bar"]=> string(2) "ok" ["yes"]=> @@ -107,9 +110,7 @@ WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O CLOSE OPEN: PHPSESSID READ: abtest - -Deprecated: Function session_register() is deprecated in %s on line %d -object(foo)#4 (2) { +object(foo)#2 (2) { ["bar"]=> string(2) "ok" ["yes"]=> @@ -117,7 +118,7 @@ object(foo)#4 (2) { } array(1) { [3]=> - object(foo)#2 (2) { + object(foo)#4 (2) { ["bar"]=> string(2) "ok" ["yes"]=> @@ -129,7 +130,7 @@ WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:3;}arr|a:1:{i:3;O CLOSE OPEN: PHPSESSID READ: abtest -object(foo)#3 (2) { +object(foo)#4 (2) { ["bar"]=> string(2) "ok" ["yes"]=> @@ -137,7 +138,7 @@ object(foo)#3 (2) { } array(1) { [3]=> - object(foo)#4 (2) { + object(foo)#2 (2) { ["bar"]=> string(2) "ok" ["yes"]=> diff --git a/ext/session/tests/006.phpt b/ext/session/tests/006.phpt index 9ab28f65d..03fca1038 100644 --- a/ext/session/tests/006.phpt +++ b/ext/session/tests/006.phpt @@ -5,7 +5,6 @@ correct instantiation of references between variables in sessions --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.serialize_handler=php session.save_handler=files --FILE-- @@ -32,12 +31,11 @@ $b = new b($a); echo "original values:\n"; var_dump($a,$b); -session_register("a"); -session_register("b"); +$_SESSION["a"] = $a; +$_SESSION["b"] = $b; session_write_close(); -session_unregister("a"); -session_unregister("b"); +unset($_SESSION["a"], $_SESSION["b"]); session_start(); @@ -45,7 +43,6 @@ echo "values after session:\n"; var_dump($a,$b); ?> --EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 original values: object(a)#%d (1) { ["test"]=> @@ -58,14 +55,6 @@ object(b)#%d (1) { string(5) "hallo" } } - -Deprecated: Function session_register() is deprecated in %s on line %d - -Deprecated: Function session_register() is deprecated in %s on line %d - -Deprecated: Function session_unregister() is deprecated in %s on line %d - -Deprecated: Function session_unregister() is deprecated in %s on line %d values after session: object(a)#%d (1) { ["test"]=> @@ -78,4 +67,3 @@ object(b)#%d (1) { string(5) "hallo" } } - diff --git a/ext/session/tests/007.phpt b/ext/session/tests/007.phpt deleted file mode 100644 index 54768e2bd..000000000 --- a/ext/session/tests/007.phpt +++ /dev/null @@ -1,67 +0,0 @@ ---TEST-- -bug compatibility: unset($c) with enabled register_globals ---SKIPIF-- -<?php include('skipif.inc'); ?> ---INI-- -register_long_arrays=1 -session.use_cookies=0 -session.cache_limiter= -register_globals=1 -session.bug_compat_42=1 -session.serialize_handler=php -session.save_handler=files -precision=14 ---FILE-- -<?php -error_reporting(E_ALL); - -session_id("abtest"); - -### Phase 1 cleanup -session_start(); -session_destroy(); - -### Phase 2 $HTTP_SESSION_VARS["c"] does not contain any value -session_id("abtest"); -session_register("c"); -unset($c); -$c = 3.14; -session_write_close(); -unset($HTTP_SESSION_VARS); -unset($c); - -### Phase 3 $HTTP_SESSION_VARS["c"] is set -session_start(); -var_dump($c); -var_dump($HTTP_SESSION_VARS); -unset($c); -$c = 2.78; - -session_write_close(); -unset($HTTP_SESSION_VARS); -unset($c); - -### Phase 4 final - -session_start(); -var_dump($c); -var_dump($HTTP_SESSION_VARS); - -session_destroy(); -?> ---EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 - -Deprecated: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0 - -Deprecated: Function session_register() is deprecated in %s on line %d -float(3.14) -array(1) { - ["c"]=> - &float(3.14) -} -float(3.14) -array(1) { - ["c"]=> - &float(3.14) -} diff --git a/ext/session/tests/008-php4.2.3.phpt b/ext/session/tests/008-php4.2.3.phpt deleted file mode 100644 index 9464ecded..000000000 --- a/ext/session/tests/008-php4.2.3.phpt +++ /dev/null @@ -1,78 +0,0 @@ ---TEST-- -bug compatibility: global is used albeit register_globals=0 ---SKIPIF-- -<?php include('skipif.inc'); - if (version_compare(PHP_VERSION,"4.2.3-dev", "<")) die("skip this is for PHP >= 4.2.3"); -?> ---INI-- -register_long_arrays=1 -session.use_cookies=0 -session.cache_limiter= -register_globals=0 -session.bug_compat_42=1 -session.bug_compat_warn=1 -track_errors=1 -log_errors=0 -html_errors=0 -display_errors=1 -session.serialize_handler=php -session.save_handler=files -precision=14 ---FILE-- -<?php -session_id("abtest"); - -### Phase 1 cleanup -session_start(); -session_destroy(); - -### Phase 2 $HTTP_SESSION_VARS["c"] does not contain any value -session_id("abtest"); -session_register("c"); -var_dump($c); -unset($c); -$c = 3.14; -@session_write_close(); // this generates an E_WARNING which will be printed -// by $php_errormsg so we can use "@" here. ANY further message IS an error. -echo $php_errormsg."\n"; -unset($HTTP_SESSION_VARS); -unset($c); - -### Phase 3 $HTTP_SESSION_VARS["c"] is set -session_start(); -var_dump($HTTP_SESSION_VARS); -unset($c); -$c = 2.78; - -session_write_close(); -unset($HTTP_SESSION_VARS); -unset($c); - -### Phase 4 final - -session_start(); -var_dump($c); -var_dump($HTTP_SESSION_VARS); - -session_destroy(); -?> ---EXPECTF-- -Deprecated: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0 - -Deprecated: Function session_register() is deprecated in %s on line %d - -Notice: Undefined variable: c in %s on line %d -NULL -session_write_close(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively -array(1) { - ["c"]=> - float(3.14) -} - -Notice: Undefined variable: c in %s on line %d -NULL -array(1) { - ["c"]=> - float(3.14) -} - diff --git a/ext/session/tests/009.phpt b/ext/session/tests/009.phpt index 1a7e87ce0..d73bc238c 100644 --- a/ext/session/tests/009.phpt +++ b/ext/session/tests/009.phpt @@ -1,14 +1,10 @@ --TEST-- -unset($_SESSION["name"]); should work with register_globals=off +unset($_SESSION["name"]); test --SKIPIF-- <?php include('skipif.inc'); ?> --INI-- -register_long_arrays=1 session.use_cookies=0 session.cache_limiter= -register_globals=0 -session.bug_compat_42=1 -session.bug_compat_warn=0 session.serialize_handler=php session.save_handler=files --FILE-- @@ -21,29 +17,28 @@ session_id("abtest"); session_start(); session_destroy(); -### Phase 2 $HTTP_SESSION_VARS["c"] does not contain any value +### Phase 2 $_SESSION["c"] does not contain any value session_id("abtest"); session_start(); -var_dump($HTTP_SESSION_VARS); -$HTTP_SESSION_VARS["name"] = "foo"; -var_dump($HTTP_SESSION_VARS); +var_dump($_SESSION); +$_SESSION["name"] = "foo"; +var_dump($_SESSION); session_write_close(); -### Phase 3 $HTTP_SESSION_VARS["c"] is set +### Phase 3 $_SESSION["c"] is set session_start(); -var_dump($HTTP_SESSION_VARS); -unset($HTTP_SESSION_VARS["name"]); -var_dump($HTTP_SESSION_VARS); +var_dump($_SESSION); +unset($_SESSION["name"]); +var_dump($_SESSION); session_write_close(); ### Phase 4 final session_start(); -var_dump($HTTP_SESSION_VARS); +var_dump($_SESSION); session_destroy(); ?> --EXPECT-- -Deprecated: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0 array(0) { } array(1) { diff --git a/ext/session/tests/010.phpt b/ext/session/tests/010.phpt index e1af8ce87..79638d283 100644 --- a/ext/session/tests/010.phpt +++ b/ext/session/tests/010.phpt @@ -5,9 +5,6 @@ $session_array = explode(";", session_encode()); should not segfault --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=0 -session.bug_compat_42=1 -session.bug_compat_warn=0 --FILE-- <?php error_reporting(E_ALL); diff --git a/ext/session/tests/011.phpt b/ext/session/tests/011.phpt index 6aaa6bd79..ff1adbaec 100644 --- a/ext/session/tests/011.phpt +++ b/ext/session/tests/011.phpt @@ -5,9 +5,6 @@ session_decode(); should not segfault --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=0 -session.bug_compat_42=1 -session.bug_compat_warn=0 --FILE-- <?php error_reporting(E_ALL); diff --git a/ext/session/tests/012.phpt b/ext/session/tests/012.phpt index b52333a99..870801127 100644 --- a/ext/session/tests/012.phpt +++ b/ext/session/tests/012.phpt @@ -5,9 +5,6 @@ registering $_SESSION should not segfault --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 -session.bug_compat_42=1 -session.bug_compat_warn=0 session.serialize_handler=php session.save_handler=files --FILE-- @@ -18,7 +15,7 @@ error_reporting(E_ALL); session_id("abtest"); session_start(); -session_register("_SESSION"); +$_SESSION["_SESSION"] = Array(); $_SESSION = "kk"; session_write_close(); @@ -31,8 +28,5 @@ session_destroy(); print "I live\n"; ?> ---EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 - -Deprecated: Function session_register() is deprecated in %s on line %d +--EXPECT-- I live diff --git a/ext/session/tests/013.phpt b/ext/session/tests/013.phpt index 04322f9f1..8d0f284b1 100644 --- a/ext/session/tests/013.phpt +++ b/ext/session/tests/013.phpt @@ -5,9 +5,6 @@ redefining SID should not cause warnings --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 -session.bug_compat_42=1 -session.bug_compat_warn=0 session.serialize_handler=php session.save_handler=files --FILE-- @@ -24,5 +21,4 @@ session_destroy(); print "I live\n"; ?> --EXPECT-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 I live diff --git a/ext/session/tests/014.phpt b/ext/session/tests/014.phpt index 09ad0f5b1..73bc28ea6 100644 --- a/ext/session/tests/014.phpt +++ b/ext/session/tests/014.phpt @@ -6,9 +6,6 @@ a script should not be able to modify session.use_trans_sid session.use_trans_sid=0 session.use_cookies=0 session.cache_limiter= -register_globals=1 -session.bug_compat_42=1 -session.bug_compat_warn=0 session.name=PHPSESSID session.serialize_handler=php session.save_handler=files @@ -33,7 +30,6 @@ ini_set("session.use_trans_sid","0"); session_destroy(); ?> --EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 <a href="/link"> Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line %d diff --git a/ext/session/tests/019.phpt b/ext/session/tests/019.phpt index 9c4f8caf9..3ee8ccd42 100644 --- a/ext/session/tests/019.phpt +++ b/ext/session/tests/019.phpt @@ -5,7 +5,6 @@ serializing references test case using globals --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.serialize_handler=php session.save_handler=files --FILE-- @@ -25,31 +24,28 @@ class TFoo { session_id("abtest"); session_start(); -session_register('o1', 'o2' ); -$o1 = new TFoo(42); -$o2 =& $o1; +$_SESSION["o1"] = new TFoo(42); +$_SESSION["o2"] =& $_SESSION["o1"]; session_write_close(); -unset($o1); -unset($o2); +unset($_SESSION["o1"]); +unset($_SESSION["o2"]); session_start(); var_dump($_SESSION); -$o1->inc(); -$o2->inc(); +$_SESSION["o1"]->inc(); +$_SESSION["o2"]->inc(); var_dump($_SESSION); session_destroy(); ?> --EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 -Deprecated: Function session_register() is deprecated in %s on line %d array(2) { ["o1"]=> &object(TFoo)#%d (1) { diff --git a/ext/session/tests/bug24592.phpt b/ext/session/tests/bug24592.phpt index 059125ba2..9f6c39531 100644 --- a/ext/session/tests/bug24592.phpt +++ b/ext/session/tests/bug24592.phpt @@ -3,7 +3,6 @@ Bug #24592 (crash when multiple NULL values are being stored) --SKIPIF-- <?php include('skipif.inc'); ?> --INI-- -register_globals=0 html_errors=0 session.save_handler=files --FILE-- diff --git a/ext/session/tests/bug26862.phpt b/ext/session/tests/bug26862.phpt index 44e7418cd..7990f7435 100644 --- a/ext/session/tests/bug26862.phpt +++ b/ext/session/tests/bug26862.phpt @@ -3,7 +3,6 @@ Bug #26862 (ob_flush() before output_reset_rewrite_vars() results in data loss) --SKIPIF-- <?php include('skipif.inc'); ?> --INI-- -register_globals=0 html_errors=0 session.use_trans_sid=0 session.save_handler=files diff --git a/ext/session/tests/bug55688.phpt b/ext/session/tests/bug55688.phpt new file mode 100644 index 000000000..8db48384a --- /dev/null +++ b/ext/session/tests/bug55688.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #55688 (Crash when calling SessionHandler::gc()) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +html_errors=0 +session.save_handler=files +--FILE-- +<?php +ini_set('session.save_handler', 'files'); +$x = new SessionHandler; +$x->gc(1); +?> +--EXPECTF-- +Warning: SessionHandler::gc(): Parent session handler is not open in %s on line %d diff --git a/ext/session/tests/rfc1867.phpt b/ext/session/tests/rfc1867.phpt new file mode 100644 index 000000000..dc44e8b44 --- /dev/null +++ b/ext/session/tests/rfc1867.phpt @@ -0,0 +1,129 @@ +--TEST-- +session rfc1867 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +session.upload_progress.min_freq=0.000000001 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_cleanup.phpt b/ext/session/tests/rfc1867_cleanup.phpt new file mode 100644 index 000000000..f70b395d2 --- /dev/null +++ b/ext/session/tests/rfc1867_cleanup.phpt @@ -0,0 +1,83 @@ +--TEST-- +session rfc1867 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=1 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +session.upload_progress.min_freq=0.000000001 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_cleanup.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_disabled.phpt b/ext/session/tests/rfc1867_disabled.phpt new file mode 100644 index 000000000..449005579 --- /dev/null +++ b/ext/session/tests/rfc1867_disabled.phpt @@ -0,0 +1,76 @@ +--TEST-- +session rfc1867 disabled +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=0 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_disabled_2.phpt b/ext/session/tests/rfc1867_disabled_2.phpt new file mode 100644 index 000000000..e878f4619 --- /dev/null +++ b/ext/session/tests/rfc1867_disabled_2.phpt @@ -0,0 +1,76 @@ +--TEST-- +session rfc1867 disabled 2 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_inter.phpt b/ext/session/tests/rfc1867_inter.phpt new file mode 100644 index 000000000..768637105 --- /dev/null +++ b/ext/session/tests/rfc1867_inter.phpt @@ -0,0 +1,133 @@ +--TEST-- +session rfc1867 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +session.upload_progress.min_freq=0.000000001 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_inter.php_1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_inter.php_2 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__) . "_1"]); +var_dump($_SESSION["upload_progress_" . basename(__FILE__) . "_2"]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} +NULL diff --git a/ext/session/tests/rfc1867_invalid_settings.phpt b/ext/session/tests/rfc1867_invalid_settings.phpt new file mode 100644 index 000000000..d954563b0 --- /dev/null +++ b/ext/session/tests/rfc1867_invalid_settings.phpt @@ -0,0 +1,16 @@ +--TEST-- +session rfc1867 invalid settings +--INI-- +session.upload_progress.freq=-1 +error_log= +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +var_dump(ini_get("session.upload_progress.freq")); +?> +--EXPECTF-- +PHP Warning: PHP Startup: session.upload_progress.freq must be greater than or equal to zero in %s + +Warning: PHP Startup: session.upload_progress.freq must be greater than or equal to zero in %s +string(%d) "1%" diff --git a/ext/session/tests/rfc1867_invalid_settings_2.phpt b/ext/session/tests/rfc1867_invalid_settings_2.phpt new file mode 100644 index 000000000..544510eef --- /dev/null +++ b/ext/session/tests/rfc1867_invalid_settings_2.phpt @@ -0,0 +1,16 @@ +--TEST-- +session rfc1867 invalid settings 2 +--INI-- +session.upload_progress.freq=200% +error_log= +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +var_dump(ini_get("session.upload_progress.freq")); +?> +--EXPECTF-- +PHP Warning: PHP Startup: session.upload_progress.freq cannot be over 100% in %s + +Warning: PHP Startup: session.upload_progress.freq cannot be over 100% in %s +string(%d) "1%" diff --git a/ext/session/tests/rfc1867_no_name.phpt b/ext/session/tests/rfc1867_no_name.phpt new file mode 100644 index 000000000..c1dda8156 --- /dev/null +++ b/ext/session/tests/rfc1867_no_name.phpt @@ -0,0 +1,76 @@ +--TEST-- +session rfc1867 no name +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_sid_cookie.phpt b/ext/session/tests/rfc1867_sid_cookie.phpt new file mode 100644 index 000000000..735a5ac20 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_cookie.phpt @@ -0,0 +1,128 @@ +--TEST-- +session rfc1867 sid cookie +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_cookie.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_get.phpt b/ext/session/tests/rfc1867_sid_get.phpt new file mode 100644 index 000000000..cc5a793e7 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_get.phpt @@ -0,0 +1,126 @@ +--TEST-- +session rfc1867 sid get +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--GET-- +PHPSESSID=rfc1867-tests +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_get.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_get_2.phpt b/ext/session/tests/rfc1867_sid_get_2.phpt new file mode 100644 index 000000000..1d22e5930 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_get_2.phpt @@ -0,0 +1,128 @@ +--TEST-- +session rfc1867 sid get 2 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=0 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests-cookie +--GET-- +PHPSESSID=rfc1867-tests +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_get_2.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_invalid.phpt b/ext/session/tests/rfc1867_sid_invalid.phpt new file mode 100644 index 000000000..b28a2e341 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_invalid.phpt @@ -0,0 +1,79 @@ +--TEST-- +session rfc1867 sid cookie +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.auto_start=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=_ +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_invalid.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +error_reporting(0); +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +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 +string(%d) "%s" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_sid_only_cookie.phpt b/ext/session/tests/rfc1867_sid_only_cookie.phpt new file mode 100644 index 000000000..9a0105668 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_only_cookie.phpt @@ -0,0 +1,128 @@ +--TEST-- +session rfc1867 sid only cookie +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=1 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_only_cookie.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_only_cookie_2.phpt b/ext/session/tests/rfc1867_sid_only_cookie_2.phpt new file mode 100644 index 000000000..e705314d6 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_only_cookie_2.phpt @@ -0,0 +1,80 @@ +--TEST-- +session rfc1867 sid only cookie 2 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=1 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_only_cookie_2.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "%s" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_sid_post.phpt b/ext/session/tests/rfc1867_sid_post.phpt new file mode 100644 index 000000000..7c1eb2de5 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_post.phpt @@ -0,0 +1,124 @@ +--TEST-- +session rfc1867 sid post +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_post.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/session_encode_basic.phpt b/ext/session/tests/session_encode_basic.phpt index b087f7441..dfe40d204 100644 --- a/ext/session/tests/session_encode_basic.phpt +++ b/ext/session/tests/session_encode_basic.phpt @@ -1,5 +1,7 @@ --TEST-- Test session_encode() function : basic functionality +--INI-- +serialize_precision=100 --SKIPIF-- <?php include('skipif.inc'); ?> --FILE-- @@ -120,7 +122,7 @@ string(13) "data|d:-10.5;" string(20) "data|d:123456789000;" -- Iteration 8 -- -string(29) "data|d:1.2345678899999999E-9;" +string(%d) "data|d:1.2345678899999999145113427164344339914681114578343112953007221221923828125E-9;" -- Iteration 9 -- string(11) "data|d:0.5;" diff --git a/ext/session/tests/session_id_variation2.phpt b/ext/session/tests/session_id_variation2.phpt index 70db283ae..f69aa44c0 100644 --- a/ext/session/tests/session_id_variation2.phpt +++ b/ext/session/tests/session_id_variation2.phpt @@ -4,6 +4,8 @@ Test session_id() function : variation <?php include('skipif.inc'); ?> --INI-- session.hash_function=0 +session.entropy_file= +session.entropy_length=0 --FILE-- <?php diff --git a/ext/session/tests/session_is_registered_basic.phpt b/ext/session/tests/session_is_registered_basic.phpt deleted file mode 100644 index 5eb127ea4..000000000 --- a/ext/session/tests/session_is_registered_basic.phpt +++ /dev/null @@ -1,318 +0,0 @@ ---TEST-- -Test session_unregister() function : basic functionality ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_is_registered(string $name) - * Description : Find out whether a global variable is registered in a session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_is_registered() : 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 -); - - -$iterator = 1; -foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(session_start()); - var_dump(session_is_registered($input)); - var_dump($_SESSION); - var_dump(session_destroy()); - $iterator++; -}; - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_is_registered() : basic functionality *** - --- Iteration 1 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 2 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 3 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 4 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 5 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 6 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 7 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 8 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 9 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 10 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 11 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 12 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 13 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 14 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 15 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 16 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 17 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 18 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 19 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 20 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 21 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 22 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 23 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 24 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d - -Warning: session_is_registered() expects parameter 1 to be string, resource given in %s on line %d -NULL -array(0) { -} -bool(true) -Done diff --git a/ext/session/tests/session_is_registered_variation1.phpt b/ext/session/tests/session_is_registered_variation1.phpt deleted file mode 100644 index 35c357d14..000000000 --- a/ext/session/tests/session_is_registered_variation1.phpt +++ /dev/null @@ -1,109 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_is_registered(string $name) - * Description : Find out whether a global variable is registered in a session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_is_registered() : variation ***\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 -); - -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_is_registered($inputs)); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_is_registered() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d - -Warning: session_is_registered() expects parameter 1 to be string, array given in %s on line %d -NULL -array(0) { -} -bool(true) -array(0) { -} -Done diff --git a/ext/session/tests/session_is_registered_variation2.phpt b/ext/session/tests/session_is_registered_variation2.phpt deleted file mode 100644 index 3727518b1..000000000 --- a/ext/session/tests/session_is_registered_variation2.phpt +++ /dev/null @@ -1,75 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_is_registered(string $name) - * Description : Find out whether a global variable is registered in a session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_is_registered() : variation ***\n"; - -var_dump(session_is_registered("foo")); -var_dump(session_start()); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -$_SESSION["foo"] = "Hello World!"; -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -var_dump(session_is_registered("foo")); -var_dump(session_unregister("foo")); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -var_dump(session_is_registered("foo")); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_is_registered() : variation *** - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(true) -array(1) { - ["foo"]=> - string(12) "Hello World!" -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(true) - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -Done diff --git a/ext/session/tests/session_is_registered_variation3.phpt b/ext/session/tests/session_is_registered_variation3.phpt deleted file mode 100644 index b435d043d..000000000 --- a/ext/session/tests/session_is_registered_variation3.phpt +++ /dev/null @@ -1,72 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_is_registered(string $name) - * Description : Find out whether a global variable is registered in a session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_is_registered() : variation ***\n"; - -var_dump(session_is_registered("foo")); -var_dump(session_start()); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -$blah = "Hello World!"; -var_dump(session_is_registered("foo")); -$_SESSION["foo"] = &$blah; -var_dump($_SESSION); -var_dump(session_is_registered("foo")); -var_dump(session_unregister("foo")); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_is_registered() : variation *** - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(1) { - ["foo"]=> - &string(12) "Hello World!" -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(true) - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -Done diff --git a/ext/session/tests/session_register_basic.phpt b/ext/session/tests/session_register_basic.phpt deleted file mode 100644 index a394f748e..000000000 --- a/ext/session/tests/session_register_basic.phpt +++ /dev/null @@ -1,364 +0,0 @@ ---TEST-- -Test session_register() function : basic functionality ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_register(mixed $name [,mixed $...]) - * Description : Register one or more global variables with the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_register() : 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 -); - - -$iterator = 1; -foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(session_start()); - var_dump(session_register($input)); - var_dump($_SESSION); - var_dump(session_destroy()); - $iterator++; -}; - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_register() : basic functionality *** - --- Iteration 1 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["0"]=> - NULL -} -bool(true) - --- Iteration 2 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["1"]=> - NULL -} -bool(true) - --- Iteration 3 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["12345"]=> - NULL -} -bool(true) - --- Iteration 4 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["-2345"]=> - NULL -} -bool(true) - --- Iteration 5 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["10.5"]=> - NULL -} -bool(true) - --- Iteration 6 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["-10.5"]=> - NULL -} -bool(true) - --- Iteration 7 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["123456789000"]=> - NULL -} -bool(true) - --- Iteration 8 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["1.23456789E-9"]=> - NULL -} -bool(true) - --- Iteration 9 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["0.5"]=> - NULL -} -bool(true) - --- Iteration 10 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 11 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 12 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["1"]=> - NULL -} -bool(true) - --- Iteration 13 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 14 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["1"]=> - NULL -} -bool(true) - --- Iteration 15 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 16 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 17 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 18 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["Nothing"]=> - NULL -} -bool(true) - --- Iteration 19 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["Nothing"]=> - NULL -} -bool(true) - --- Iteration 20 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["Hello World!"]=> - NULL -} -bool(true) - --- Iteration 21 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["Hello World!"]=> - NULL -} -bool(true) - --- Iteration 22 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 23 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 24 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["Resource id #%d"]=> - NULL -} -bool(true) -Done diff --git a/ext/session/tests/session_register_variation1.phpt b/ext/session/tests/session_register_variation1.phpt deleted file mode 100644 index 82950d9a9..000000000 --- a/ext/session/tests/session_register_variation1.phpt +++ /dev/null @@ -1,159 +0,0 @@ ---TEST-- -Test session_register() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_register(mixed $name [,mixed $...]) - * Description : Register one or more global variables with the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_register() : variation ***\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 -); - -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_register($inputs)); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_register() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(13) { - ["0"]=> - NULL - ["1"]=> - NULL - ["12345"]=> - NULL - ["-2345"]=> - NULL - ["10.5"]=> - NULL - ["-10.5"]=> - NULL - ["123456789000"]=> - NULL - ["1.23456789E-9"]=> - NULL - ["0.5"]=> - NULL - [""]=> - NULL - ["Nothing"]=> - NULL - ["Hello World!"]=> - NULL - ["Resource id #%d"]=> - NULL -} -bool(true) -array(13) { - ["0"]=> - NULL - ["1"]=> - NULL - ["12345"]=> - NULL - ["-2345"]=> - NULL - ["10.5"]=> - NULL - ["-10.5"]=> - NULL - ["123456789000"]=> - NULL - ["1.23456789E-9"]=> - NULL - ["0.5"]=> - NULL - [""]=> - NULL - ["Nothing"]=> - NULL - ["Hello World!"]=> - NULL - ["Resource id #%d"]=> - NULL -} -Done diff --git a/ext/session/tests/session_register_variation2.phpt b/ext/session/tests/session_register_variation2.phpt deleted file mode 100644 index d9060c7e9..000000000 --- a/ext/session/tests/session_register_variation2.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -Test session_register() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_register(mixed $name [,mixed $...]) - * Description : Register one or more global variables with the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_register() : variation ***\n"; - -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_register()); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_register() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_register() is deprecated in %s on line %d - -Warning: session_register() expects at least 1 parameter, 0 given in %s on line %d -NULL -array(0) { -} -bool(true) -array(0) { -} -Done diff --git a/ext/session/tests/session_register_variation3.phpt b/ext/session/tests/session_register_variation3.phpt deleted file mode 100644 index 43172ac49..000000000 --- a/ext/session/tests/session_register_variation3.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -Test session_register() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_register(mixed $name [,mixed $...]) - * Description : Register one or more global variables with the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_register() : variation ***\n"; - -$blah = "Hello World!"; -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_register("blah")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_register() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["blah"]=> - NULL -} -bool(true) -array(1) { - ["blah"]=> - NULL -} -Done diff --git a/ext/session/tests/session_register_variation4.phpt b/ext/session/tests/session_register_variation4.phpt deleted file mode 100644 index 4f0781502..000000000 --- a/ext/session/tests/session_register_variation4.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Test session_register() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_register(mixed $name [,mixed $...]) - * Description : Register one or more global variables with the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_register() : variation ***\n"; - -$blah = "Hello World!"; -$foo = &$blah; -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_register("foo")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_register() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["foo"]=> - NULL -} -bool(true) -array(1) { - ["foo"]=> - NULL -} -Done diff --git a/ext/session/tests/session_save_path_variation5.phpt b/ext/session/tests/session_save_path_variation5.phpt index ca6cb51c5..5407b5e15 100644 --- a/ext/session/tests/session_save_path_variation5.phpt +++ b/ext/session/tests/session_save_path_variation5.phpt @@ -6,15 +6,14 @@ if(substr(PHP_OS, 0, 3) == "WIN") die("skip Not for Windows"); ?> --INI-- -open_basedir=. session.save_handler=files session.save_path= session.name=PHPSESSID +open_basedir=. --FILE-- <?php ob_start(); - /* * Prototype : string session_save_path([string $path]) * Description : Get and/or set the current session save path diff --git a/ext/session/tests/session_set_save_handler_class_001.phpt b/ext/session/tests/session_set_save_handler_class_001.phpt new file mode 100644 index 000000000..83e899a2b --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_001.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test session_set_save_handler() : basic class wrapping existing handler +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : basic class wrapping existing handler ***\n"; + +class MySession extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } +} + +$oldHandler = ini_get('session.save_handler'); +$handler = new MySession; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); + +$_SESSION['foo'] = "hello"; + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() : basic class wrapping existing handler *** +Open +Read %s +string(%d) "%s" +string(5) "files" +string(4) "user" +int(2) +array(0) { +} +Open %s +Read %s +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_class_002.phpt b/ext/session/tests/session_set_save_handler_class_002.phpt new file mode 100644 index 000000000..9d5f732b5 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_002.phpt @@ -0,0 +1,113 @@ +--TEST-- +Test session_set_save_handler() : full handler implementation +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : full handler implementation ***\n"; + +class MySession2 extends SessionHandler { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = '/tmp'; + } + $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; + } +} + +$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')); +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(); + +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() : full handler implementation *** +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} +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_003.phpt b/ext/session/tests/session_set_save_handler_class_003.phpt new file mode 100644 index 000000000..e9a3cc2fe --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_003.phpt @@ -0,0 +1,78 @@ +--TEST-- +Test session_set_save_handler() : inheritance +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : inheritance ***\n"; + +class MySession3 extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + return parent::read($key); + } +} + +class MySession4 extends MySession3 { + public function write($id, $data) { + $this->i = "hai"; + return parent::write($id, $data); + } +} + +$handler = new MySession3; +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = "hello"; + +session_write_close(); +session_unset(); + +session_start(); + +var_dump($_SESSION, $handler->i); + +session_write_close(); +session_unset(); + +$handler = new MySession4; +session_set_save_handler($handler); + +session_start(); + +session_write_close(); +session_unset(); + +var_dump(session_id(), $_SESSION, $handler->i); + +--EXPECTF-- +*** Testing session_set_save_handler() : inheritance *** +array(1) { + ["foo"]=> + string(5) "hello" +} +int(4) +string(%d) "%s" +array(1) { + ["foo"]=> + string(5) "hello" +} +string(3) "hai" diff --git a/ext/session/tests/session_set_save_handler_class_004.phpt b/ext/session/tests/session_set_save_handler_class_004.phpt new file mode 100644 index 000000000..103b13baa --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_004.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test session_set_save_handler() : default object +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : default object ***\n"; + +session_set_save_handler(new SessionHandler); +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() : default object *** +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_005.phpt b/ext/session/tests/session_set_save_handler_class_005.phpt new file mode 100644 index 000000000..a996eb8d2 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_005.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test session_set_save_handler() : incomplete implementation +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : incomplete implementation ***\n"; + +class MySession6 extends SessionHandler { + public function open($path, $name) { + // don't call parent + return true; + } + + public function read($id) { + // should error because parent::open hasn't been called + return parent::read($id); + } +} + +$handler = new MySession6; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + + +--EXPECTF-- +*** Testing session_set_save_handler() : incomplete implementation *** + +Warning: SessionHandler::read(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d +string(%d) "%s" +string(4) "user" +array(0) { +} + +Warning: SessionHandler::write(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d + +Warning: SessionHandler::close(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d diff --git a/ext/session/tests/session_set_save_handler_class_006.phpt b/ext/session/tests/session_set_save_handler_class_006.phpt new file mode 100644 index 000000000..5830b6d4f --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_006.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test session_set_save_handler() : using objects in close +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : using objects in close ***\n"; + +class MySession7_Foo { + public $state = 'ok'; + function __destruct() { + $this->state = 'destroyed'; + } +} + +class MySession7 extends SessionHandler { + public $foo; + public function close() { + var_dump($this->foo); + @var_dump($GLOBALS['bar']); + return parent::close(); + } +} + +$bar = new MySession7_Foo; +$handler = new MySession7; +$handler->foo = new MySession7_Foo; +session_set_save_handler($handler); +session_start(); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : using objects in close *** +object(MySession7_Foo)#%d (%d) { + ["state"]=> + string(2) "ok" +} +object(MySession7_Foo)#%d (%d) { + ["state"]=> + string(2) "ok" +} diff --git a/ext/session/tests/session_set_save_handler_class_007.phpt b/ext/session/tests/session_set_save_handler_class_007.phpt new file mode 100644 index 000000000..7344ae1ef --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_007.phpt @@ -0,0 +1,74 @@ +--TEST-- +Test session_set_save_handler() : manual shutdown, reopen +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : manual shutdown, reopen ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = 'bar'; + +// explicit close +$handler->finish(); + +$handler = new MySession(2); +session_set_save_handler($handler); +session_start(); + +// implicit close (called by shutdown function) +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : manual shutdown, reopen *** +(#1) constructor called +(#1) finish called %s +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +(#2) constructor called +(#1) destructor called +done +(#2) writing %s = foo|s:3:"bar"; +(#2) closing %s +(#2) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_008.phpt b/ext/session/tests/session_set_save_handler_class_008.phpt new file mode 100644 index 000000000..28cb692f0 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_008.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test session_set_save_handler() : manual shutdown +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : manual shutdown ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = 'bar'; + +// explicit close +$handler->finish(); + +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : manual shutdown *** +(#1) constructor called +(#1) finish called %s +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +done +(#1) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_009.phpt b/ext/session/tests/session_set_save_handler_class_009.phpt new file mode 100644 index 000000000..a8b57dc54 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_009.phpt @@ -0,0 +1,62 @@ +--TEST-- +Test session_set_save_handler() : implicit shutdown +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : implicit shutdown ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + $this->shutdown(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = 'bar'; + +// implicit close +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : implicit shutdown *** +(#1) constructor called +done +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +(#1) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_010.phpt b/ext/session/tests/session_set_save_handler_class_010.phpt new file mode 100644 index 000000000..02304f497 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_010.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test session_set_save_handler() : manual shutdown function +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : manual shutdown function ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler, false); +register_shutdown_function(array($handler, 'finish')); +session_start(); + +$_SESSION['foo'] = 'bar'; + +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : manual shutdown function *** +(#1) constructor called +done +(#1) finish called %s +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +(#1) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_011.phpt b/ext/session/tests/session_set_save_handler_class_011.phpt new file mode 100644 index 000000000..7fa365769 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_011.phpt @@ -0,0 +1,66 @@ +--TEST-- +Test session_set_save_handler() : shutdown failure +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : shutdown failure ***\n"; + +class MySession extends SessionHandler { + public $num; + public $destroyed = false; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + $this->destroyed = true; + } + public function write($id, $data) { + if ($this->destroyed) { + echo "(#$this->num) destroyed, cannot write\n"; + } else { + echo "(#$this->num) writing $id = $data\n"; + } + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + if ($this->destroyed) { + echo "(#$this->num) destroyed, cannot write\n"; + } else { + echo "(#$this->num) closing $id\n"; + } + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler, false); +session_start(); + +$_SESSION['foo'] = 'bar'; + +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : shutdown failure *** +(#1) constructor called +done +(#1) destructor called +(#1) destroyed, cannot write +(#1) destroyed, cannot write diff --git a/ext/session/tests/session_set_save_handler_class_012.phpt b/ext/session/tests/session_set_save_handler_class_012.phpt new file mode 100644 index 000000000..706ef793e --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_012.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test session_set_save_handler() : incorrect arguments for existing handler open +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : incorrect arguments for existing handler open ***\n"; + +class MySession extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open(); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } +} + +$oldHandler = ini_get('session.save_handler'); +$handler = new MySession; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); + +--EXPECTF-- +*** Testing session_set_save_handler() : incorrect arguments for existing handler open *** +Open + +Warning: SessionHandler::open() expects exactly 2 parameters, 0 given in %s on line %d +Read %s + +Warning: SessionHandler::read(): Parent session handler is not open in %s on line %d +string(%d) "%s" +string(5) "files" +string(4) "user" +int(2) +array(0) { +} + +Warning: Unknown: Parent session handler is not open in Unknown on line 0 + +Warning: Unknown: Parent session handler is not open in Unknown on line 0 diff --git a/ext/session/tests/session_set_save_handler_class_013.phpt b/ext/session/tests/session_set_save_handler_class_013.phpt new file mode 100644 index 000000000..f536aa72a --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_013.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test session_set_save_handler() : incorrect arguments for existing handler close +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : incorrect arguments for existing handler close ***\n"; + +class MySession extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } + public function close() { + return parent::close(false); + } +} + +$oldHandler = ini_get('session.save_handler'); +$handler = new MySession; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); + +--EXPECTF-- +*** Testing session_set_save_handler() : incorrect arguments for existing handler close *** +Open +Read %s +string(%d) "%s" +string(5) "files" +string(4) "user" +int(2) +array(0) { +} + +Warning: SessionHandler::close() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/session/tests/session_set_save_handler_class_014.phpt b/ext/session/tests/session_set_save_handler_class_014.phpt new file mode 100644 index 000000000..ea62beb0f --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_014.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test session_set_save_handler() : calling default handler when save_handler=user +--INI-- +session.save_handler=user +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : calling default handler when save_handler=user ***\n"; + +$oldHandler = ini_get('session.save_handler'); +$handler = new SessionHandler; +session_set_save_handler($handler); + +session_start(); + +--EXPECTF-- +*** Testing session_set_save_handler() : calling default handler when save_handler=user *** + +Fatal error: SessionHandler::open(): Cannot call default session handler in %s on line %d diff --git a/ext/session/tests/session_set_save_handler_class_015.phpt b/ext/session/tests/session_set_save_handler_class_015.phpt new file mode 100644 index 000000000..3bef51be4 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_015.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test session_set_save_handler() : register session handler but don't start +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $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() : register session handler but don't start ***\n"; + +session_set_save_handler(new SessionHandler); + +--EXPECTF-- +*** Testing session_set_save_handler() : register session handler but don't start *** diff --git a/ext/session/tests/session_set_save_handler_iface_001.phpt b/ext/session/tests/session_set_save_handler_iface_001.phpt new file mode 100644 index 000000000..c8199ffe3 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_iface_001.phpt @@ -0,0 +1,113 @@ +--TEST-- +Test session_set_save_handler() function: 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: interface ***\n"; + +class MySession2 implements SessionHandlerInterface { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = '/tmp'; + } + $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; + } +} + +$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')); +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(); + +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: interface *** +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} +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_iface_002.phpt b/ext/session/tests/session_set_save_handler_iface_002.phpt new file mode 100644 index 000000000..42e8fbe3f --- /dev/null +++ b/ext/session/tests/session_set_save_handler_iface_002.phpt @@ -0,0 +1,90 @@ +--TEST-- +Test session_set_save_handler() function: interface wrong +--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: interface wrong ***\n"; + +interface MySessionHandlerInterface { + public function open($path, $name); + public function close(); + public function read($id); + public function write($id, $data); + public function destroy($id); + public function gc($maxlifetime); +} + +class MySession2 implements MySessionHandlerInterface { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = '/tmp'; + } + $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) { + echo "Unsupported session handler in use\n"; + } + + 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; + } +} + +function good_write($id, $data) { + global $handler; + echo "good handler writing\n"; + return file_put_contents($handler->path . $id, $data); +} + +$handler = new MySession2; + +$ret = session_set_save_handler(array($handler, 'open'), array($handler, 'close'), + array($handler, 'read'), 'good_write', array($handler, 'destroy'), array($handler, 'gc')); + +var_dump($ret); +$ret = session_set_save_handler($handler); +var_dump($ret); + +session_start(); + +--EXPECTF-- +*** Testing session_set_save_handler() function: interface wrong *** +bool(true) + +Warning: session_set_save_handler() expects parameter 1 to be SessionHandlerInterface, object given in %s +bool(false) +good handler writing diff --git a/ext/session/tests/session_status.phpt b/ext/session/tests/session_status.phpt new file mode 100644 index 000000000..d1f7e2f38 --- /dev/null +++ b/ext/session/tests/session_status.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test session_status() function : active, none +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +echo "*** Testing session_status() : active, none\n"; + +var_dump(PHP_SESSION_NONE != PHP_SESSION_ACTIVE); +var_dump(session_status() == PHP_SESSION_NONE); + +session_start(); + +var_dump(session_status() == PHP_SESSION_ACTIVE); + +?> +--EXPECTF-- +*** Testing session_status() : active, none +bool(true) +bool(true) +bool(true) diff --git a/ext/session/tests/session_status_disabled.phpt b/ext/session/tests/session_status_disabled.phpt new file mode 100644 index 000000000..24e0ecd7b --- /dev/null +++ b/ext/session/tests/session_status_disabled.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test session_status() function : disabled +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_handler=non-existant +--FILE-- +<?php + +echo "*** Testing session_status() : disabled\n"; + +var_dump(session_status() == PHP_SESSION_DISABLED); + +?> +--EXPECTF-- +*** Testing session_status() : disabled +bool(true) diff --git a/ext/session/tests/session_unregister_basic.phpt b/ext/session/tests/session_unregister_basic.phpt deleted file mode 100644 index 15ebb7dd2..000000000 --- a/ext/session/tests/session_unregister_basic.phpt +++ /dev/null @@ -1,225 +0,0 @@ ---TEST-- -Test session_unregister() function : basic functionality ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_unregister(string $name) - * Description : Unregister a global variable from the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_unregister() : 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 -); - - -var_dump(session_start()); - -$iterator = 1; -foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(session_unregister($input)); - $iterator++; -}; - -var_dump(session_destroy()); - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_unregister() : basic functionality *** -bool(true) - --- Iteration 1 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 2 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 3 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 4 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 5 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 6 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 7 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 8 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 9 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 10 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 11 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 12 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 13 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 14 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 15 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 16 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 17 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 18 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 19 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 20 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 21 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 22 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 23 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 24 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d - -Warning: session_unregister() expects parameter 1 to be string, resource given in %s on line %d -NULL -bool(true) -Done diff --git a/ext/session/tests/session_unregister_variation1.phpt b/ext/session/tests/session_unregister_variation1.phpt deleted file mode 100644 index 609a05163..000000000 --- a/ext/session/tests/session_unregister_variation1.phpt +++ /dev/null @@ -1,159 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_unregister(string $name) - * Description : Unregister a global variable from the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_unregister() : variation ***\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 -); - -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_register($inputs)); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_unregister() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(13) { - ["0"]=> - NULL - ["1"]=> - NULL - ["12345"]=> - NULL - ["-2345"]=> - NULL - ["10.5"]=> - NULL - ["-10.5"]=> - NULL - ["123456789000"]=> - NULL - ["1.23456789E-9"]=> - NULL - ["0.5"]=> - NULL - [""]=> - NULL - ["Nothing"]=> - NULL - ["Hello World!"]=> - NULL - ["Resource id #%d"]=> - NULL -} -bool(true) -array(13) { - ["0"]=> - NULL - ["1"]=> - NULL - ["12345"]=> - NULL - ["-2345"]=> - NULL - ["10.5"]=> - NULL - ["-10.5"]=> - NULL - ["123456789000"]=> - NULL - ["1.23456789E-9"]=> - NULL - ["0.5"]=> - NULL - [""]=> - NULL - ["Nothing"]=> - NULL - ["Hello World!"]=> - NULL - ["Resource id #%d"]=> - NULL -} -Done diff --git a/ext/session/tests/session_unregister_variation2.phpt b/ext/session/tests/session_unregister_variation2.phpt deleted file mode 100644 index 19cf4d5e6..000000000 --- a/ext/session/tests/session_unregister_variation2.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_unregister(string $name) - * Description : Unregister a global variable from the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_unregister() : variation ***\n"; - -var_dump(session_start()); -var_dump($_SESSION); -$_SESSION["foo"] = "Hello World!"; -var_dump($_SESSION); -var_dump(session_unregister("foo")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_unregister() : variation *** -bool(true) -array(0) { -} -array(1) { - ["foo"]=> - string(12) "Hello World!" -} - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) -array(0) { -} -bool(true) -array(0) { -} -Done diff --git a/ext/session/tests/session_unregister_variation3.phpt b/ext/session/tests/session_unregister_variation3.phpt deleted file mode 100644 index 7933b0878..000000000 --- a/ext/session/tests/session_unregister_variation3.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_unregister(string $name) - * Description : Unregister a global variable from the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_unregister() : variation ***\n"; - -var_dump(session_start()); -var_dump($_SESSION); -$blah = "Hello World!"; -$_SESSION["foo"] = &$blah; -var_dump($_SESSION); -var_dump(session_unregister("foo")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_unregister() : variation *** -bool(true) -array(0) { -} -array(1) { - ["foo"]=> - &string(12) "Hello World!" -} - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) -array(0) { -} -bool(true) -array(0) { -} -Done diff --git a/ext/session/tests/sessionhandler_open_001.phpt b/ext/session/tests/sessionhandler_open_001.phpt new file mode 100644 index 000000000..6ade9e00a --- /dev/null +++ b/ext/session/tests/sessionhandler_open_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing repated SessionHandler::open() calls +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ini_set('session.save_handler', 'files'); +$x = new SessionHandler; +$x->open('',''); +$x->open('',''); +$x->open('',''); +$x->open('',''); + +print "Done!\n"; + +?> +--EXPECTF-- +Done! |