diff options
author | Ant Phillips <ant@php.net> | 2008-04-22 16:05:42 +0000 |
---|---|---|
committer | Ant Phillips <ant@php.net> | 2008-04-22 16:05:42 +0000 |
commit | 168e58d2daf91b98698f56a53441076d1ff638c4 (patch) | |
tree | 7cece1e08597398b2dfa2e05445904edc074dd7b | |
parent | 81087c56530de0444a7b59a6fb16cf1d71b0ae6c (diff) | |
download | php-git-168e58d2daf91b98698f56a53441076d1ff638c4.tar.gz |
New set of session extension tests for PHP 6.0 branch.
These hopefully test a reasonable set of basic, error and variations for
the twenty or so session functions. Note however that they do not
test all the session configuration settings.
93 files changed, 10700 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..102c664b5f --- /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(999)); +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(999) +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..cdfce72787 --- /dev/null +++ b/ext/session/tests/session_cache_expire_error.phpt @@ -0,0 +1,249 @@ +--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 -- + +Warning: session_cache_expire() expects parameter 1 to be string, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** 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 -- + +Warning: session_cache_expire() expects parameter 1 to be binary string, resource given in %s on line %d +NULL +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..9d9d8e5dd2 --- /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(999)); +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(999) +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..0282470826 --- /dev/null +++ b/ext/session/tests/session_cache_expire_variation2.phpt @@ -0,0 +1,40 @@ +--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(999)); +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(999) +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..2c15a605f2 --- /dev/null +++ b/ext/session/tests/session_cache_expire_variation3.phpt @@ -0,0 +1,61 @@ +--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(999)); +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(3) "999" +bool(true) +int(999) +string(3) "999" +bool(true) +int(999) +string(3) "999" +Done +--UEXPECTF-- +*** Testing session_cache_expire() : variation *** +unicode(3) "180" +int(180) +unicode(3) "180" +int(180) +unicode(3) "999" +bool(true) +int(999) +unicode(3) "999" +bool(true) +int(999) +unicode(3) "999" +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..115394a127 --- /dev/null +++ b/ext/session/tests/session_cache_limiter_basic.phpt @@ -0,0 +1,91 @@ +--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 +--UEXPECTF-- +*** Testing session_cache_limiter() : basic functionality *** +bool(true) +unicode(7) "nocache" +unicode(7) "nocache" +unicode(6) "public" +bool(true) +bool(true) +unicode(6) "public" +unicode(6) "public" +unicode(7) "private" +bool(true) +bool(true) +unicode(7) "private" +unicode(7) "private" +unicode(7) "nocache" +bool(true) +bool(true) +unicode(7) "nocache" +unicode(7) "nocache" +unicode(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..cadec5dbe3 --- /dev/null +++ b/ext/session/tests/session_cache_limiter_error.phpt @@ -0,0 +1,249 @@ +--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 -- + +Warning: session_cache_limiter() expects parameter 1 to be string, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing session_cache_limiter() : error functionality *** + +-- Iteration 1 -- +unicode(7) "nocache" + +-- Iteration 2 -- +unicode(1) "0" + +-- Iteration 3 -- +unicode(1) "1" + +-- Iteration 4 -- +unicode(5) "12345" + +-- Iteration 5 -- +unicode(5) "-2345" + +-- Iteration 6 -- +unicode(4) "10.5" + +-- Iteration 7 -- +unicode(5) "-10.5" + +-- Iteration 8 -- +unicode(12) "123456789000" + +-- Iteration 9 -- +unicode(13) "1.23456789E-9" + +-- Iteration 10 -- +unicode(3) "0.5" + +-- Iteration 11 -- +unicode(0) "" + +-- Iteration 12 -- +unicode(0) "" + +-- Iteration 13 -- +unicode(1) "1" + +-- Iteration 14 -- +unicode(0) "" + +-- Iteration 15 -- +unicode(1) "1" + +-- Iteration 16 -- +unicode(0) "" + +-- Iteration 17 -- +unicode(0) "" + +-- Iteration 18 -- +unicode(0) "" + +-- Iteration 19 -- +unicode(7) "Nothing" + +-- Iteration 20 -- +unicode(7) "Nothing" + +-- Iteration 21 -- +unicode(12) "Hello World!" + +-- Iteration 22 -- +unicode(12) "Hello World!" + +-- Iteration 23 -- +unicode(0) "" + +-- Iteration 24 -- + +Warning: session_cache_limiter() expects parameter 1 to be binary string, resource given in %s on line %d +NULL +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..25e0c906b6 --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation1.phpt @@ -0,0 +1,51 @@ +--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 +--UEXPECTF-- +*** Testing session_cache_limiter() : variation *** +unicode(7) "nocache" +bool(true) +unicode(7) "nocache" +unicode(7) "nocache" +unicode(6) "public" +bool(true) +unicode(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..28ff7fa88d --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation2.phpt @@ -0,0 +1,50 @@ +--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 +--UEXPECTF-- +*** Testing session_cache_limiter() : variation *** +unicode(7) "nocache" +bool(true) +unicode(7) "nocache" +unicode(7) "nocache" +unicode(6) "public" +bool(true) +unicode(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..fd652f120d --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation3.phpt @@ -0,0 +1,49 @@ +--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 +--UEXPECTF-- +*** Testing session_cache_limiter() : variation *** +unicode(7) "nocache" +bool(true) +unicode(7) "nocache" +unicode(7) "nocache" +unicode(6) "public" +bool(true) +unicode(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..41fe6eb29e --- /dev/null +++ b/ext/session/tests/session_decode_basic.phpt @@ -0,0 +1,447 @@ +--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 +--UEXPECTF-- +*** Testing session_decode() : basic functionality *** +bool(true) + +-- Iteration 1 -- +bool(true) +array(1) { + [u"data"]=> + int(0) +} + +-- Iteration 2 -- +bool(true) +array(1) { + [u"data"]=> + int(1) +} + +-- Iteration 3 -- +bool(true) +array(1) { + [u"data"]=> + int(12345) +} + +-- Iteration 4 -- +bool(true) +array(1) { + [u"data"]=> + int(-2345) +} + +-- Iteration 5 -- +bool(true) +array(1) { + [u"data"]=> + float(10.5) +} + +-- Iteration 6 -- +bool(true) +array(1) { + [u"data"]=> + float(-10.5) +} + +-- Iteration 7 -- +bool(true) +array(1) { + [u"data"]=> + float(123456789000) +} + +-- Iteration 8 -- +bool(true) +array(1) { + [u"data"]=> + float(1.23456789E-9) +} + +-- Iteration 9 -- +bool(true) +array(1) { + [u"data"]=> + float(0.5) +} + +-- Iteration 10 -- +bool(true) +array(1) { + [u"data"]=> + NULL +} + +-- Iteration 11 -- +bool(true) +array(1) { + [u"data"]=> + NULL +} + +-- Iteration 12 -- +bool(true) +array(1) { + [u"data"]=> + bool(true) +} + +-- Iteration 13 -- +bool(true) +array(1) { + [u"data"]=> + bool(false) +} + +-- Iteration 14 -- +bool(true) +array(1) { + [u"data"]=> + bool(true) +} + +-- Iteration 15 -- +bool(true) +array(1) { + [u"data"]=> + bool(false) +} + +-- Iteration 16 -- +bool(true) +array(1) { + [u"data"]=> + unicode(0) "" +} + +-- Iteration 17 -- +bool(true) +array(1) { + [u"data"]=> + unicode(0) "" +} + +-- Iteration 18 -- +bool(true) +array(1) { + [u"data"]=> + unicode(7) "Nothing" +} + +-- Iteration 19 -- +bool(true) +array(1) { + [u"data"]=> + unicode(7) "Nothing" +} + +-- Iteration 20 -- +bool(true) +array(1) { + [u"data"]=> + unicode(12) "Hello World!" +} + +-- Iteration 21 -- +bool(true) +array(1) { + [u"data"]=> + object(classA)#2 (0) { + } +} + +-- Iteration 22 -- +bool(true) +array(1) { + [u"data"]=> + NULL +} + +-- Iteration 23 -- +bool(true) +array(1) { + [u"data"]=> + NULL +} + +-- Iteration 24 -- +bool(true) +array(1) { + [u"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..eeff36b09b --- /dev/null +++ b/ext/session/tests/session_decode_error.phpt @@ -0,0 +1,351 @@ +--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 -- + +Warning: session_decode() expects parameter 1 to be string, resource given in %s on line %d +NULL +array(0) { +} +bool(true) +Done +--UEXPECTF-- +*** 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 -- + +Warning: session_decode() expects parameter 1 to be binary string, resource given in %s on line %d +NULL +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..6a98c6df7f --- /dev/null +++ b/ext/session/tests/session_decode_error2.phpt @@ -0,0 +1,1199 @@ +--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 +--UEXPECTF-- +*** 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) { + [u"foo"]=> + NULL +} + +-- Iteration 5 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 6 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 7 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 8 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 9 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 10 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 11 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 12 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 13 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 14 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 15 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 16 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 17 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 18 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 19 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 20 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 21 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 22 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 23 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 24 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 25 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 26 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 27 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 28 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 29 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 30 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 31 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 32 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 33 -- +bool(true) +array(1) { + [u"foo"]=> + NULL +} + +-- Iteration 34 -- +bool(true) +array(1) { + [u"foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 35 -- +bool(true) +array(1) { + [u"foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 36 -- +bool(true) +array(1) { + [u"foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 37 -- +bool(true) +array(1) { + [u"foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 38 -- +bool(true) +array(1) { + [u"foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 39 -- +bool(true) +array(2) { + [u"foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + NULL +} + +-- Iteration 40 -- +bool(true) +array(2) { + [u"foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + NULL +} + +-- Iteration 41 -- +bool(true) +array(2) { + [u"foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + NULL +} + +-- Iteration 42 -- +bool(true) +array(2) { + [u"foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + NULL +} + +-- Iteration 43 -- +bool(true) +array(2) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 44 -- +bool(true) +array(2) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 45 -- +bool(true) +array(2) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 46 -- +bool(true) +array(2) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 47 -- +bool(true) +array(2) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 48 -- +bool(true) +array(3) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"blah"]=> + NULL +} + +-- Iteration 49 -- +bool(true) +array(3) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"blah"]=> + NULL +} + +-- Iteration 50 -- +bool(true) +array(3) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"blah"]=> + NULL +} + +-- Iteration 51 -- +bool(true) +array(3) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"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..74c722f594 --- /dev/null +++ b/ext/session/tests/session_decode_variation1.phpt @@ -0,0 +1,344 @@ +--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 +--UEXPECTF-- +*** Testing session_decode() : variation *** +bool(true) +bool(true) +array(3) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"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..1dc7c88435 --- /dev/null +++ b/ext/session/tests/session_decode_variation2.phpt @@ -0,0 +1,125 @@ +--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 +--UEXPECTF-- +*** Testing session_decode() : variation *** +bool(true) +array(0) { +} +array(3) { + [u"foo"]=> + int(1234567890) + [u"bar"]=> + unicode(12) "Hello World!" + [u"guff"]=> + float(123.456) +} +bool(true) +array(4) { + [u"foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"bar"]=> + unicode(12) "Hello World!" + [u"guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [u"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..a3e443e9d8 --- /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: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: session_destroy() expects exactly 0 parameters, 1 given 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..7035ed8e5c --- /dev/null +++ b/ext/session/tests/session_encode_basic.phpt @@ -0,0 +1,251 @@ +--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 +--UEXPECTF-- +*** Testing session_encode() : basic functionality *** +bool(true) + +-- Iteration 1 -- +unicode(9) "data|i:0;" + +-- Iteration 2 -- +unicode(9) "data|i:1;" + +-- Iteration 3 -- +unicode(13) "data|i:12345;" + +-- Iteration 4 -- +unicode(13) "data|i:-2345;" + +-- Iteration 5 -- +unicode(12) "data|d:10.5;" + +-- Iteration 6 -- +unicode(13) "data|d:-10.5;" + +-- Iteration 7 -- +unicode(20) "data|d:123456789000;" + +-- Iteration 8 -- +unicode(86) "data|d:1.2345678899999999145113427164344339914681114578343112953007221221923828125E-9;" + +-- Iteration 9 -- +unicode(11) "data|d:0.5;" + +-- Iteration 10 -- +unicode(7) "data|N;" + +-- Iteration 11 -- +unicode(7) "data|N;" + +-- Iteration 12 -- +unicode(9) "data|b:1;" + +-- Iteration 13 -- +unicode(9) "data|b:0;" + +-- Iteration 14 -- +unicode(9) "data|b:1;" + +-- Iteration 15 -- +unicode(9) "data|b:0;" + +-- Iteration 16 -- +unicode(12) "data|U:0:"";" + +-- Iteration 17 -- +unicode(12) "data|U:0:"";" + +-- Iteration 18 -- +unicode(19) "data|U:7:"Nothing";" + +-- Iteration 19 -- +unicode(19) "data|U:7:"Nothing";" + +-- Iteration 20 -- +unicode(25) "data|U:12:"Hello World!";" + +-- Iteration 21 -- +unicode(22) "data|O:6:"classA":0:{}" + +-- Iteration 22 -- +unicode(7) "data|N;" + +-- Iteration 23 -- +unicode(7) "data|N;" + +-- Iteration 24 -- +unicode(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..955aff4d53 --- /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: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: session_encode() expects exactly 0 parameters, 1 given 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..6df0a570a4 --- /dev/null +++ b/ext/session/tests/session_encode_error2.phpt @@ -0,0 +1,351 @@ +--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) +bool(false) +bool(true) + +-- Iteration 2 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 3 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 4 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 5 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 6 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 7 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 8 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 9 -- +bool(true) +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) +bool(false) +bool(true) + +-- Iteration 13 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 14 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 15 -- +bool(true) +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 %d +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 +bool(false) +bool(true) +Done +--UEXPECTF-- +*** Testing session_encode() : error functionality *** + +-- Iteration 1 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 2 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 3 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 4 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 5 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 6 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 7 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 8 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 9 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 10 -- +bool(true) +unicode(21) "|U:12:"Hello World!";" +bool(true) + +-- Iteration 11 -- +bool(true) +unicode(21) "|U:12:"Hello World!";" +bool(true) + +-- Iteration 12 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 13 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 14 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 15 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 16 -- +bool(true) +unicode(21) "|U:12:"Hello World!";" +bool(true) + +-- Iteration 17 -- +bool(true) +unicode(21) "|U:12:"Hello World!";" +bool(true) + +-- Iteration 18 -- +bool(true) +unicode(28) "Nothing|U:12:"Hello World!";" +bool(true) + +-- Iteration 19 -- +bool(true) +unicode(28) "Nothing|U:12:"Hello World!";" +bool(true) + +-- Iteration 20 -- +bool(true) +unicode(33) "Hello World!|U:12:"Hello World!";" +bool(true) + +-- Iteration 21 -- +bool(true) + +Warning: Illegal offset type in %s on line %d +bool(false) +bool(true) + +-- Iteration 22 -- +bool(true) +unicode(21) "|U:12:"Hello World!";" +bool(true) + +-- Iteration 23 -- +bool(true) +unicode(21) "|U: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 +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..4f2e5e89de --- /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..d9971a6d6d --- /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..659148bd1d --- /dev/null +++ b/ext/session/tests/session_encode_variation3.phpt @@ -0,0 +1,40 @@ +--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 +--UEXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +unicode(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..9bc3dd7261 --- /dev/null +++ b/ext/session/tests/session_encode_variation4.phpt @@ -0,0 +1,42 @@ +--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 +--UEXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +unicode(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..52edaf576e --- /dev/null +++ b/ext/session/tests/session_encode_variation5.phpt @@ -0,0 +1,42 @@ +--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 +--UEXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +unicode(64) "data|a:5:{i:0;i:1;i:1;i:2;i:2;i:3;U:3:"foo";R:1;U: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..9c9ddf9fdc --- /dev/null +++ b/ext/session/tests/session_encode_variation6.phpt @@ -0,0 +1,46 @@ +--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) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +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..225c69accf --- /dev/null +++ b/ext/session/tests/session_get_cookie_params_basic.phpt @@ -0,0 +1,109 @@ +--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 +--UEXPECTF-- +*** Testing session_get_cookie_params() : basic functionality *** +array(5) { + [u"lifetime"]=> + int(0) + [u"path"]=> + unicode(1) "/" + [u"domain"]=> + unicode(0) "" + [u"secure"]=> + bool(false) + [u"httponly"]=> + bool(false) +} +NULL +array(5) { + [u"lifetime"]=> + int(3600) + [u"path"]=> + unicode(5) "/path" + [u"domain"]=> + unicode(4) "blah" + [u"secure"]=> + bool(false) + [u"httponly"]=> + bool(false) +} +NULL +array(5) { + [u"lifetime"]=> + int(1234567890) + [u"path"]=> + unicode(5) "/guff" + [u"domain"]=> + unicode(3) "foo" + [u"secure"]=> + bool(true) + [u"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..243536c39e --- /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: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: session_get_cookie_params() expects exactly 0 parameters, 1 given 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..9807e3be09 --- /dev/null +++ b/ext/session/tests/session_get_cookie_params_variation1.phpt @@ -0,0 +1,183 @@ +--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 +--UEXPECTF-- +*** Testing session_get_cookie_params() : variation *** +array(5) { + [u"lifetime"]=> + int(0) + [u"path"]=> + unicode(1) "/" + [u"domain"]=> + unicode(0) "" + [u"secure"]=> + bool(false) + [u"httponly"]=> + bool(false) +} +array(5) { + [u"lifetime"]=> + int(3600) + [u"path"]=> + unicode(1) "/" + [u"domain"]=> + unicode(0) "" + [u"secure"]=> + bool(false) + [u"httponly"]=> + bool(false) +} +array(5) { + [u"lifetime"]=> + int(3600) + [u"path"]=> + unicode(5) "/path" + [u"domain"]=> + unicode(0) "" + [u"secure"]=> + bool(false) + [u"httponly"]=> + bool(false) +} +array(5) { + [u"lifetime"]=> + int(3600) + [u"path"]=> + unicode(5) "/path" + [u"domain"]=> + unicode(3) "foo" + [u"secure"]=> + bool(false) + [u"httponly"]=> + bool(false) +} +array(5) { + [u"lifetime"]=> + int(3600) + [u"path"]=> + unicode(5) "/path" + [u"domain"]=> + unicode(3) "foo" + [u"secure"]=> + bool(true) + [u"httponly"]=> + bool(false) +} +array(5) { + [u"lifetime"]=> + int(3600) + [u"path"]=> + unicode(5) "/path" + [u"domain"]=> + unicode(3) "foo" + [u"secure"]=> + bool(true) + [u"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..f32cb6c4b7 --- /dev/null +++ b/ext/session/tests/session_id_error.phpt @@ -0,0 +1,172 @@ +--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 -- + +Warning: session_id() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +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..44629ca039 --- /dev/null +++ b/ext/session/tests/session_id_error3.phpt @@ -0,0 +1,65 @@ +--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("\r\n")); +var_dump(session_id()); +@session_destroy(); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : error functionality *** +string(32) "%s" +string(32) "%s" +string(1) "!" +string(32) "%s" +string(32) "%s" +string(3) "?><" +string(32) "%s" +string(32) "%s" +string(2) " +" +Done +--UEXPECTF-- +*** Testing session_id() : error functionality *** +string(32) "%s" +string(32) "%s" +string(1) "!" +string(32) "%s" +string(32) "%s" +string(3) "?><" +string(32) "%s" +string(32) "%s" +string(2) " +" +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..7bc6170c0c --- /dev/null +++ b/ext/session/tests/session_module_name_basic.phpt @@ -0,0 +1,45 @@ +--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 +--UEXPECTF-- +*** Testing session_module_name() : basic functionality *** +unicode(5) "files" +unicode(5) "files" +bool(true) +unicode(5) "files" +bool(true) +unicode(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..7310f87ee3 --- /dev/null +++ b/ext/session/tests/session_module_name_error.phpt @@ -0,0 +1,340 @@ +--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() expects parameter 1 to be string, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** 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() expects parameter 1 to be binary string, resource given in %s on line %d +NULL +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..0e53ee95cb --- /dev/null +++ b/ext/session/tests/session_module_name_variation1.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"; +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 +--UEXPECTF-- +*** 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) +unicode(5) "files" +bool(true) +unicode(5) "files" +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..2ddf93137a --- /dev/null +++ b/ext/session/tests/session_module_name_variation2.phpt @@ -0,0 +1,39 @@ +--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" +--UEXPECTF-- +*** Testing session_module_name() : variation *** +unicode(5) "files" +unicode(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..2325b9531e --- /dev/null +++ b/ext/session/tests/session_module_name_variation3.phpt @@ -0,0 +1,58 @@ +--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 +--UEXPECTF-- +*** Testing session_module_name() : variation *** +unicode(5) "files" +unicode(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..7ec0d098cd --- /dev/null +++ b/ext/session/tests/session_name_basic.phpt @@ -0,0 +1,46 @@ +--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 +--UEXPECTF-- +*** Testing session_name() : error functionality *** +unicode(9) "PHPSESSID" +unicode(9) "PHPSESSID" +bool(true) +unicode(4) "blah" +bool(true) +unicode(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..fbcd16db4a --- /dev/null +++ b/ext/session/tests/session_name_error.phpt @@ -0,0 +1,248 @@ +--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 -- + +Warning: session_name() expects parameter 1 to be string, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing session_name() : error functionality *** + +-- Iteration 1 -- +unicode(9) "PHPSESSID" + +-- Iteration 2 -- +unicode(1) "0" + +-- Iteration 3 -- +unicode(1) "1" + +-- Iteration 4 -- +unicode(5) "12345" + +-- Iteration 5 -- +unicode(5) "-2345" + +-- Iteration 6 -- +unicode(4) "10.5" + +-- Iteration 7 -- +unicode(5) "-10.5" + +-- Iteration 8 -- +unicode(12) "123456789000" + +-- Iteration 9 -- +unicode(13) "1.23456789E-9" + +-- Iteration 10 -- +unicode(3) "0.5" + +-- Iteration 11 -- +unicode(0) "" + +-- Iteration 12 -- +unicode(0) "" + +-- Iteration 13 -- +unicode(1) "1" + +-- Iteration 14 -- +unicode(0) "" + +-- Iteration 15 -- +unicode(1) "1" + +-- Iteration 16 -- +unicode(0) "" + +-- Iteration 17 -- +unicode(0) "" + +-- Iteration 18 -- +unicode(0) "" + +-- Iteration 19 -- +unicode(7) "Nothing" + +-- Iteration 20 -- +unicode(7) "Nothing" + +-- Iteration 21 -- +unicode(12) "Hello World!" + +-- Iteration 22 -- +unicode(12) "Hello World!" + +-- Iteration 23 -- +unicode(0) "" + +-- Iteration 24 -- + +Warning: session_name() expects parameter 1 to be binary string, resource given in %s on line %d +NULL +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..2db40b80e3 --- /dev/null +++ b/ext/session/tests/session_name_variation1.phpt @@ -0,0 +1,75 @@ +--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 +--UEXPECTF-- +*** Testing session_name() : variation *** +unicode(9) "PHPSESSID" +bool(true) +unicode(0) "" +bool(true) +unicode(0) "" +unicode(0) "" +bool(true) +unicode(1) " " +bool(true) +unicode(1) " " +unicode(1) " " +bool(true) +unicode(0) "" +bool(true) +unicode(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..8a00e94a52 --- /dev/null +++ b/ext/session/tests/session_name_variation2.phpt @@ -0,0 +1,48 @@ +--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 +--UEXPECTF-- +*** Testing session_name() : variation *** +unicode(4) "blah" +unicode(4) "blah" +bool(true) +unicode(4) "blah" +bool(true) +unicode(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_save_path_basic.phpt b/ext/session/tests/session_save_path_basic.phpt new file mode 100644 index 0000000000..80b1a4c7b2 --- /dev/null +++ b/ext/session/tests/session_save_path_basic.phpt @@ -0,0 +1,40 @@ +--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 +--UEXPECTF-- +*** Testing session_save_path() : error functionality *** +unicode(0) "" +unicode(0) "" +unicode(%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..f3cd68e412 --- /dev/null +++ b/ext/session/tests/session_save_path_error.phpt @@ -0,0 +1,253 @@ +--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 -- + +Warning: session_save_path() expects parameter 1 to be string, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing session_save_path() : error functionality *** + +-- Iteration 1 -- +unicode(0) "" + +-- Iteration 2 -- +unicode(1) "0" + +-- Iteration 3 -- +unicode(1) "1" + +-- Iteration 4 -- +unicode(5) "12345" + +-- Iteration 5 -- +unicode(5) "-2345" + +-- Iteration 6 -- +unicode(4) "10.5" + +-- Iteration 7 -- +unicode(5) "-10.5" + +-- Iteration 8 -- +unicode(12) "123456789000" + +-- Iteration 9 -- +unicode(13) "1.23456789E-9" + +-- Iteration 10 -- +unicode(3) "0.5" + +-- Iteration 11 -- +unicode(0) "" + +-- Iteration 12 -- +unicode(0) "" + +-- Iteration 13 -- +unicode(1) "1" + +-- Iteration 14 -- +unicode(0) "" + +-- Iteration 15 -- +unicode(1) "1" + +-- Iteration 16 -- +unicode(0) "" + +-- Iteration 17 -- +unicode(0) "" + +-- Iteration 18 -- +unicode(0) "" + +-- Iteration 19 -- +unicode(7) "Nothing" + +-- Iteration 20 -- +unicode(7) "Nothing" + +-- Iteration 21 -- +unicode(12) "Hello World!" + +-- Iteration 22 -- +unicode(12) "Hello World!" + +-- Iteration 23 -- +unicode(0) "" + +-- Iteration 24 -- + +Warning: session_save_path() expects parameter 1 to be binary string, resource given in %s on line %d +NULL +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..66b7e2e316 --- /dev/null +++ b/ext/session/tests/session_save_path_variation1.phpt @@ -0,0 +1,52 @@ +--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 +--UEXPECTF-- +*** Testing session_save_path() : variation *** +unicode(0) "" +bool(true) +unicode(0) "" +unicode(0) "" +unicode(%d) "%s" +bool(true) +unicode(%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..5918c07532 --- /dev/null +++ b/ext/session/tests/session_save_path_variation2.phpt @@ -0,0 +1,51 @@ +--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 +--UEXPECTF-- +*** Testing session_save_path() : variation *** +unicode(5) "/blah" + +Warning: session_start(): open(%s, O_RDWR) failed: No such file or directory (2) in %s on line %d +bool(true) +unicode(5) "/blah" +bool(true) +unicode(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..6da6fe08b1 --- /dev/null +++ b/ext/session/tests/session_save_path_variation3.phpt @@ -0,0 +1,51 @@ +--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 +--UEXPECTF-- +*** Testing session_save_path() : variation *** +unicode(5) "/blah" + +Warning: session_start(): open(%s, O_RDWR) failed: No such file or directory (2) in %s on line %d +bool(true) +unicode(5) "/blah" +bool(true) +unicode(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..0adc9edd10 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_error.phpt @@ -0,0 +1,517 @@ +--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 + +Warning: session_set_cookie_params() expects parameter 4 to be boolean, object given in %s on line %d +NULL + +Warning: session_set_cookie_params() expects parameter 5 to be boolean, object given 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 -- + +Warning: session_set_cookie_params() expects parameter 1 to be string, resource given in %s on line %d +NULL + +Warning: session_set_cookie_params() expects parameter 2 to be string, resource given in %s on line %d +NULL + +Warning: session_set_cookie_params() expects parameter 3 to be string, resource given in %s on line %d +NULL + +Warning: session_set_cookie_params() expects parameter 4 to be boolean, resource given in %s on line %d +NULL + +Warning: session_set_cookie_params() expects parameter 5 to be boolean, resource given in %s on line %d +NULL +NULL +Done +--UEXPECTF-- +*** 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 + +Warning: session_set_cookie_params() expects parameter 4 to be boolean, object given in %s on line %d +NULL + +Warning: session_set_cookie_params() expects parameter 5 to be boolean, object given 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 -- + +Warning: session_set_cookie_params() expects parameter 1 to be binary string, resource given in %s on line %d +NULL + +Warning: session_set_cookie_params() expects parameter 2 to be binary string, resource given in %s on line %d +NULL + +Warning: session_set_cookie_params() expects parameter 3 to be binary string, resource given in %s on line %d +NULL + +Warning: session_set_cookie_params() expects parameter 4 to be boolean, resource given in %s on line %d +NULL + +Warning: session_set_cookie_params() expects parameter 5 to be boolean, resource given in %s on line %d +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..ce1033d46b --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation1.phpt @@ -0,0 +1,63 @@ +--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 +--UEXPECTF-- +*** Testing session_set_cookie_params() : variation *** +unicode(4) "3600" +NULL +unicode(4) "3600" +bool(true) +unicode(4) "3600" +NULL +unicode(4) "1800" +bool(true) +unicode(4) "1800" +NULL +unicode(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..f2fefea9a8 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation2.phpt @@ -0,0 +1,63 @@ +--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 +--UEXPECTF-- +*** Testing session_set_cookie_params() : variation *** +unicode(5) "/path" +NULL +unicode(4) "/foo" +bool(true) +unicode(4) "/foo" +NULL +unicode(5) "/blah" +bool(true) +unicode(5) "/blah" +NULL +unicode(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..146111b575 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation3.phpt @@ -0,0 +1,63 @@ +--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 +--UEXPECTF-- +*** Testing session_set_cookie_params() : variation *** +unicode(3) "foo" +NULL +unicode(4) "blah" +bool(true) +unicode(4) "blah" +NULL +unicode(4) "guff" +bool(true) +unicode(4) "guff" +NULL +unicode(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..0fd2d2861d --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation4.phpt @@ -0,0 +1,63 @@ +--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 +--UEXPECTF-- +*** Testing session_set_cookie_params() : variation *** +unicode(1) "1" +NULL +unicode(1) "0" +bool(true) +unicode(1) "0" +NULL +unicode(1) "1" +bool(true) +unicode(1) "1" +NULL +unicode(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..4fe501ad9f --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation5.phpt @@ -0,0 +1,63 @@ +--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 +--UEXPECTF-- +*** Testing session_set_cookie_params() : variation *** +unicode(1) "1" +NULL +unicode(1) "0" +bool(true) +unicode(1) "0" +NULL +unicode(1) "1" +bool(true) +unicode(1) "1" +NULL +unicode(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..6c7a3bb840 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_basic.phpt @@ -0,0 +1,142 @@ +--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(5) "files" + +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] +--UEXPECTF-- +*** Testing session_set_save_handler() : basic functionality *** + +unicode(5) "files" + +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) { + [u"Blah"]=> + unicode(12) "Hello World!" + [u"Foo"]=> + bool(false) + [u"Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|U:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] + +Notice: fwrite(): %d character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +Close [%s,PHPSESSID] +array(3) { + [u"Blah"]=> + unicode(12) "Hello World!" + [u"Foo"]=> + bool(false) + [u"Guff"]=> + int(1234567890) +} +Starting session again..! +Open [%s,PHPSESSID] +Read [%s,%s] +array(3) { + [u"Blah"]=> + unicode(12) "Hello World!" + [u"Foo"]=> + bool(false) + [u"Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|U:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] + +Notice: fwrite(): %d character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +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..1cc2fb5797 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_error2.phpt @@ -0,0 +1,82 @@ +--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) { +} +--UEXPECTF-- +*** Testing session_set_save_handler() : error functionality *** +array(3) { + [u"Blah"]=> + unicode(12) "Hello World!" + [u"Foo"]=> + bool(false) + [u"Guff"]=> + int(1234567890) +} +array(3) { + [u"Blah"]=> + unicode(12) "Hello World!" + [u"Foo"]=> + bool(false) + [u"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..26d9d7b7d2 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation1.phpt @@ -0,0 +1,54 @@ +--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" +--UEXPECTF-- +*** Testing session_set_save_handler() : variation *** +unicode(5) "files" + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) +unicode(5) "files" + +Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d +bool(false) +unicode(5) "files" +unicode(5) "files" +unicode(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..c92bfda067 --- /dev/null +++ b/ext/session/tests/session_start_variation4.phpt @@ -0,0 +1,46 @@ +--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 +--UEXPECTF-- +*** Testing session_start() : variation *** +array(1) { + [u"blah"]=> + unicode(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..a3ed21e975 --- /dev/null +++ b/ext/session/tests/session_start_variation5.phpt @@ -0,0 +1,82 @@ +--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 +--UEXPECTF-- +*** Testing session_start() : variation *** +array(4) { + [u"colour"]=> + unicode(5) "green" + [u"animal"]=> + unicode(3) "cat" + [u"person"]=> + unicode(5) "julia" + [u"age"]=> + int(6) +} +NULL +array(4) { + [u"colour"]=> + unicode(5) "green" + [u"animal"]=> + unicode(3) "cat" + [u"person"]=> + unicode(5) "julia" + [u"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..12f817b4c1 --- /dev/null +++ b/ext/session/tests/session_start_variation6.phpt @@ -0,0 +1,103 @@ +--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 +--UEXPECTF-- +*** Testing session_start() : variation *** +array(4) { + [u"colour"]=> + unicode(5) "green" + [u"animal"]=> + unicode(3) "cat" + [u"person"]=> + unicode(5) "julia" + [u"age"]=> + int(6) +} +NULL +array(4) { + [u"colour"]=> + unicode(5) "green" + [u"animal"]=> + unicode(3) "cat" + [u"person"]=> + unicode(5) "julia" + [u"age"]=> + int(6) +} +array(4) { + [u"colour"]=> + unicode(5) "green" + [u"animal"]=> + unicode(3) "cat" + [u"person"]=> + unicode(5) "julia" + [u"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..d7b7785563 --- /dev/null +++ b/ext/session/tests/session_start_variation7.phpt @@ -0,0 +1,87 @@ +--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 +--UEXPECTF-- +*** Testing session_start() : variation *** +array(4) { + [u"colour"]=> + unicode(5) "green" + [u"animal"]=> + unicode(3) "cat" + [u"person"]=> + unicode(5) "julia" + [u"age"]=> + int(6) +} +bool(true) +array(4) { + [u"colour"]=> + unicode(5) "green" + [u"animal"]=> + unicode(3) "cat" + [u"person"]=> + unicode(5) "julia" + [u"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_unset_basic.phpt b/ext/session/tests/session_unset_basic.phpt new file mode 100644 index 0000000000..db95d51de9 --- /dev/null +++ b/ext/session/tests/session_unset_basic.phpt @@ -0,0 +1,57 @@ +--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 +--UEXPECTF-- +*** Testing session_unset() : basic functionality *** +bool(true) +array(1) { + [u"foo"]=> + unicode(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..f9346f6332 --- /dev/null +++ b/ext/session/tests/session_unset_variation1.phpt @@ -0,0 +1,65 @@ +--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 +--UEXPECTF-- +*** Testing session_unset() : variation *** +bool(false) +bool(true) +NULL +array(1) { + [u"foo"]=> + unicode(12) "Hello World!" +} +bool(true) +bool(false) +array(1) { + [u"foo"]=> + unicode(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 + |