diff options
106 files changed, 9732 insertions, 0 deletions
diff --git a/ext/session/tests/save_handler.inc b/ext/session/tests/save_handler.inc new file mode 100644 index 0000000000..ebe9cac564 --- /dev/null +++ b/ext/session/tests/save_handler.inc @@ -0,0 +1,63 @@ +<?php + +DEFINE("SESSION_FILE_PREFIX" ,"session_test_"); +function open($save_path, $session_name) { + global $session_save_path, $name; + $session_save_path = $save_path; + $name = $session_name; + echo "Open [${session_save_path},${session_name}]\n"; + return true; +} + +function close() { + global $session_save_path, $name; + echo "Close [${session_save_path},${name}]\n"; + return true; +} + +function read($id) { + global $session_save_path, $name, $session_id; + $session_id = $id; + echo "Read [${session_save_path},${id}]\n"; + $session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id; + return (string) @file_get_contents($session_file); +} + +function write($id, $session_data) { + global $session_save_path, $name, $session_id; + $session_id = $id; + echo "Write [${session_save_path},${id},${session_data}]\n"; + $session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id; + if ($fp = fopen($session_file, "w")) { + $return = fwrite($fp, $session_data); + fclose($fp); + return $return; + } + return false; +} + +function destroy($id) { + global $session_save_path, $name; + echo "Destroy [${session_save_path},${id}]\n"; + $session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id; + return unlink($session_file); +} + +function gc($maxlifetime) { + global $session_save_path, $name; + $directory = opendir($session_save_path."/"); + $length = strlen(SESSION_FILE_PREFIX); + while (($file = readdir($directory)) !== FALSE) { + $qualified = ($session_save_path."/".$file); + if (is_file($qualified) === TRUE) { + if (substr($file, 0, $length) === SESSION_FILE_PREFIX) { + unlink($qualified); + } + } + } + closedir($directory); + return true; +} + +?> + diff --git a/ext/session/tests/session_cache_expire_basic.phpt b/ext/session/tests/session_cache_expire_basic.phpt new file mode 100644 index 0000000000..7166485937 --- /dev/null +++ b/ext/session/tests/session_cache_expire_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_cache_expire() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : basic functionality ***\n"; + +var_dump(session_cache_expire()); +var_dump(session_cache_expire(1234567890)); +var_dump(session_cache_expire(180)); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(session_destroy()); +var_dump(session_cache_expire()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : basic functionality *** +int(180) +int(180) +int(1234567890) +bool(true) +int(180) +bool(true) +int(180) +Done + diff --git a/ext/session/tests/session_cache_expire_error.phpt b/ext/session/tests/session_cache_expire_error.phpt new file mode 100644 index 0000000000..486ba787e5 --- /dev/null +++ b/ext/session/tests/session_cache_expire_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_cache_expire() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : error 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_cache_expire($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : error functionality *** + +-- Iteration 1 -- +int(180) + +-- Iteration 2 -- +int(0) + +-- Iteration 3 -- +int(1) + +-- Iteration 4 -- +int(12345) + +-- Iteration 5 -- +int(-2345) + +-- Iteration 6 -- +int(10) + +-- Iteration 7 -- +int(-10) + +-- Iteration 8 -- +int(%s) + +-- Iteration 9 -- +int(1) + +-- Iteration 10 -- +int(0) + +-- Iteration 11 -- +int(0) + +-- Iteration 12 -- +int(0) + +-- Iteration 13 -- +int(1) + +-- Iteration 14 -- +int(0) + +-- Iteration 15 -- +int(1) + +-- Iteration 16 -- +int(0) + +-- Iteration 17 -- +int(0) + +-- Iteration 18 -- +int(0) + +-- Iteration 19 -- +int(0) + +-- Iteration 20 -- +int(0) + +-- Iteration 21 -- +int(0) + +-- Iteration 22 -- +int(0) + +-- Iteration 23 -- +int(0) + +-- Iteration 24 -- +int(0) +Done + diff --git a/ext/session/tests/session_cache_expire_variation1.phpt b/ext/session/tests/session_cache_expire_variation1.phpt new file mode 100644 index 0000000000..9d0ba27fea --- /dev/null +++ b/ext/session/tests/session_cache_expire_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_cache_expire() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.cache_expire=360 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : variation ***\n"; + +var_dump(session_cache_expire()); +var_dump(session_cache_expire(1234567890)); +var_dump(session_cache_expire(180)); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(session_destroy()); +var_dump(session_cache_expire()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : variation *** +int(360) +int(360) +int(1234567890) +bool(true) +int(180) +bool(true) +int(180) +Done + diff --git a/ext/session/tests/session_cache_expire_variation2.phpt b/ext/session/tests/session_cache_expire_variation2.phpt new file mode 100644 index 0000000000..f17f4711a9 --- /dev/null +++ b/ext/session/tests/session_cache_expire_variation2.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_cache_expire() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : variation ***\n"; + +ini_set("session.cache_expire", 360); +var_dump(session_cache_expire()); +var_dump(session_cache_expire(1234567890)); +var_dump(session_cache_expire(180)); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(session_destroy()); +var_dump(session_cache_expire()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : variation *** +int(360) +int(360) +int(1234567890) +bool(true) +int(180) +bool(true) +int(180) +Done + + diff --git a/ext/session/tests/session_cache_expire_variation3.phpt b/ext/session/tests/session_cache_expire_variation3.phpt new file mode 100644 index 0000000000..c243c1f115 --- /dev/null +++ b/ext/session/tests/session_cache_expire_variation3.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test session_cache_expire() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : variation ***\n"; + +var_dump(ini_get("session.cache_expire")); +var_dump(session_cache_expire()); +var_dump(ini_get("session.cache_expire")); +var_dump(session_cache_expire(1234567890)); +var_dump(ini_get("session.cache_expire")); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(ini_get("session.cache_expire")); +var_dump(session_destroy()); +var_dump(session_cache_expire()); +var_dump(ini_get("session.cache_expire")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : variation *** +string(3) "180" +int(180) +string(3) "180" +int(180) +string(10) "1234567890" +bool(true) +int(1234567890) +string(10) "1234567890" +bool(true) +int(1234567890) +string(10) "1234567890" +Done + diff --git a/ext/session/tests/session_cache_limiter_basic.phpt b/ext/session/tests/session_cache_limiter_basic.phpt new file mode 100644 index 0000000000..d0531878f0 --- /dev/null +++ b/ext/session/tests/session_cache_limiter_basic.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test session_cache_limiter() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : basic functionality ***\n"; + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("public")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("private")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("nocache")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("private_no_expire")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : basic functionality *** +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +bool(true) +string(6) "public" +string(6) "public" +string(7) "private" +bool(true) +bool(true) +string(7) "private" +string(7) "private" +string(7) "nocache" +bool(true) +bool(true) +string(7) "nocache" +string(7) "nocache" +string(17) "private_no_expire" +bool(true) +Done + diff --git a/ext/session/tests/session_cache_limiter_error.phpt b/ext/session/tests/session_cache_limiter_error.phpt new file mode 100644 index 0000000000..98bbbac6d7 --- /dev/null +++ b/ext/session/tests/session_cache_limiter_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_cache_limiter() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : error 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_cache_limiter($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : error functionality *** + +-- Iteration 1 -- +string(7) "nocache" + +-- Iteration 2 -- +string(1) "0" + +-- Iteration 3 -- +string(1) "1" + +-- Iteration 4 -- +string(5) "12345" + +-- Iteration 5 -- +string(5) "-2345" + +-- Iteration 6 -- +string(4) "10.5" + +-- Iteration 7 -- +string(5) "-10.5" + +-- Iteration 8 -- +string(12) "123456789000" + +-- Iteration 9 -- +string(13) "1.23456789E-9" + +-- Iteration 10 -- +string(3) "0.5" + +-- Iteration 11 -- +string(0) "" + +-- Iteration 12 -- +string(0) "" + +-- Iteration 13 -- +string(1) "1" + +-- Iteration 14 -- +string(0) "" + +-- Iteration 15 -- +string(1) "1" + +-- Iteration 16 -- +string(0) "" + +-- Iteration 17 -- +string(0) "" + +-- Iteration 18 -- +string(0) "" + +-- Iteration 19 -- +string(7) "Nothing" + +-- Iteration 20 -- +string(7) "Nothing" + +-- Iteration 21 -- +string(12) "Hello World!" + +-- Iteration 22 -- +string(12) "Hello World!" + +-- Iteration 23 -- +string(0) "" + +-- Iteration 24 -- +string(0) "" +Done + diff --git a/ext/session/tests/session_cache_limiter_variation1.phpt b/ext/session/tests/session_cache_limiter_variation1.phpt new file mode 100644 index 0000000000..7c6e71eb81 --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_cache_limiter() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.cache_limiter=nocache +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : variation ***\n"; + +var_dump(session_cache_limiter()); +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("public")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); +var_dump(session_cache_limiter()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : variation *** +string(7) "nocache" +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +string(6) "public" +Done + diff --git a/ext/session/tests/session_cache_limiter_variation2.phpt b/ext/session/tests/session_cache_limiter_variation2.phpt new file mode 100644 index 0000000000..b6d97a3dda --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation2.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_cache_limiter() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : variation ***\n"; + +ini_set("session.cache_limiter", "nocache"); +var_dump(session_cache_limiter()); +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("public")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); +var_dump(session_cache_limiter()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : variation *** +string(7) "nocache" +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +string(6) "public" +Done + diff --git a/ext/session/tests/session_cache_limiter_variation3.phpt b/ext/session/tests/session_cache_limiter_variation3.phpt new file mode 100644 index 0000000000..7aab95b24e --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation3.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_cache_limiter() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : variation ***\n"; + +var_dump(ini_get("session.cache_limiter")); +var_dump(session_start()); +var_dump(ini_get("session.cache_limiter")); +var_dump(session_cache_limiter("public")); +var_dump(ini_get("session.cache_limiter")); +var_dump(session_destroy()); +var_dump(ini_get("session.cache_limiter")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : variation *** +string(7) "nocache" +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +string(6) "public" +Done + diff --git a/ext/session/tests/session_commit_basic.phpt b/ext/session/tests/session_commit_basic.phpt new file mode 100644 index 0000000000..c20db10933 --- /dev/null +++ b/ext/session/tests/session_commit_basic.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test session_commit() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : basic functionality ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_commit()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : basic functionality *** +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_commit_error.phpt b/ext/session/tests/session_commit_error.phpt new file mode 100644 index 0000000000..b867572ebc --- /dev/null +++ b/ext/session/tests/session_commit_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_commit() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : error 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_commit($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : error functionality *** + +-- Iteration 1 -- +NULL + +-- Iteration 2 -- +NULL + +-- Iteration 3 -- +NULL + +-- Iteration 4 -- +NULL + +-- Iteration 5 -- +NULL + +-- Iteration 6 -- +NULL + +-- Iteration 7 -- +NULL + +-- Iteration 8 -- +NULL + +-- Iteration 9 -- +NULL + +-- Iteration 10 -- +NULL + +-- Iteration 11 -- +NULL + +-- Iteration 12 -- +NULL + +-- Iteration 13 -- +NULL + +-- Iteration 14 -- +NULL + +-- Iteration 15 -- +NULL + +-- Iteration 16 -- +NULL + +-- Iteration 17 -- +NULL + +-- Iteration 18 -- +NULL + +-- Iteration 19 -- +NULL + +-- Iteration 20 -- +NULL + +-- Iteration 21 -- +NULL + +-- Iteration 22 -- +NULL + +-- Iteration 23 -- +NULL + +-- Iteration 24 -- +NULL +Done + diff --git a/ext/session/tests/session_commit_variation1.phpt b/ext/session/tests/session_commit_variation1.phpt new file mode 100644 index 0000000000..81240dac82 --- /dev/null +++ b/ext/session/tests/session_commit_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_commit() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_commit()); +var_dump(session_commit()); +var_dump(session_commit()); +var_dump(session_commit()); +var_dump(session_commit()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : variation *** +bool(true) +NULL +NULL +NULL +NULL +NULL +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_commit_variation2.phpt b/ext/session/tests/session_commit_variation2.phpt new file mode 100644 index 0000000000..b38885a8d9 --- /dev/null +++ b/ext/session/tests/session_commit_variation2.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test session_commit() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_commit()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_commit()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_commit()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : variation *** +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_commit_variation3.phpt b/ext/session/tests/session_commit_variation3.phpt new file mode 100644 index 0000000000..4cee2f4d58 --- /dev/null +++ b/ext/session/tests/session_commit_variation3.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.auto_start=1 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : variation ***\n"; + +var_dump($_SESSION); +var_dump(session_commit()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : variation *** +array(0) { +} +NULL +array(0) { +} +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_commit_variation4.phpt b/ext/session/tests/session_commit_variation4.phpt new file mode 100644 index 0000000000..57f42539d2 --- /dev/null +++ b/ext/session/tests/session_commit_variation4.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test session_commit() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : variation ***\n"; + +var_dump(session_id("test")); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_commit()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_commit()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_commit()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : variation *** +string(0) "" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_decode_basic.phpt b/ext/session/tests/session_decode_basic.phpt new file mode 100644 index 0000000000..f8aa24305a --- /dev/null +++ b/ext/session/tests/session_decode_basic.phpt @@ -0,0 +1,273 @@ +--TEST-- +Test session_decode() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : basic functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +var_dump(session_start()); +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + $_SESSION["data"] = $input; + $encoded = session_encode(); + var_dump(session_decode($encoded)); + var_dump($_SESSION); + $iterator++; +}; + +var_dump(session_destroy()); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : basic functionality *** +bool(true) + +-- Iteration 1 -- +bool(true) +array(1) { + ["data"]=> + int(0) +} + +-- Iteration 2 -- +bool(true) +array(1) { + ["data"]=> + int(1) +} + +-- Iteration 3 -- +bool(true) +array(1) { + ["data"]=> + int(12345) +} + +-- Iteration 4 -- +bool(true) +array(1) { + ["data"]=> + int(-2345) +} + +-- Iteration 5 -- +bool(true) +array(1) { + ["data"]=> + float(10.5) +} + +-- Iteration 6 -- +bool(true) +array(1) { + ["data"]=> + float(-10.5) +} + +-- Iteration 7 -- +bool(true) +array(1) { + ["data"]=> + float(123456789000) +} + +-- Iteration 8 -- +bool(true) +array(1) { + ["data"]=> + float(1.23456789E-9) +} + +-- Iteration 9 -- +bool(true) +array(1) { + ["data"]=> + float(0.5) +} + +-- Iteration 10 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 11 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 12 -- +bool(true) +array(1) { + ["data"]=> + bool(true) +} + +-- Iteration 13 -- +bool(true) +array(1) { + ["data"]=> + bool(false) +} + +-- Iteration 14 -- +bool(true) +array(1) { + ["data"]=> + bool(true) +} + +-- Iteration 15 -- +bool(true) +array(1) { + ["data"]=> + bool(false) +} + +-- Iteration 16 -- +bool(true) +array(1) { + ["data"]=> + string(0) "" +} + +-- Iteration 17 -- +bool(true) +array(1) { + ["data"]=> + string(0) "" +} + +-- Iteration 18 -- +bool(true) +array(1) { + ["data"]=> + string(7) "Nothing" +} + +-- Iteration 19 -- +bool(true) +array(1) { + ["data"]=> + string(7) "Nothing" +} + +-- Iteration 20 -- +bool(true) +array(1) { + ["data"]=> + string(12) "Hello World!" +} + +-- Iteration 21 -- +bool(true) +array(1) { + ["data"]=> + object(classA)#2 (0) { + } +} + +-- Iteration 22 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 23 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 24 -- +bool(true) +array(1) { + ["data"]=> + int(0) +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_error.phpt b/ext/session/tests/session_decode_error.phpt new file mode 100644 index 0000000000..416d741169 --- /dev/null +++ b/ext/session/tests/session_decode_error.phpt @@ -0,0 +1,222 @@ +--TEST-- +Test session_decode() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : error 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_decode($input)); + var_dump($_SESSION); + $iterator++; +}; + +var_dump(session_destroy()); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : error functionality *** +bool(true) + +-- Iteration 1 -- +bool(true) +array(0) { +} + +-- Iteration 2 -- +bool(true) +array(0) { +} + +-- Iteration 3 -- +bool(true) +array(0) { +} + +-- Iteration 4 -- +bool(true) +array(0) { +} + +-- Iteration 5 -- +bool(true) +array(0) { +} + +-- Iteration 6 -- +bool(true) +array(0) { +} + +-- Iteration 7 -- +bool(true) +array(0) { +} + +-- Iteration 8 -- +bool(true) +array(0) { +} + +-- Iteration 9 -- +bool(true) +array(0) { +} + +-- Iteration 10 -- +bool(true) +array(0) { +} + +-- Iteration 11 -- +bool(true) +array(0) { +} + +-- Iteration 12 -- +bool(true) +array(0) { +} + +-- Iteration 13 -- +bool(true) +array(0) { +} + +-- Iteration 14 -- +bool(true) +array(0) { +} + +-- Iteration 15 -- +bool(true) +array(0) { +} + +-- Iteration 16 -- +bool(true) +array(0) { +} + +-- Iteration 17 -- +bool(true) +array(0) { +} + +-- Iteration 18 -- +bool(true) +array(0) { +} + +-- Iteration 19 -- +bool(true) +array(0) { +} + +-- Iteration 20 -- +bool(true) +array(0) { +} + +-- Iteration 21 -- +bool(true) +array(0) { +} + +-- Iteration 22 -- +bool(true) +array(0) { +} + +-- Iteration 23 -- +bool(true) +array(0) { +} + +-- Iteration 24 -- +bool(true) +array(0) { +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_error2.phpt b/ext/session/tests/session_decode_error2.phpt new file mode 100644 index 0000000000..4160f87855 --- /dev/null +++ b/ext/session/tests/session_decode_error2.phpt @@ -0,0 +1,615 @@ +--TEST-- +Test session_decode() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : error functionality ***\n"; +$data = "foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;"; + +var_dump(session_start()); +for($index = 0; $index < strlen($data); $index++) { + echo "\n-- Iteration $index --\n"; + $encoded = substr($data, 0, $index); + var_dump(session_decode($encoded)); + var_dump($_SESSION); +}; + +var_dump(session_destroy()); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : error functionality *** +bool(true) + +-- Iteration 0 -- +bool(true) +array(0) { +} + +-- Iteration 1 -- +bool(true) +array(0) { +} + +-- Iteration 2 -- +bool(true) +array(0) { +} + +-- Iteration 3 -- +bool(true) +array(0) { +} + +-- Iteration 4 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 5 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 6 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 7 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 8 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 9 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 10 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 11 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 12 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 13 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 14 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 15 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 16 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 17 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 18 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 19 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 20 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 21 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 22 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 23 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 24 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 25 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 26 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 27 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 28 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 29 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 30 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 31 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 32 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 33 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 34 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 35 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 36 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 37 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 38 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 39 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 40 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 41 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 42 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 43 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 44 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 45 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 46 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 47 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 48 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} + +-- Iteration 49 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} + +-- Iteration 50 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} + +-- Iteration 51 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_variation1.phpt b/ext/session/tests/session_decode_variation1.phpt new file mode 100644 index 0000000000..b2d06b1abb --- /dev/null +++ b/ext/session/tests/session_decode_variation1.phpt @@ -0,0 +1,189 @@ +--TEST-- +Test session_decode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : variation *** +bool(true) +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_variation2.phpt b/ext/session/tests/session_decode_variation2.phpt new file mode 100644 index 0000000000..1a9b687900 --- /dev/null +++ b/ext/session/tests/session_decode_variation2.phpt @@ -0,0 +1,78 @@ +--TEST-- +Test session_decode() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +$_SESSION["foo"] = 1234567890; +$_SESSION["bar"] = "Hello World!"; +$_SESSION["guff"] = 123.456; +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : variation *** +bool(true) +array(0) { +} +array(3) { + ["foo"]=> + int(1234567890) + ["bar"]=> + string(12) "Hello World!" + ["guff"]=> + float(123.456) +} +bool(true) +array(4) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["bar"]=> + string(12) "Hello World!" + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +Done + diff --git a/ext/session/tests/session_destroy_error.phpt b/ext/session/tests/session_destroy_error.phpt new file mode 100644 index 0000000000..c68d33ebd5 --- /dev/null +++ b/ext/session/tests/session_destroy_error.phpt @@ -0,0 +1,218 @@ +--TEST-- +Test session_destroy() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_destroy(void) + * Description : Destroys all data registered to a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_destroy() : error 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_destroy($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_destroy() : error functionality *** + +-- Iteration 1 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL +Done + diff --git a/ext/session/tests/session_destroy_variation1.phpt b/ext/session/tests/session_destroy_variation1.phpt new file mode 100644 index 0000000000..fdbdf08c57 --- /dev/null +++ b/ext/session/tests/session_destroy_variation1.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test session_destroy() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_destroy(void) + * Description : Destroys all data registered to a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_destroy() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_destroy()); +var_dump(session_destroy()); +var_dump(session_destroy()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_destroy() : variation *** +bool(true) +bool(true) + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) +Done + diff --git a/ext/session/tests/session_destroy_variation2.phpt b/ext/session/tests/session_destroy_variation2.phpt new file mode 100644 index 0000000000..c72c65bac9 --- /dev/null +++ b/ext/session/tests/session_destroy_variation2.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test session_destroy() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_destroy(void) + * Description : Destroys all data registered to a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_destroy() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_destroy() : variation *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_destroy_variation3.phpt b/ext/session/tests/session_destroy_variation3.phpt new file mode 100644 index 0000000000..b63c17e392 --- /dev/null +++ b/ext/session/tests/session_destroy_variation3.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_destroy() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_destroy(void) + * Description : Destroys all data registered to a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_destroy() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_destroy() : variation *** +bool(true) +string(%d) "%s" +bool(true) +string(0) "" +bool(true) +string(%d) "%s" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_encode_basic.phpt b/ext/session/tests/session_encode_basic.phpt new file mode 100644 index 0000000000..f74bddd9ca --- /dev/null +++ b/ext/session/tests/session_encode_basic.phpt @@ -0,0 +1,174 @@ +--TEST-- +Test session_encode() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : 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"; + $_SESSION["data"] = $input; + var_dump(session_encode()); + $iterator++; +}; + +var_dump(session_destroy()); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : basic functionality *** +bool(true) + +-- Iteration 1 -- +string(9) "data|i:0;" + +-- Iteration 2 -- +string(9) "data|i:1;" + +-- Iteration 3 -- +string(13) "data|i:12345;" + +-- Iteration 4 -- +string(13) "data|i:-2345;" + +-- Iteration 5 -- +string(12) "data|d:10.5;" + +-- Iteration 6 -- +string(13) "data|d:-10.5;" + +-- Iteration 7 -- +string(20) "data|d:123456789000;" + +-- Iteration 8 -- +string(86) "data|d:1.2345678899999999145113427164344339914681114578343112953007221221923828125E-9;" + +-- Iteration 9 -- +string(11) "data|d:0.5;" + +-- Iteration 10 -- +string(7) "data|N;" + +-- Iteration 11 -- +string(7) "data|N;" + +-- Iteration 12 -- +string(9) "data|b:1;" + +-- Iteration 13 -- +string(9) "data|b:0;" + +-- Iteration 14 -- +string(9) "data|b:1;" + +-- Iteration 15 -- +string(9) "data|b:0;" + +-- Iteration 16 -- +string(12) "data|s:0:"";" + +-- Iteration 17 -- +string(12) "data|s:0:"";" + +-- Iteration 18 -- +string(19) "data|s:7:"Nothing";" + +-- Iteration 19 -- +string(19) "data|s:7:"Nothing";" + +-- Iteration 20 -- +string(25) "data|s:12:"Hello World!";" + +-- Iteration 21 -- +string(22) "data|O:6:"classA":0:{}" + +-- Iteration 22 -- +string(7) "data|N;" + +-- Iteration 23 -- +string(7) "data|N;" + +-- Iteration 24 -- +string(9) "data|i:0;" +bool(true) +Done + diff --git a/ext/session/tests/session_encode_error.phpt b/ext/session/tests/session_encode_error.phpt new file mode 100644 index 0000000000..ce4fd383bf --- /dev/null +++ b/ext/session/tests/session_encode_error.phpt @@ -0,0 +1,220 @@ +--TEST-- +Test session_encode() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : 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 +); + +session_start(); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_encode($input)); + $iterator++; +}; + +session_destroy(); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : basic functionality *** + +-- Iteration 1 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL +Done + diff --git a/ext/session/tests/session_encode_error2.phpt b/ext/session/tests/session_encode_error2.phpt new file mode 100644 index 0000000000..6a019b203d --- /dev/null +++ b/ext/session/tests/session_encode_error2.phpt @@ -0,0 +1,251 @@ +--TEST-- +Test session_encode() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : error 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()); + $_SESSION[$input] = "Hello World!"; + var_dump(session_encode()); + var_dump(session_destroy()); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : error functionality *** + +-- Iteration 1 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) + +-- Iteration 2 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 1. in %s on line %d +bool(false) +bool(true) + +-- Iteration 3 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 12345. in %s on line %d +bool(false) +bool(true) + +-- Iteration 4 -- +bool(true) + +Notice: session_encode(): Skipping numeric key -2345. in %s on line %d +bool(false) +bool(true) + +-- Iteration 5 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 10. in %s on line %d +bool(false) +bool(true) + +-- Iteration 6 -- +bool(true) + +Notice: session_encode(): Skipping numeric key -10. in %s on line %d +bool(false) +bool(true) + +-- Iteration 7 -- +bool(true) + +Notice: session_encode(): Skipping numeric key %s. in %s on line %d +bool(false) +bool(true) + +-- Iteration 8 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) + +-- Iteration 9 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) + +-- Iteration 10 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 11 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 12 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 1. in %s on line %d +bool(false) +bool(true) + +-- Iteration 13 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) + +-- Iteration 14 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 1. in %s on line %d +bool(false) +bool(true) + +-- Iteration 15 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) + +-- Iteration 16 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 17 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 18 -- +bool(true) +string(28) "Nothing|s:12:"Hello World!";" +bool(true) + +-- Iteration 19 -- +bool(true) +string(28) "Nothing|s:12:"Hello World!";" +bool(true) + +-- Iteration 20 -- +bool(true) +string(33) "Hello World!|s:12:"Hello World!";" +bool(true) + +-- Iteration 21 -- +bool(true) + +Warning: Illegal offset type in %s on line 82 +bool(false) +bool(true) + +-- Iteration 22 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 23 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 24 -- +bool(true) + +Strict Standards: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d + +Notice: session_encode(): Skipping numeric key %d. in %s on line %d +bool(false) +bool(true) +Done diff --git a/ext/session/tests/session_encode_variation1.phpt b/ext/session/tests/session_encode_variation1.phpt new file mode 100644 index 0000000000..9c9f64b436 --- /dev/null +++ b/ext/session/tests/session_encode_variation1.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_encode()); +var_dump(session_start()); +var_dump(session_encode()); +var_dump(session_write_close()); +var_dump(session_encode()); +var_dump(session_start()); +var_dump(session_encode()); +var_dump(session_destroy()); +var_dump(session_encode()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** + +Warning: session_encode(): Cannot encode non-existent session. in %s on line %d +bool(false) +bool(true) +bool(false) +NULL +bool(false) +bool(true) +bool(false) +bool(true) + +Warning: session_encode(): Cannot encode non-existent session. in %s on line %d +bool(false) +Done + diff --git a/ext/session/tests/session_encode_variation2.phpt b/ext/session/tests/session_encode_variation2.phpt new file mode 100644 index 0000000000..7ec8a63afd --- /dev/null +++ b/ext/session/tests/session_encode_variation2.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.auto_start=1 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_encode()); +var_dump(session_destroy()); +var_dump(session_encode()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(false) +bool(true) + +Warning: session_encode(): Cannot encode non-existent session. in %s on line %d +bool(false) +Done + diff --git a/ext/session/tests/session_encode_variation3.phpt b/ext/session/tests/session_encode_variation3.phpt new file mode 100644 index 0000000000..40bb44de54 --- /dev/null +++ b/ext/session/tests/session_encode_variation3.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); + +$array = array(1,2,3); +$_SESSION["foo"] = &$array; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(34) "foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}" +bool(true) +Done + diff --git a/ext/session/tests/session_encode_variation4.phpt b/ext/session/tests/session_encode_variation4.phpt new file mode 100644 index 0000000000..d85b9a48ad --- /dev/null +++ b/ext/session/tests/session_encode_variation4.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); + +$array = array(1,2,3); +$_SESSION["foo"] = &$array; +$_SESSION["guff"] = &$array; +$_SESSION["blah"] = &$array; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(52) "foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;" +bool(true) +Done + diff --git a/ext/session/tests/session_encode_variation5.phpt b/ext/session/tests/session_encode_variation5.phpt new file mode 100644 index 0000000000..fc408847bf --- /dev/null +++ b/ext/session/tests/session_encode_variation5.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); + +$array = array(1,2,3); +$array["foo"] = &$array; +$array["blah"] = &$array; +$_SESSION["data"] = &$array; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(64) "data|a:5:{i:0;i:1;i:1;i:2;i:2;i:3;s:3:"foo";R:1;s:4:"blah";R:1;}" +bool(true) +Done + diff --git a/ext/session/tests/session_encode_variation6.phpt b/ext/session/tests/session_encode_variation6.phpt new file mode 100644 index 0000000000..4280473821 --- /dev/null +++ b/ext/session/tests/session_encode_variation6.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); +$_SESSION[] = 1234567890; +var_dump(session_encode()); +var_dump(session_destroy()); +var_dump(session_start()); +$_SESSION[1234567890] = "Hello World!"; +var_dump(session_encode()); +var_dump(session_destroy()); +var_dump(session_start()); +$_SESSION[-1234567890] = 1234567890; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) +bool(true) + +Notice: session_encode(): Skipping numeric key 1234567890. in %s on line %d +bool(false) +bool(true) +bool(true) + +Notice: session_encode(): Skipping numeric key -1234567890. in %s on line %d +bool(false) +bool(true) +Done + diff --git a/ext/session/tests/session_get_cookie_params_basic.phpt b/ext/session/tests/session_get_cookie_params_basic.phpt new file mode 100644 index 0000000000..5cadc7947d --- /dev/null +++ b/ext/session/tests/session_get_cookie_params_basic.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test session_get_cookie_params() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : array session_get_cookie_params(void) + * Description : Get the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_get_cookie_params() : basic functionality ***\n"; + +var_dump(session_get_cookie_params()); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, FALSE)); +var_dump(session_get_cookie_params()); +var_dump(session_set_cookie_params(1234567890, "/guff", "foo", TRUE, TRUE)); +var_dump(session_get_cookie_params()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_get_cookie_params() : basic functionality *** +array(5) { + ["lifetime"]=> + int(0) + ["path"]=> + string(1) "/" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +NULL +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(4) "blah" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +NULL +array(5) { + ["lifetime"]=> + int(1234567890) + ["path"]=> + string(5) "/guff" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(true) + ["httponly"]=> + bool(true) +} +Done + diff --git a/ext/session/tests/session_get_cookie_params_error.phpt b/ext/session/tests/session_get_cookie_params_error.phpt new file mode 100644 index 0000000000..529ea6b116 --- /dev/null +++ b/ext/session/tests/session_get_cookie_params_error.phpt @@ -0,0 +1,217 @@ +--TEST-- +Test session_get_cookie_params() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : array session_get_cookie_params(void) + * Description : Get the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_get_cookie_params() : error 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_get_cookie_params($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_get_cookie_params() : error functionality *** + +-- Iteration 1 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL +Done + diff --git a/ext/session/tests/session_get_cookie_params_variation1.phpt b/ext/session/tests/session_get_cookie_params_variation1.phpt new file mode 100644 index 0000000000..0ab4eec88f --- /dev/null +++ b/ext/session/tests/session_get_cookie_params_variation1.phpt @@ -0,0 +1,108 @@ +--TEST-- +Test session_get_cookie_params() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : array session_get_cookie_params(void) + * Description : Get the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_get_cookie_params() : variation ***\n"; + +var_dump(session_get_cookie_params()); +ini_set("session.cookie_lifetime", 3600); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_path", "/path"); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_domain", "foo"); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_secure", TRUE); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_httponly", TRUE); +var_dump(session_get_cookie_params()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_get_cookie_params() : variation *** +array(5) { + ["lifetime"]=> + int(0) + ["path"]=> + string(1) "/" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(1) "/" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(true) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(true) + ["httponly"]=> + bool(true) +} +Done + diff --git a/ext/session/tests/session_id_basic.phpt b/ext/session/tests/session_id_basic.phpt new file mode 100644 index 0000000000..5cb13c25ea --- /dev/null +++ b/ext/session/tests/session_id_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_id() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : basic functionality ***\n"; + +var_dump(session_id()); +var_dump(session_id("test")); +var_dump(session_id()); +var_dump(session_id("1234567890")); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : basic functionality *** +string(0) "" +string(0) "" +string(4) "test" +string(4) "test" +string(10) "1234567890" +bool(true) +string(10) "1234567890" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_id_error.phpt b/ext/session/tests/session_id_error.phpt new file mode 100644 index 0000000000..07c4ed7025 --- /dev/null +++ b/ext/session/tests/session_id_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_id() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : error 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_id($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : error functionality *** + +-- Iteration 1 -- +string(0) "" + +-- Iteration 2 -- +string(1) "0" + +-- Iteration 3 -- +string(1) "1" + +-- Iteration 4 -- +string(5) "12345" + +-- Iteration 5 -- +string(5) "-2345" + +-- Iteration 6 -- +string(4) "10.5" + +-- Iteration 7 -- +string(5) "-10.5" + +-- Iteration 8 -- +string(12) "123456789000" + +-- Iteration 9 -- +string(13) "1.23456789E-9" + +-- Iteration 10 -- +string(3) "0.5" + +-- Iteration 11 -- +string(0) "" + +-- Iteration 12 -- +string(0) "" + +-- Iteration 13 -- +string(1) "1" + +-- Iteration 14 -- +string(0) "" + +-- Iteration 15 -- +string(1) "1" + +-- Iteration 16 -- +string(0) "" + +-- Iteration 17 -- +string(0) "" + +-- Iteration 18 -- +string(0) "" + +-- Iteration 19 -- +string(7) "Nothing" + +-- Iteration 20 -- +string(7) "Nothing" + +-- Iteration 21 -- +string(12) "Hello World!" + +-- Iteration 22 -- +string(12) "Hello World!" + +-- Iteration 23 -- +string(0) "" + +-- Iteration 24 -- +string(0) "" +Done + diff --git a/ext/session/tests/session_id_error2.phpt b/ext/session/tests/session_id_error2.phpt new file mode 100644 index 0000000000..05284e797b --- /dev/null +++ b/ext/session/tests/session_id_error2.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_id() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : error functionality ***\n"; + +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id("test")); +var_dump(session_id()); +var_dump(session_id("1234567890")); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : error functionality *** +string(0) "" +bool(true) +string(%d) "%s" +string(4) "test" +string(4) "test" +string(10) "1234567890" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_id_error3.phpt b/ext/session/tests/session_id_error3.phpt new file mode 100644 index 0000000000..fc291389d9 --- /dev/null +++ b/ext/session/tests/session_id_error3.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test session_id() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : error functionality ***\n"; + +@session_start(); +var_dump(session_id()); +var_dump(session_id("!")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("?><")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("£$%^&*()")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("\r\n")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("\0")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("¬``@~:{>?><,./[]+--")); +var_dump(session_id()); +@session_destroy(); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : error functionality *** +string(%d) "%s" +string(%d) "%s" +string(1) "!" +string(%d) "%s" +string(%d) "%s" +string(3) "?><" +string(%d) "%s" +string(%d) "%s" +string(8) "£$%^&*()" +string(%d) "%s" +string(%d) "%s" +string(2) " +" +string(%d) "%s" +string(%d) "%s" +string(0) "" +string(%d) "%s" +string(%d) "%s" +string(19) "¬``@~:{>?><,./[]+--" +Done + diff --git a/ext/session/tests/session_is_registered_basic.phpt b/ext/session/tests/session_is_registered_basic.phpt new file mode 100644 index 0000000000..080dd0bcc3 --- /dev/null +++ b/ext/session/tests/session_is_registered_basic.phpt @@ -0,0 +1,269 @@ +--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) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 2 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 3 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 4 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 5 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 6 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 7 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 8 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 9 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 10 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 11 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 12 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 13 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 14 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 15 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 16 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 17 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 18 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 19 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 20 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 21 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 22 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 23 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 24 -- +bool(true) +bool(false) +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 new file mode 100644 index 0000000000..f92de82973 --- /dev/null +++ b/ext/session/tests/session_is_registered_variation1.phpt @@ -0,0 +1,108 @@ +--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) { +} + +Notice: Array to string conversion in %s on line %d +bool(false) +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 new file mode 100644 index 0000000000..582b947afc --- /dev/null +++ b/ext/session/tests/session_is_registered_variation2.phpt @@ -0,0 +1,60 @@ +--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 *** +bool(false) +bool(true) +bool(false) +array(0) { +} +bool(true) +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +bool(true) +bool(true) +bool(false) +array(0) { +} +bool(true) +bool(false) +array(0) { +} +bool(false) +Done + diff --git a/ext/session/tests/session_is_registered_variation3.phpt b/ext/session/tests/session_is_registered_variation3.phpt new file mode 100644 index 0000000000..10f7ffe491 --- /dev/null +++ b/ext/session/tests/session_is_registered_variation3.phpt @@ -0,0 +1,59 @@ +--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 *** +bool(false) +bool(true) +bool(false) +array(0) { +} +bool(false) +array(1) { + ["foo"]=> + &string(12) "Hello World!" +} +bool(true) +bool(true) +bool(false) +array(0) { +} +bool(true) +bool(false) +array(0) { +} +Done + diff --git a/ext/session/tests/session_module_name_basic.phpt b/ext/session/tests/session_module_name_basic.phpt new file mode 100644 index 0000000000..2daf6fc620 --- /dev/null +++ b/ext/session/tests/session_module_name_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_module_name() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : basic functionality ***\n"; +var_dump(session_module_name("files")); +var_dump(session_module_name()); +var_dump(session_start()); +var_dump(session_module_name()); +var_dump(session_destroy()); +var_dump(session_module_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : basic functionality *** +string(%d) "%s" +string(5) "files" +bool(true) +string(5) "files" +bool(true) +string(5) "files" +Done diff --git a/ext/session/tests/session_module_name_error.phpt b/ext/session/tests/session_module_name_error.phpt new file mode 100644 index 0000000000..84cfde499c --- /dev/null +++ b/ext/session/tests/session_module_name_error.phpt @@ -0,0 +1,216 @@ +--TEST-- +Test session_module_name() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : error 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_module_name($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : error functionality *** + +-- Iteration 1 -- + +Warning: session_module_name(): Cannot find named PHP session module (0) in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: session_module_name(): Cannot find named PHP session module (1) in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: session_module_name(): Cannot find named PHP session module (12345) in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: session_module_name(): Cannot find named PHP session module (-2345) in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: session_module_name(): Cannot find named PHP session module (10.5) in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: session_module_name(): Cannot find named PHP session module (-10.5) in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: session_module_name(): Cannot find named PHP session module (123456789000) in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: session_module_name(): Cannot find named PHP session module (1.23456789E-9) in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: session_module_name(): Cannot find named PHP session module (0.5) in %s on line %d +bool(false) + +-- Iteration 10 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: session_module_name(): Cannot find named PHP session module (1) in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: session_module_name(): Cannot find named PHP session module (1) in %s on line %d +bool(false) + +-- Iteration 15 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: session_module_name(): Cannot find named PHP session module (Nothing) in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: session_module_name(): Cannot find named PHP session module (Nothing) in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: session_module_name(): Cannot find named PHP session module (Hello World!) in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: session_module_name(): Cannot find named PHP session module (Hello World!) in %s on line %d +bool(false) + +-- Iteration 22 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 23 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 24 -- + +Warning: session_module_name(): Cannot find named PHP session module (Resource id #%d) in %s on line %d +bool(false) +Done diff --git a/ext/session/tests/session_module_name_variation1.phpt b/ext/session/tests/session_module_name_variation1.phpt new file mode 100644 index 0000000000..2034b7eff1 --- /dev/null +++ b/ext/session/tests/session_module_name_variation1.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_module_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : variation ***\n"; +var_dump(session_module_name("blah")); +var_dump(session_start()); +var_dump(session_module_name()); +var_dump(session_destroy()); +var_dump(session_module_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : variation *** + +Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d +bool(false) +bool(true) +string(%d) "%s" +bool(true) +string(%d) "%s" +Done diff --git a/ext/session/tests/session_module_name_variation2.phpt b/ext/session/tests/session_module_name_variation2.phpt new file mode 100644 index 0000000000..aa7b33c767 --- /dev/null +++ b/ext/session/tests/session_module_name_variation2.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test session_module_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : variation ***\n"; + +function open($save_path, $session_name) { } +function close() { } +function read($id) { } +function write($id, $session_data) { } +function destroy($id) { } +function gc($maxlifetime) { } + +var_dump(session_module_name("files")); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +var_dump(session_module_name()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : variation *** +string(%d) "%s" +string(4) "user" diff --git a/ext/session/tests/session_module_name_variation3.phpt b/ext/session/tests/session_module_name_variation3.phpt new file mode 100644 index 0000000000..06f5ccc058 --- /dev/null +++ b/ext/session/tests/session_module_name_variation3.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test session_module_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : variation ***\n"; +function open($save_path, $session_name) { + throw new Exception("Stop...!"); +} + +function close() { } +function read($id) { } +function write($id, $session_data) { } +function destroy($id) { } +function gc($maxlifetime) { } + +var_dump(session_module_name("files")); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +var_dump(session_module_name()); +var_dump(session_start()); +var_dump(session_module_name()); +var_dump(session_destroy()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : variation *** +string(%d) "%s" +string(4) "user" + +Fatal error: Uncaught exception 'Exception' with message 'Stop...!' in %s:%d +Stack trace: +#0 [internal function]: open('', 'PHPSESSID') +#1 %s(%d): session_start() +#2 {main} + thrown in %s on line %d diff --git a/ext/session/tests/session_name_basic.phpt b/ext/session/tests/session_name_basic.phpt new file mode 100644 index 0000000000..2cf7a35cb7 --- /dev/null +++ b/ext/session/tests/session_name_basic.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test session_name() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_name([string $name]) + * Description : Get and/or set the current session name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_name() : error functionality ***\n"; + +var_dump(session_name()); +var_dump(session_name("blah")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_name() : error functionality *** +string(9) "PHPSESSID" +string(9) "PHPSESSID" +bool(true) +string(4) "blah" +bool(true) +string(4) "blah" +Done + diff --git a/ext/session/tests/session_name_error.phpt b/ext/session/tests/session_name_error.phpt new file mode 100644 index 0000000000..967559f484 --- /dev/null +++ b/ext/session/tests/session_name_error.phpt @@ -0,0 +1,169 @@ +--TEST-- +Test session_name() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_name([string $name]) + * Description : Get and/or set the current session name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_name() : error 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_name($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_name() : error functionality *** + +-- Iteration 1 -- +string(9) "PHPSESSID" + +-- Iteration 2 -- +string(1) "0" + +-- Iteration 3 -- +string(1) "1" + +-- Iteration 4 -- +string(5) "12345" + +-- Iteration 5 -- +string(5) "-2345" + +-- Iteration 6 -- +string(4) "10.5" + +-- Iteration 7 -- +string(5) "-10.5" + +-- Iteration 8 -- +string(12) "123456789000" + +-- Iteration 9 -- +string(13) "1.23456789E-9" + +-- Iteration 10 -- +string(3) "0.5" + +-- Iteration 11 -- +string(0) "" + +-- Iteration 12 -- +string(0) "" + +-- Iteration 13 -- +string(1) "1" + +-- Iteration 14 -- +string(0) "" + +-- Iteration 15 -- +string(1) "1" + +-- Iteration 16 -- +string(0) "" + +-- Iteration 17 -- +string(0) "" + +-- Iteration 18 -- +string(0) "" + +-- Iteration 19 -- +string(7) "Nothing" + +-- Iteration 20 -- +string(7) "Nothing" + +-- Iteration 21 -- +string(12) "Hello World!" + +-- Iteration 22 -- +string(12) "Hello World!" + +-- Iteration 23 -- +string(0) "" + +-- Iteration 24 -- +string(0) "" +Done + diff --git a/ext/session/tests/session_name_variation1.phpt b/ext/session/tests/session_name_variation1.phpt new file mode 100644 index 0000000000..83084eabb4 --- /dev/null +++ b/ext/session/tests/session_name_variation1.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test session_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_name([string $name]) + * Description : Get and/or set the current session name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_name() : variation ***\n"; + +var_dump(session_name("\0")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +var_dump(session_name("\t")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +var_dump(session_name("")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_name() : variation *** +string(9) "PHPSESSID" +bool(true) +string(0) "" +bool(true) +string(0) "" +string(0) "" +bool(true) +string(1) " " +bool(true) +string(1) " " +string(1) " " +bool(true) +string(0) "" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_name_variation2.phpt b/ext/session/tests/session_name_variation2.phpt new file mode 100644 index 0000000000..84bfeba740 --- /dev/null +++ b/ext/session/tests/session_name_variation2.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.name=blah +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_name([string $name]) + * Description : Get and/or set the current session name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_name() : variation ***\n"; + +var_dump(session_name()); +var_dump(session_name("blah")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_name() : variation *** +string(4) "blah" +string(4) "blah" +bool(true) +string(4) "blah" +bool(true) +string(4) "blah" +Done + diff --git a/ext/session/tests/session_regenerate_id_basic.phpt b/ext/session/tests/session_regenerate_id_basic.phpt new file mode 100644 index 0000000000..910620a66f --- /dev/null +++ b/ext/session/tests/session_regenerate_id_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_regenerate_id() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_regenerate_id([bool $delete_old_session]) + * Description : Update the current session id with a newly generated one + * Source code : ext/session/session.c + */ + +echo "*** Testing session_regenerate_id() : basic functionality ***\n"; + +var_dump(session_id()); +var_dump(session_regenerate_id()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_regenerate_id()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_regenerate_id()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_regenerate_id() : basic functionality *** +string(0) "" +bool(false) +string(0) "" +bool(true) +bool(true) +string(%d) "%s" +bool(true) +bool(false) +string(0) "" +Done + diff --git a/ext/session/tests/session_regenerate_id_error.phpt b/ext/session/tests/session_regenerate_id_error.phpt new file mode 100644 index 0000000000..9e119f17fb --- /dev/null +++ b/ext/session/tests/session_regenerate_id_error.phpt @@ -0,0 +1,174 @@ +--TEST-- +Test session_regenerate_id() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_regenerate_id([bool $delete_old_session]) + * Description : Update the current session id with a newly generated one + * Source code : ext/session/session.c + */ + +echo "*** Testing session_regenerate_id() : error 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_regenerate_id($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_regenerate_id() : error functionality *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- + +Warning: session_regenerate_id() expects parameter 1 to be boolean, object given in %s on line %d +NULL + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- + +Warning: session_regenerate_id() expects parameter 1 to be boolean, resource given in %s on line %d +NULL +Done + diff --git a/ext/session/tests/session_regenerate_id_variation1.phpt b/ext/session/tests/session_regenerate_id_variation1.phpt new file mode 100644 index 0000000000..95d4a77c8e --- /dev/null +++ b/ext/session/tests/session_regenerate_id_variation1.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_regenerate_id() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_regenerate_id([bool $delete_old_session]) + * Description : Update the current session id with a newly generated one + * Source code : ext/session/session.c + */ + +echo "*** Testing session_regenerate_id() : variation ***\n"; + +var_dump(session_id()); +var_dump(session_regenerate_id(TRUE)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_regenerate_id(TRUE)); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_regenerate_id(TRUE)); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_regenerate_id() : variation *** +string(0) "" +bool(false) +string(0) "" +bool(true) +bool(true) +string(%d) "%s" +bool(true) +bool(false) +string(0) "" +Done + diff --git a/ext/session/tests/session_register_basic.phpt b/ext/session/tests/session_register_basic.phpt new file mode 100644 index 0000000000..75ae97286f --- /dev/null +++ b/ext/session/tests/session_register_basic.phpt @@ -0,0 +1,317 @@ +--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) +bool(true) +array(1) { + ["0"]=> + NULL +} +bool(true) + +-- Iteration 2 -- +bool(true) +bool(true) +array(1) { + ["1"]=> + NULL +} +bool(true) + +-- Iteration 3 -- +bool(true) +bool(true) +array(1) { + ["12345"]=> + NULL +} +bool(true) + +-- Iteration 4 -- +bool(true) +bool(true) +array(1) { + ["-2345"]=> + NULL +} +bool(true) + +-- Iteration 5 -- +bool(true) +bool(true) +array(1) { + ["10.5"]=> + NULL +} +bool(true) + +-- Iteration 6 -- +bool(true) +bool(true) +array(1) { + ["-10.5"]=> + NULL +} +bool(true) + +-- Iteration 7 -- +bool(true) +bool(true) +array(1) { + ["123456789000"]=> + NULL +} +bool(true) + +-- Iteration 8 -- +bool(true) +bool(true) +array(1) { + ["1.23456789E-9"]=> + NULL +} +bool(true) + +-- Iteration 9 -- +bool(true) +bool(true) +array(1) { + ["0.5"]=> + NULL +} +bool(true) + +-- Iteration 10 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 11 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 12 -- +bool(true) +bool(true) +array(1) { + ["1"]=> + NULL +} +bool(true) + +-- Iteration 13 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 14 -- +bool(true) +bool(true) +array(1) { + ["1"]=> + NULL +} +bool(true) + +-- Iteration 15 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 16 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 17 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 18 -- +bool(true) +bool(true) +array(1) { + ["Nothing"]=> + NULL +} +bool(true) + +-- Iteration 19 -- +bool(true) +bool(true) +array(1) { + ["Nothing"]=> + NULL +} +bool(true) + +-- Iteration 20 -- +bool(true) +bool(true) +array(1) { + ["Hello World!"]=> + NULL +} +bool(true) + +-- Iteration 21 -- +bool(true) +bool(true) +array(1) { + ["Hello World!"]=> + NULL +} +bool(true) + +-- Iteration 22 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 23 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 24 -- +bool(true) +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 new file mode 100644 index 0000000000..4f40a095b9 --- /dev/null +++ b/ext/session/tests/session_register_variation1.phpt @@ -0,0 +1,158 @@ +--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) { +} +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 new file mode 100644 index 0000000000..11189c597a --- /dev/null +++ b/ext/session/tests/session_register_variation2.phpt @@ -0,0 +1,40 @@ +--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) { +} +bool(false) +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 new file mode 100644 index 0000000000..7051dea938 --- /dev/null +++ b/ext/session/tests/session_register_variation3.phpt @@ -0,0 +1,45 @@ +--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) { +} +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 new file mode 100644 index 0000000000..384133ee6b --- /dev/null +++ b/ext/session/tests/session_register_variation4.phpt @@ -0,0 +1,46 @@ +--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) { +} +bool(true) +array(1) { + ["foo"]=> + NULL +} +bool(true) +array(1) { + ["foo"]=> + NULL +} +Done + diff --git a/ext/session/tests/session_save_path_basic.phpt b/ext/session/tests/session_save_path_basic.phpt new file mode 100644 index 0000000000..dbb7e63cdc --- /dev/null +++ b/ext/session/tests/session_save_path_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test session_save_path() function : basic functionality +--INI-- +session.gc_probability=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : error functionality ***\n"; + +$directory = dirname(__FILE__); +var_dump(session_save_path()); +var_dump(session_save_path($directory)); +var_dump(session_save_path()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : error functionality *** +string(0) "" +string(0) "" +string(%d) "%s" +Done + diff --git a/ext/session/tests/session_save_path_error.phpt b/ext/session/tests/session_save_path_error.phpt new file mode 100644 index 0000000000..21c37de18f --- /dev/null +++ b/ext/session/tests/session_save_path_error.phpt @@ -0,0 +1,174 @@ +--TEST-- +Test session_save_path() function : error functionality +--INI-- +session.gc_probability=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : error 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 +); + +session_start(); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_save_path($input)); + $iterator++; +}; + +session_destroy(); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : error functionality *** + +-- Iteration 1 -- +string(0) "" + +-- Iteration 2 -- +string(1) "0" + +-- Iteration 3 -- +string(1) "1" + +-- Iteration 4 -- +string(5) "12345" + +-- Iteration 5 -- +string(5) "-2345" + +-- Iteration 6 -- +string(4) "10.5" + +-- Iteration 7 -- +string(5) "-10.5" + +-- Iteration 8 -- +string(12) "123456789000" + +-- Iteration 9 -- +string(13) "1.23456789E-9" + +-- Iteration 10 -- +string(3) "0.5" + +-- Iteration 11 -- +string(0) "" + +-- Iteration 12 -- +string(0) "" + +-- Iteration 13 -- +string(1) "1" + +-- Iteration 14 -- +string(0) "" + +-- Iteration 15 -- +string(1) "1" + +-- Iteration 16 -- +string(0) "" + +-- Iteration 17 -- +string(0) "" + +-- Iteration 18 -- +string(0) "" + +-- Iteration 19 -- +string(7) "Nothing" + +-- Iteration 20 -- +string(7) "Nothing" + +-- Iteration 21 -- +string(12) "Hello World!" + +-- Iteration 22 -- +string(12) "Hello World!" + +-- Iteration 23 -- +string(0) "" + +-- Iteration 24 -- +string(0) "" +Done + diff --git a/ext/session/tests/session_save_path_variation1.phpt b/ext/session/tests/session_save_path_variation1.phpt new file mode 100644 index 0000000000..3b62027492 --- /dev/null +++ b/ext/session/tests/session_save_path_variation1.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test session_save_path() function : variation +--INI-- +session.gc_probability=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; + +$directory = dirname(__FILE__); +var_dump(session_save_path()); +var_dump(session_start()); +var_dump(session_save_path()); +var_dump(session_save_path($directory)); +var_dump(session_save_path()); +var_dump(session_destroy()); +var_dump(session_save_path()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : variation *** +string(0) "" +bool(true) +string(0) "" +string(0) "" +string(%d) "%s" +bool(true) +string(%d) "%s" +Done + diff --git a/ext/session/tests/session_save_path_variation2.phpt b/ext/session/tests/session_save_path_variation2.phpt new file mode 100644 index 0000000000..6b08480312 --- /dev/null +++ b/ext/session/tests/session_save_path_variation2.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_handler=files +session.gc_probability=0 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; + +ini_set("session.save_path", "/blah"); +var_dump(ini_get("session.save_path")); +var_dump(session_start()); +var_dump(ini_get("session.save_path")); +var_dump(session_destroy()); +var_dump(ini_get("session.save_path")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : variation *** +string(5) "/blah" + +Warning: session_start(): open(%s, O_RDWR) failed: No such file or directory (2) in %s on line %d +bool(true) +string(5) "/blah" +bool(true) +string(5) "/blah" +Done diff --git a/ext/session/tests/session_save_path_variation3.phpt b/ext/session/tests/session_save_path_variation3.phpt new file mode 100644 index 0000000000..b064f30183 --- /dev/null +++ b/ext/session/tests/session_save_path_variation3.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_handler=files +session.gc_probability=0 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; + +ini_set("session.save_path", "/blah"); +var_dump(session_save_path()); +var_dump(session_start()); +var_dump(session_save_path()); +var_dump(session_destroy()); +var_dump(session_save_path()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : variation *** +string(5) "/blah" + +Warning: session_start(): open(%s, O_RDWR) failed: No such file or directory (2) in %s on line %d +bool(true) +string(5) "/blah" +bool(true) +string(5) "/blah" +Done diff --git a/ext/session/tests/session_set_cookie_params_basic.phpt b/ext/session/tests/session_set_cookie_params_basic.phpt new file mode 100644 index 0000000000..5055d1c698 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_set_cookie_params() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : basic functionality ***\n"; + +var_dump(session_set_cookie_params(3600)); +var_dump(session_start()); +var_dump(session_set_cookie_params(1800)); +var_dump(session_destroy()); +var_dump(session_set_cookie_params(1234567890)); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : basic functionality *** +NULL +bool(true) +NULL +bool(true) +NULL +Done + diff --git a/ext/session/tests/session_set_cookie_params_error.phpt b/ext/session/tests/session_set_cookie_params_error.phpt new file mode 100644 index 0000000000..389387f6ab --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_error.phpt @@ -0,0 +1,298 @@ +--TEST-- +Test session_set_cookie_params() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : error 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_set_cookie_params($input)); + var_dump(session_set_cookie_params(1234567890, $input)); + var_dump(session_set_cookie_params(1234567890, "blah", $input)); + var_dump(session_set_cookie_params(1234567890, "blah", "foo", $input)); + var_dump(session_set_cookie_params(1234567890, "blah", "foo", TRUE, $input)); + var_dump(session_set_cookie_params(1234567890, "blah", "foo", TRUE, FALSE)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : error functionality *** + +-- Iteration 1 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 2 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 3 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 4 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 5 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 6 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 7 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 8 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 9 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 10 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 11 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 12 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 13 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 14 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 15 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 16 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 17 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 18 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 19 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 20 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 21 -- +NULL +NULL +NULL + +Notice: Object of class classA could not be converted to int in %s on line %d +NULL + +Notice: Object of class classA could not be converted to int in %s on line %d +NULL +NULL + +-- Iteration 22 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 23 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 24 -- +NULL +NULL +NULL +NULL +NULL +NULL +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation1.phpt b/ext/session/tests/session_set_cookie_params_variation1.phpt new file mode 100644 index 0000000000..02b901f3cf --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation1.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_lifetime=3600 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_set_cookie_params(3600)); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_set_cookie_params(1800)); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_set_cookie_params(1234567890)); +var_dump(ini_get("session.cookie_lifetime")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(4) "3600" +NULL +string(4) "3600" +bool(true) +string(4) "3600" +NULL +string(4) "1800" +bool(true) +string(4) "1800" +NULL +string(10) "1234567890" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation2.phpt b/ext/session/tests/session_set_cookie_params_variation2.phpt new file mode 100644 index 0000000000..5d7a01096f --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation2.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_path=/path +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_path")); +var_dump(session_set_cookie_params(3600, "/foo")); +var_dump(ini_get("session.cookie_path")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_path")); +var_dump(session_set_cookie_params(3600, "/blah")); +var_dump(ini_get("session.cookie_path")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_path")); +var_dump(session_set_cookie_params(3600, "/guff")); +var_dump(ini_get("session.cookie_path")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(5) "/path" +NULL +string(4) "/foo" +bool(true) +string(4) "/foo" +NULL +string(5) "/blah" +bool(true) +string(5) "/blah" +NULL +string(5) "/guff" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation3.phpt b/ext/session/tests/session_set_cookie_params_variation3.phpt new file mode 100644 index 0000000000..5e8f0ff572 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation3.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_domain=foo +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_domain")); +var_dump(session_set_cookie_params(3600, "/path", "blah")); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_set_cookie_params(3600, "/path", "guff")); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_set_cookie_params(3600, "/path", "foo")); +var_dump(ini_get("session.cookie_domain")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(3) "foo" +NULL +string(4) "blah" +bool(true) +string(4) "blah" +NULL +string(4) "guff" +bool(true) +string(4) "guff" +NULL +string(3) "foo" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation4.phpt b/ext/session/tests/session_set_cookie_params_variation4.phpt new file mode 100644 index 0000000000..7b825968f8 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation4.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_secure=TRUE +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_secure")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE)); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_set_cookie_params(3600, "/path", "blah", TRUE)); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE)); +var_dump(ini_get("session.cookie_secure")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(1) "1" +NULL +string(1) "0" +bool(true) +string(1) "0" +NULL +string(1) "1" +bool(true) +string(1) "1" +NULL +string(1) "0" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation5.phpt b/ext/session/tests/session_set_cookie_params_variation5.phpt new file mode 100644 index 0000000000..29559f7fd6 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation5.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_httponly=TRUE +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, FALSE)); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, TRUE)); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, FALSE)); +var_dump(ini_get("session.cookie_httponly")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(1) "1" +NULL +string(1) "0" +bool(true) +string(1) "0" +NULL +string(1) "1" +bool(true) +string(1) "1" +NULL +string(1) "0" +Done + diff --git a/ext/session/tests/session_set_save_handler_basic.phpt b/ext/session/tests/session_set_save_handler_basic.phpt new file mode 100644 index 0000000000..09fc96b394 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_basic.phpt @@ -0,0 +1,92 @@ +--TEST-- +Test session_set_save_handler() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : basic functionality ***\n"; + +require_once "save_handler.inc"; +var_dump(session_module_name()); +var_dump(session_module_name(FALSE)); +var_dump(session_module_name("blah")); +var_dump(session_module_name("foo")); + +$path = dirname(__FILE__); +session_save_path($path); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); + +session_start(); +$_SESSION["Blah"] = "Hello World!"; +$_SESSION["Foo"] = FALSE; +$_SESSION["Guff"] = 1234567890; +var_dump($_SESSION); + +session_write_close(); +session_unset(); +var_dump($_SESSION); + +echo "Starting session again..!\n"; +session_id($session_id); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_start(); +var_dump($_SESSION); +session_write_close(); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : basic functionality *** + +string(%d) "%s" + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d +bool(false) + +Warning: session_module_name(): Cannot find named PHP session module (foo) in %s on line %d +bool(false) +Open [%s,PHPSESSID] +Read [%s,%s] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Close [%s,PHPSESSID] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Starting session again..! +Open [%s,PHPSESSID] +Read [%s,%s] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Close [%s,PHPSESSID] diff --git a/ext/session/tests/session_set_save_handler_error.phpt b/ext/session/tests/session_set_save_handler_error.phpt new file mode 100644 index 0000000000..bf9d25de59 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_error.phpt @@ -0,0 +1,218 @@ +--TEST-- +Test session_set_save_handler() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : error 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_set_save_handler($input, NULL, NULL, NULL, NULL, NULL)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : error functionality *** + +-- Iteration 1 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 10 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 15 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 22 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 23 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 24 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) +Done + diff --git a/ext/session/tests/session_set_save_handler_error2.phpt b/ext/session/tests/session_set_save_handler_error2.phpt new file mode 100644 index 0000000000..03ba3b04d0 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_error2.phpt @@ -0,0 +1,62 @@ +--TEST-- +Test session_set_save_handler() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : error functionality ***\n"; + +function open($save_path, $session_name) { return true; } +function close() { return true; } +function read($id) { return false; } +function write($id, $session_data) { } +function destroy($id) { return true; } +function gc($maxlifetime) { return true; } + +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); + +session_start(); +$_SESSION["Blah"] = "Hello World!"; +$_SESSION["Foo"] = FALSE; +$_SESSION["Guff"] = 1234567890; +var_dump($_SESSION); + +session_write_close(); +var_dump($_SESSION); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_start(); +var_dump($_SESSION); +session_destroy(); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : error functionality *** +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +array(0) { +} + diff --git a/ext/session/tests/session_set_save_handler_error3.phpt b/ext/session/tests/session_set_save_handler_error3.phpt new file mode 100644 index 0000000000..da2b6a5970 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_error3.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_set_save_handler() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : error functionality ***\n"; +function open($save_path, $session_name) { + throw new Exception("Do something bad..!"); +} + +function close() { return true; } +function read($id) { return false; } +function write($id, $session_data) { } +function destroy($id) { return true; } +function gc($maxlifetime) { return true; } + +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_start(); +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : error functionality *** + +Fatal error: Uncaught exception 'Exception' with message 'Do something bad..!' in %s:%d +Stack trace: +#0 [internal function]: open('', 'PHPSESSID') +#1 %s(%d): session_start() +#2 {main} + thrown in %s on line %d + diff --git a/ext/session/tests/session_set_save_handler_error4.phpt b/ext/session/tests/session_set_save_handler_error4.phpt new file mode 100644 index 0000000000..4debde5b0f --- /dev/null +++ b/ext/session/tests/session_set_save_handler_error4.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test session_set_save_handler() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : error functionality ***\n"; + +function callback() { } + +session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback"); +session_set_save_handler("callback", "echo", "callback", "callback", "callback", "callback"); +session_set_save_handler("callback", "callback", "echo", "callback", "callback", "callback"); +session_set_save_handler("callback", "callback", "callback", "echo", "callback", "callback"); +session_set_save_handler("callback", "callback", "callback", "callback", "echo", "callback"); +session_set_save_handler("callback", "callback", "callback", "callback", "callback", "echo"); +session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback"); +session_start(); +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : error functionality *** + +Warning: session_set_save_handler(): Argument 2 is not a valid callback in %s on line %d + +Warning: session_set_save_handler(): Argument 3 is not a valid callback in %s on line %d + +Warning: session_set_save_handler(): Argument 4 is not a valid callback in %s on line %d + +Warning: session_set_save_handler(): Argument 5 is not a valid callback in %s on line %d + +Warning: session_set_save_handler(): Argument 6 is not a valid callback in %s on line %d + diff --git a/ext/session/tests/session_set_save_handler_variation1.phpt b/ext/session/tests/session_set_save_handler_variation1.phpt new file mode 100644 index 0000000000..fe1d2b0b5a --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation1.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_set_save_handler() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : variation ***\n"; + +var_dump(session_module_name()); +var_dump(session_module_name(FALSE)); +var_dump(session_module_name()); +var_dump(session_module_name("blah")); +var_dump(session_module_name()); +var_dump(session_module_name("files")); +var_dump(session_module_name()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : variation *** +string(%d) "%s" + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) +string(%d) "%s" + +Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d +bool(false) +string(%d) "%s" +string(%d) "%s" +string(5) "files" diff --git a/ext/session/tests/session_set_save_handler_variation2.phpt b/ext/session/tests/session_set_save_handler_variation2.phpt new file mode 100644 index 0000000000..1c019bb5a6 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation2.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test session_set_save_handler() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : variation ***\n"; + +require_once "save_handler.inc"; +$path = dirname(__FILE__); +session_save_path($path); +var_dump(session_start()); +var_dump(session_set_save_handler("open", "close", "read", "write", "destroy", "gc")); +var_dump(session_destroy()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : variation *** + +bool(true) +bool(false) +bool(true) + diff --git a/ext/session/tests/session_set_save_handler_variation3.phpt b/ext/session/tests/session_set_save_handler_variation3.phpt new file mode 100644 index 0000000000..774d0db489 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation3.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test session_set_save_handler() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.auto_start=1 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : variation ***\n"; + +require_once "save_handler.inc"; +$path = dirname(__FILE__); +session_save_path($path); +var_dump(session_set_save_handler("open", "close", "read", "write", "destroy", "gc")); +var_dump(session_destroy()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : variation *** + +bool(false) +bool(true) + diff --git a/ext/session/tests/session_start_error.phpt b/ext/session/tests/session_start_error.phpt new file mode 100644 index 0000000000..8cbf42c860 --- /dev/null +++ b/ext/session/tests/session_start_error.phpt @@ -0,0 +1,195 @@ +--TEST-- +Test session_start() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : error 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($input)); + var_dump(session_destroy()); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : error functionality *** + +-- Iteration 1 -- +bool(true) +bool(true) + +-- Iteration 2 -- +bool(true) +bool(true) + +-- Iteration 3 -- +bool(true) +bool(true) + +-- Iteration 4 -- +bool(true) +bool(true) + +-- Iteration 5 -- +bool(true) +bool(true) + +-- Iteration 6 -- +bool(true) +bool(true) + +-- Iteration 7 -- +bool(true) +bool(true) + +-- Iteration 8 -- +bool(true) +bool(true) + +-- Iteration 9 -- +bool(true) +bool(true) + +-- Iteration 10 -- +bool(true) +bool(true) + +-- Iteration 11 -- +bool(true) +bool(true) + +-- Iteration 12 -- +bool(true) +bool(true) + +-- Iteration 13 -- +bool(true) +bool(true) + +-- Iteration 14 -- +bool(true) +bool(true) + +-- Iteration 15 -- +bool(true) +bool(true) + +-- Iteration 16 -- +bool(true) +bool(true) + +-- Iteration 17 -- +bool(true) +bool(true) + +-- Iteration 18 -- +bool(true) +bool(true) + +-- Iteration 19 -- +bool(true) +bool(true) + +-- Iteration 20 -- +bool(true) +bool(true) + +-- Iteration 21 -- +bool(true) +bool(true) + +-- Iteration 22 -- +bool(true) +bool(true) + +-- Iteration 23 -- +bool(true) +bool(true) + +-- Iteration 24 -- +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_start_variation1.phpt b/ext/session/tests/session_start_variation1.phpt new file mode 100644 index 0000000000..1c8f3eb3b8 --- /dev/null +++ b/ext/session/tests/session_start_variation1.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_start()); +var_dump(session_start()); +var_dump(session_start()); +var_dump(session_start()); + +session_destroy(); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +bool(true) + +Notice: A session had already been started - ignoring session_start() in %s on line %d +bool(true) + +Notice: A session had already been started - ignoring session_start() in %s on line %d +bool(true) + +Notice: A session had already been started - ignoring session_start() in %s on line %d +bool(true) + +Notice: A session had already been started - ignoring session_start() in %s on line %d +bool(true) +Done + diff --git a/ext/session/tests/session_start_variation2.phpt b/ext/session/tests/session_start_variation2.phpt new file mode 100644 index 0000000000..6c9b29e3ec --- /dev/null +++ b/ext/session/tests/session_start_variation2.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_start_variation3.phpt b/ext/session/tests/session_start_variation3.phpt new file mode 100644 index 0000000000..e87f84bcea --- /dev/null +++ b/ext/session/tests/session_start_variation3.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) +Done + diff --git a/ext/session/tests/session_start_variation4.phpt b/ext/session/tests/session_start_variation4.phpt new file mode 100644 index 0000000000..42895493a7 --- /dev/null +++ b/ext/session/tests/session_start_variation4.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +$_SESSION['blah'] = 'foo'; +var_dump($_SESSION); +session_start(); +var_dump($_SESSION); + +session_destroy(); +echo "Done"; +ob_end_flush(); + +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(1) { + ["blah"]=> + string(3) "foo" +} +array(0) { +} +Done + diff --git a/ext/session/tests/session_start_variation5.phpt b/ext/session/tests/session_start_variation5.phpt new file mode 100644 index 0000000000..4dcafac330 --- /dev/null +++ b/ext/session/tests/session_start_variation5.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +session_start(); + +$_SESSION['colour'] = 'green'; +$_SESSION['animal'] = 'cat'; +$_SESSION['person'] = 'julia'; +$_SESSION['age'] = 6; + +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); + +session_start(); +session_destroy(); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +NULL +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +Done + diff --git a/ext/session/tests/session_start_variation6.phpt b/ext/session/tests/session_start_variation6.phpt new file mode 100644 index 0000000000..378554bbe3 --- /dev/null +++ b/ext/session/tests/session_start_variation6.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +session_start(); + +$_SESSION['colour'] = 'green'; +$_SESSION['animal'] = 'cat'; +$_SESSION['person'] = 'julia'; +$_SESSION['age'] = 6; + +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +session_start(); +var_dump($_SESSION); + +session_destroy(); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +NULL +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +Done + diff --git a/ext/session/tests/session_start_variation7.phpt b/ext/session/tests/session_start_variation7.phpt new file mode 100644 index 0000000000..be079f3350 --- /dev/null +++ b/ext/session/tests/session_start_variation7.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +session_start(); + +$_SESSION['colour'] = 'green'; +$_SESSION['animal'] = 'cat'; +$_SESSION['person'] = 'julia'; +$_SESSION['age'] = 6; + +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); +session_start(); +var_dump($_SESSION); + +session_destroy(); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +bool(true) +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +array(0) { +} +Done + diff --git a/ext/session/tests/session_start_variation8.phpt b/ext/session/tests/session_start_variation8.phpt new file mode 100644 index 0000000000..9365475275 --- /dev/null +++ b/ext/session/tests/session_start_variation8.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +string(0) "" +bool(true) +string(%d) "%s" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_start_variation9.phpt b/ext/session/tests/session_start_variation9.phpt new file mode 100644 index 0000000000..21523e0657 --- /dev/null +++ b/ext/session/tests/session_start_variation9.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.auto_start=1 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +string(%d) "%s" + +Notice: A session had already been started - ignoring session_start() in %s on line %d +bool(true) +string(%d) "%s" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_unregister_basic.phpt b/ext/session/tests/session_unregister_basic.phpt new file mode 100644 index 0000000000..8ce5126936 --- /dev/null +++ b/ext/session/tests/session_unregister_basic.phpt @@ -0,0 +1,176 @@ +--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 -- +bool(true) + +-- Iteration 2 -- +bool(true) + +-- Iteration 3 -- +bool(true) + +-- Iteration 4 -- +bool(true) + +-- Iteration 5 -- +bool(true) + +-- Iteration 6 -- +bool(true) + +-- Iteration 7 -- +bool(true) + +-- Iteration 8 -- +bool(true) + +-- Iteration 9 -- +bool(true) + +-- Iteration 10 -- +bool(true) + +-- Iteration 11 -- +bool(true) + +-- Iteration 12 -- +bool(true) + +-- Iteration 13 -- +bool(true) + +-- Iteration 14 -- +bool(true) + +-- Iteration 15 -- +bool(true) + +-- Iteration 16 -- +bool(true) + +-- Iteration 17 -- +bool(true) + +-- Iteration 18 -- +bool(true) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(true) + +-- Iteration 23 -- +bool(true) + +-- Iteration 24 -- +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_unregister_variation1.phpt b/ext/session/tests/session_unregister_variation1.phpt new file mode 100644 index 0000000000..f6de13ed93 --- /dev/null +++ b/ext/session/tests/session_unregister_variation1.phpt @@ -0,0 +1,158 @@ +--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) { +} +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 new file mode 100644 index 0000000000..cd57788775 --- /dev/null +++ b/ext/session/tests/session_unregister_variation2.phpt @@ -0,0 +1,46 @@ +--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!" +} +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 new file mode 100644 index 0000000000..97609266d1 --- /dev/null +++ b/ext/session/tests/session_unregister_variation3.phpt @@ -0,0 +1,47 @@ +--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!" +} +bool(true) +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_unset_basic.phpt b/ext/session/tests/session_unset_basic.phpt new file mode 100644 index 0000000000..21b12c4ddc --- /dev/null +++ b/ext/session/tests/session_unset_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_unset() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_unset(void) + * Description : Free all session variables + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unset() : basic functionality ***\n"; + +var_dump(session_start()); +$_SESSION["foo"] = "Hello World!"; +var_dump($_SESSION); +var_dump(session_unset()); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unset() : basic functionality *** +bool(true) +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +NULL +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_unset_error.phpt b/ext/session/tests/session_unset_error.phpt new file mode 100644 index 0000000000..9478345508 --- /dev/null +++ b/ext/session/tests/session_unset_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_unset() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_unset(void) + * Description : Free all session variables + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unset() : error 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_unset($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unset() : error functionality *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) +Done + diff --git a/ext/session/tests/session_unset_variation1.phpt b/ext/session/tests/session_unset_variation1.phpt new file mode 100644 index 0000000000..17ab283a1b --- /dev/null +++ b/ext/session/tests/session_unset_variation1.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test session_unset() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_unset(void) + * Description : Free all session variables + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unset() : variation ***\n"; + +var_dump(session_unset()); +var_dump(session_start()); +var_dump(session_unset()); +$_SESSION["foo"] = "Hello World!"; +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump(session_unset()); +var_dump($_SESSION); +var_dump(session_unset()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unset() : variation *** +bool(false) +bool(true) +NULL +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +bool(true) +bool(false) +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +bool(false) +Done + diff --git a/ext/session/tests/session_write_close_basic.phpt b/ext/session/tests/session_write_close_basic.phpt new file mode 100644 index 0000000000..0841afed97 --- /dev/null +++ b/ext/session/tests/session_write_close_basic.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test session_write_close() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : basic functionality ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : basic functionality *** +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_write_close_error.phpt b/ext/session/tests/session_write_close_error.phpt new file mode 100644 index 0000000000..cbdb55f26c --- /dev/null +++ b/ext/session/tests/session_write_close_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_write_close() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : error 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_write_close($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : error functionality *** + +-- Iteration 1 -- +NULL + +-- Iteration 2 -- +NULL + +-- Iteration 3 -- +NULL + +-- Iteration 4 -- +NULL + +-- Iteration 5 -- +NULL + +-- Iteration 6 -- +NULL + +-- Iteration 7 -- +NULL + +-- Iteration 8 -- +NULL + +-- Iteration 9 -- +NULL + +-- Iteration 10 -- +NULL + +-- Iteration 11 -- +NULL + +-- Iteration 12 -- +NULL + +-- Iteration 13 -- +NULL + +-- Iteration 14 -- +NULL + +-- Iteration 15 -- +NULL + +-- Iteration 16 -- +NULL + +-- Iteration 17 -- +NULL + +-- Iteration 18 -- +NULL + +-- Iteration 19 -- +NULL + +-- Iteration 20 -- +NULL + +-- Iteration 21 -- +NULL + +-- Iteration 22 -- +NULL + +-- Iteration 23 -- +NULL + +-- Iteration 24 -- +NULL +Done + diff --git a/ext/session/tests/session_write_close_variation1.phpt b/ext/session/tests/session_write_close_variation1.phpt new file mode 100644 index 0000000000..595796dbe7 --- /dev/null +++ b/ext/session/tests/session_write_close_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_write_close() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_write_close()); +var_dump(session_write_close()); +var_dump(session_write_close()); +var_dump(session_write_close()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : variation *** +bool(true) +NULL +NULL +NULL +NULL +NULL +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_write_close_variation2.phpt b/ext/session/tests/session_write_close_variation2.phpt new file mode 100644 index 0000000000..40871c5cd0 --- /dev/null +++ b/ext/session/tests/session_write_close_variation2.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test session_write_close() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : variation *** +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_write_close_variation3.phpt b/ext/session/tests/session_write_close_variation3.phpt new file mode 100644 index 0000000000..0f8061662c --- /dev/null +++ b/ext/session/tests/session_write_close_variation3.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.auto_start=1 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : variation ***\n"; + +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : variation *** +array(0) { +} +NULL +array(0) { +} +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_write_close_variation4.phpt b/ext/session/tests/session_write_close_variation4.phpt new file mode 100644 index 0000000000..249c1555c0 --- /dev/null +++ b/ext/session/tests/session_write_close_variation4.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test session_write_close() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : variation ***\n"; + +var_dump(session_id("test")); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_write_close()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_write_close()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_write_close()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : variation *** +string(0) "" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +bool(true) +Done + |
