From: Ant Phillips Date: Tue, 29 Apr 2008 08:57:12 +0000 (+0000) Subject: More session tests to improve code coverage for untested extension code X-Git-Tag: php-5.2.6~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2d2ad8e8d3d6332c8746ac66dc5c9fb369cc5dba;p=php More session tests to improve code coverage for untested extension code --- diff --git a/ext/session/tests/session_decode_variation3.phpt b/ext/session/tests/session_decode_variation3.phpt new file mode 100644 index 0000000000..b7e13cc40c --- /dev/null +++ b/ext/session/tests/session_decode_variation3.phpt @@ -0,0 +1,62 @@ +--TEST-- +Test session_decode() function : variation +--SKIPIF-- + +--INI-- +session.serialize_handler=blah +--FILE-- + +--EXPECTF-- +*** Testing session_decode() : variation *** + +Warning: session_start(): Unknown session.serialize_handler. Failed to decode session object. in %s on line %d +bool(true) +array(0) { +} +array(3) { + ["foo"]=> + int(1234567890) + ["bar"]=> + string(5) "Blah!" + ["guff"]=> + float(123.456) +} + +Warning: session_decode(): Unknown session.serialize_handler. Failed to decode session object. in %s on line %d +bool(true) +array(3) { + ["foo"]=> + int(1234567890) + ["bar"]=> + string(5) "Blah!" + ["guff"]=> + float(123.456) +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_variation4.phpt b/ext/session/tests/session_decode_variation4.phpt new file mode 100644 index 0000000000..81642754f0 --- /dev/null +++ b/ext/session/tests/session_decode_variation4.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test session_decode() function : variation +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +*** Testing session_decode() : variation *** +bool(true) +array(0) { +} +array(3) { + ["foo"]=> + int(1234567890) + ["bar"]=> + string(5) "Blah!" + ["guff"]=> + float(123.456) +} +bool(true) +array(3) { + ["foo"]=> + int(1234567890) + ["bar"]=> + string(5) "Blah!" + ["guff"]=> + float(123.456) +} +bool(true) +Done + diff --git a/ext/session/tests/session_encode_variation7.phpt b/ext/session/tests/session_encode_variation7.phpt new file mode 100644 index 0000000000..b3de3c68a8 --- /dev/null +++ b/ext/session/tests/session_encode_variation7.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- + +--INI-- +session.serialize_handler=php_binary +--FILE-- + +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(24) "A2Zvb2k6MTIzNDU2Nzg5MDs=" +bool(true) +Done + diff --git a/ext/session/tests/session_encode_variation8.phpt b/ext/session/tests/session_encode_variation8.phpt new file mode 100644 index 0000000000..57c9e17bd4 --- /dev/null +++ b/ext/session/tests/session_encode_variation8.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- + +--INI-- +session.serialize_handler=blah +--FILE-- + +--EXPECTF-- +*** Testing session_encode() : variation *** + +Warning: session_start(): Unknown session.serialize_handler. Failed to decode session object. in %s on line %d +bool(true) + +Warning: session_encode(): Unknown session.serialize_handler. Failed to encode session object. in %s on line %d +string(0) "" +bool(true) +Done + diff --git a/ext/session/tests/session_id_error4.phpt b/ext/session/tests/session_id_error4.phpt new file mode 100644 index 0000000000..cc23578aed --- /dev/null +++ b/ext/session/tests/session_id_error4.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test session_id() function : error functionality +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +*** Testing session_id() : error functionality *** +string(1) "0" +string(0) "" + +Fatal error: session_start(): Invalid session hash function in %s on line %d + diff --git a/ext/session/tests/session_id_variation1.phpt b/ext/session/tests/session_id_variation1.phpt new file mode 100644 index 0000000000..8509f809cc --- /dev/null +++ b/ext/session/tests/session_id_variation1.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test session_id() function : variation +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +*** Testing session_id() : variation *** +string(1) "0" +string(0) "" +bool(true) +string(32) "%s" +bool(true) +string(1) "0" +string(0) "" +bool(true) +string(40) "%s" +bool(true) +Done + diff --git a/ext/session/tests/session_id_variation2.phpt b/ext/session/tests/session_id_variation2.phpt new file mode 100644 index 0000000000..568896b6ec --- /dev/null +++ b/ext/session/tests/session_id_variation2.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test session_id() function : variation +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +*** Testing session_id() : variation *** +string(0) "" +int(12) +string(1) "0" +string(1) "0" +string(0) "" +bool(true) +string(32) "%s" +bool(true) +string(1) "0" +string(0) "" +bool(true) +string(40) "%s" +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_module_name_variation4.phpt b/ext/session/tests/session_module_name_variation4.phpt new file mode 100644 index 0000000000..0748b3db2f --- /dev/null +++ b/ext/session/tests/session_module_name_variation4.phpt @@ -0,0 +1,67 @@ +--TEST-- +Test session_module_name() function : variation +--SKIPIF-- + +--INI-- +session.gc_probability=1 +session.gc_divisor=1 +session.gc_maxlifetime=0 +--FILE-- + +--EXPECTF-- +*** Testing session_module_name() : variation *** + +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +NULL +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +bool(true) +array(0) { +} +bool(true) + diff --git a/ext/session/tests/session_save_path_variation4.phpt b/ext/session/tests/session_save_path_variation4.phpt new file mode 100644 index 0000000000..9c0580f64a --- /dev/null +++ b/ext/session/tests/session_save_path_variation4.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- + +--INI-- +open_basedir=. +session.save_handler=files +--FILE-- + +--CLEAN-- +$directory = dirname(__FILE__); +$sessions = ($directory."/sessions"); +var_dump(rmdir($sessions)); +--EXPECTF-- +*** Testing session_save_path() : variation *** +bool(true) +bool(true) + +Warning: ini_set(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %s on line %d +string(0) "" + +Warning: session_start(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %s on line %d + +Fatal error: session_start(): Failed to initialize storage module: files (path: ) in %s on line %d + diff --git a/ext/session/tests/session_save_path_variation5.phpt b/ext/session/tests/session_save_path_variation5.phpt new file mode 100644 index 0000000000..5d20397b66 --- /dev/null +++ b/ext/session/tests/session_save_path_variation5.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- + +--INI-- +open_basedir=. +session.save_handler=files +--FILE-- + +--CLEAN-- +$directory = dirname(__FILE__); +$sessions = ($directory."/sessions"); +var_dump(rmdir($sessions)); +--EXPECTF-- +*** Testing session_save_path() : variation *** +bool(true) +bool(true) + +Warning: ini_set(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %s on line %d +string(0) "" +bool(true) +string(0) "" +bool(true) +string(0) "" +bool(true) +Done + diff --git a/ext/session/tests/session_set_save_handler_variation4.phpt b/ext/session/tests/session_set_save_handler_variation4.phpt new file mode 100644 index 0000000000..053d453669 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation4.phpt @@ -0,0 +1,81 @@ +--TEST-- +Test session_set_save_handler() function : variation +--SKIPIF-- + +--INI-- +session.gc_probability=1 +session.gc_divisor=1 +session.gc_maxlifetime=0 +--FILE-- + +--EXPECTF-- +*** Testing session_set_save_handler() : variation *** + +Open [%s,PHPSESSID] +Read [%s,%s] +GC [0] +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] +NULL +Open [%s,PHPSESSID] +Read [%s,%s] +GC [0] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Destroy [%s,%s] + +Warning: unlink(%s): No such file or directory in %s on line %d +Close [%s,PHPSESSID] +bool(true) +