From 049e27a949ceeb62f65977c61d272e45f60fee6b Mon Sep 17 00:00:00 2001 From: Ant Phillips Date: Tue, 29 Apr 2008 08:57:10 +0000 Subject: [PATCH] More session tests to improve code coverage for untested extension code --- .../tests/session_decode_variation3.phpt | 90 ++++++++++++++ .../tests/session_decode_variation4.phpt | 80 ++++++++++++ .../tests/session_encode_variation7.phpt | 41 +++++++ .../tests/session_encode_variation8.phpt | 39 ++++++ ext/session/tests/session_id_error4.phpt | 43 +++++++ ext/session/tests/session_id_variation1.phpt | 59 +++++++++ ext/session/tests/session_id_variation2.phpt | 74 +++++++++++ .../tests/session_module_name_variation4.phpt | 91 ++++++++++++++ .../tests/session_save_path_variation4.phpt | 70 +++++++++++ .../tests/session_save_path_variation5.phpt | 69 +++++++++++ .../session_set_save_handler_variation4.phpt | 116 ++++++++++++++++++ 11 files changed, 772 insertions(+) create mode 100644 ext/session/tests/session_decode_variation3.phpt create mode 100644 ext/session/tests/session_decode_variation4.phpt create mode 100644 ext/session/tests/session_encode_variation7.phpt create mode 100644 ext/session/tests/session_encode_variation8.phpt create mode 100644 ext/session/tests/session_id_error4.phpt create mode 100644 ext/session/tests/session_id_variation1.phpt create mode 100644 ext/session/tests/session_id_variation2.phpt create mode 100644 ext/session/tests/session_module_name_variation4.phpt create mode 100644 ext/session/tests/session_save_path_variation4.phpt create mode 100644 ext/session/tests/session_save_path_variation5.phpt create mode 100644 ext/session/tests/session_set_save_handler_variation4.phpt diff --git a/ext/session/tests/session_decode_variation3.phpt b/ext/session/tests/session_decode_variation3.phpt new file mode 100644 index 0000000000..10b6851cac --- /dev/null +++ b/ext/session/tests/session_decode_variation3.phpt @@ -0,0 +1,90 @@ +--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 +--UEXPECTF-- +*** 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) { + [u"foo"]=> + int(1234567890) + [u"bar"]=> + unicode(5) "Blah!" + [u"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) { + [u"foo"]=> + int(1234567890) + [u"bar"]=> + unicode(5) "Blah!" + [u"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..62c4535f79 --- /dev/null +++ b/ext/session/tests/session_decode_variation4.phpt @@ -0,0 +1,80 @@ +--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 +--UEXPECTF-- +*** Testing session_decode() : variation *** +bool(true) +array(0) { +} +array(3) { + [u"foo"]=> + int(1234567890) + [u"bar"]=> + unicode(5) "Blah!" + [u"guff"]=> + float(123.456) +} +bool(true) +array(3) { + [u"foo"]=> + int(1234567890) + [u"bar"]=> + unicode(5) "Blah!" + [u"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..aefec954fc --- /dev/null +++ b/ext/session/tests/session_encode_variation7.phpt @@ -0,0 +1,41 @@ +--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 +--UEXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(0) "" +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..376c9ac1bf --- /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..e67597e4f1 --- /dev/null +++ b/ext/session/tests/session_id_error4.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_id() function : error functionality +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +*** Testing session_id() : error functionality *** +string(1) "0" +string(0) "" +bool(true) +string(40) "%s" +bool(true) +Done +--UEXPECTF-- +*** Testing session_id() : error functionality *** +unicode(1) "0" +string(0) "" +bool(true) +string(40) "%s" +bool(true) +Done + diff --git a/ext/session/tests/session_id_variation1.phpt b/ext/session/tests/session_id_variation1.phpt new file mode 100644 index 0000000000..282c31b6c4 --- /dev/null +++ b/ext/session/tests/session_id_variation1.phpt @@ -0,0 +1,59 @@ +--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 +--UEXPECTF-- +*** Testing session_id() : variation *** +unicode(1) "0" +string(0) "" +bool(true) +string(32) "%s" +bool(true) +unicode(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..38d2542473 --- /dev/null +++ b/ext/session/tests/session_id_variation2.phpt @@ -0,0 +1,74 @@ +--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 +--UEXPECTF-- +*** Testing session_id() : variation *** +unicode(0) "" +int(12) +unicode(1) "0" +unicode(1) "0" +string(0) "" +bool(true) +string(32) "%s" +bool(true) +unicode(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..54c42e086f --- /dev/null +++ b/ext/session/tests/session_module_name_variation4.phpt @@ -0,0 +1,91 @@ +--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) +--UEXPECTF-- +*** Testing session_module_name() : variation *** + +array(3) { + [u"Blah"]=> + unicode(12) "Hello World!" + [u"Foo"]=> + bool(false) + [u"Guff"]=> + int(1234567890) +} +NULL +array(3) { + [u"Blah"]=> + unicode(12) "Hello World!" + [u"Foo"]=> + bool(false) + [u"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..7f6e80466b --- /dev/null +++ b/ext/session/tests/session_save_path_variation4.phpt @@ -0,0 +1,70 @@ +--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 +--UEXPECTF-- +*** 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 +unicode(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..c677d4a8c0 --- /dev/null +++ b/ext/session/tests/session_save_path_variation5.phpt @@ -0,0 +1,69 @@ +--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 +--UEXPECTF-- +*** 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 +unicode(0) "" +bool(true) +unicode(0) "" +bool(true) +unicode(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..9885aa9fdd --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation4.phpt @@ -0,0 +1,116 @@ +--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) +--UEXPECTF-- +*** Testing session_set_save_handler() : variation *** + +Open [%s,PHPSESSID] +Read [%s,%s] +GC [0] +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(): 51 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +Close [%s,PHPSESSID] +NULL +Open [%s,PHPSESSID] +Read [%s,%s] +GC [0] +array(3) { + [u"Blah"]=> + unicode(12) "Hello World!" + [u"Foo"]=> + bool(false) + [u"Guff"]=> + int(1234567890) +} +Destroy [%s,%s] + +Warning: unlink(%s): No such file or directory in %s on line %d +Close [%s,PHPSESSID] +bool(true) + -- 2.50.1