diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/session/tests | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/session/tests')
194 files changed, 13829 insertions, 0 deletions
diff --git a/ext/session/tests/001.phpt b/ext/session/tests/001.phpt new file mode 100644 index 0000000..eb04dc1 --- /dev/null +++ b/ext/session/tests/001.phpt @@ -0,0 +1,36 @@ +--TEST-- +session object serialization +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +class foo { + public $bar = "ok"; + + function method() { $this->yes = "done"; } +} + +$baz = new foo; +$baz->method(); + +$arr[3] = new foo; +$arr[3]->method(); + +session_start(); + +$_SESSION["baz"] = $baz; +$_SESSION["arr"] = $arr; + +print session_encode()."\n"; + +session_destroy(); +--EXPECT-- +baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}} + diff --git a/ext/session/tests/002.phpt b/ext/session/tests/002.phpt new file mode 100644 index 0000000..6fff01e --- /dev/null +++ b/ext/session/tests/002.phpt @@ -0,0 +1,11 @@ +--TEST-- +session_unset() without a initialized session +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +error_reporting(E_ALL); +session_unset(); +print "ok\n"; +--EXPECT-- +ok diff --git a/ext/session/tests/003.phpt b/ext/session/tests/003.phpt new file mode 100644 index 0000000..03c3b95 --- /dev/null +++ b/ext/session/tests/003.phpt @@ -0,0 +1,45 @@ +--TEST-- +session object deserialization +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +class foo { + public $bar = "ok"; + function method() { $this->yes++; } +} + +session_id("abtest"); +session_start(); +session_decode('baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'); + +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); + +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); +session_destroy(); +--EXPECT-- +object(foo)#1 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#2 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} + diff --git a/ext/session/tests/004.phpt b/ext/session/tests/004.phpt new file mode 100644 index 0000000..aeb2c8b --- /dev/null +++ b/ext/session/tests/004.phpt @@ -0,0 +1,110 @@ +--TEST-- +session_set_save_handler test +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.name=PHPSESSID +session.serialize_handler=php +--FILE-- +<?php +error_reporting(E_ALL); + +class handler { + public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'; + function open($save_path, $session_name) + { + print "OPEN: $session_name\n"; + return true; + } + function close() + { + return true; + } + function read($key) + { + print "READ: $key\n"; + return $GLOBALS["hnd"]->data; + } + + function write($key, $val) + { + print "WRITE: $key, $val\n"; + $GLOBALS["hnd"]->data = $val; + return true; + } + + function destroy($key) + { + print "DESTROY: $key\n"; + return true; + } + + function gc() { return true; } +} + +$hnd = new handler; + +class foo { + public $bar = "ok"; + function method() { $this->yes++; } +} + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); + +session_id("abtest"); +session_start(); +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); + +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); + +session_write_close(); + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_start(); + +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); + +session_destroy(); +?> +--EXPECT-- +OPEN: PHPSESSID +READ: abtest +object(foo)#2 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#3 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} +WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}} +OPEN: PHPSESSID +READ: abtest +object(foo)#3 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#2 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} +DESTROY: abtest diff --git a/ext/session/tests/005.phpt b/ext/session/tests/005.phpt new file mode 100644 index 0000000..a970e6b --- /dev/null +++ b/ext/session/tests/005.phpt @@ -0,0 +1,151 @@ +--TEST-- +custom save handler, multiple session_start()s, complex data structure test. +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.name=PHPSESSID +session.serialize_handler=php +--FILE-- +<?php + +error_reporting(E_ALL); + +class handler { + public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'; + function open($save_path, $session_name) + { + print "OPEN: $session_name\n"; + return true; + } + function close() + { + print "CLOSE\n"; + return true; + } + function read($key) + { + print "READ: $key\n"; + return $GLOBALS["hnd"]->data; + } + + function write($key, $val) + { + print "WRITE: $key, $val\n"; + $GLOBALS["hnd"]->data = $val; + return true; + } + + function destroy($key) + { + print "DESTROY: $key\n"; + return true; + } + + function gc() { return true; } +} + +$hnd = new handler; + +class foo { + public $bar = "ok"; + function method() { $this->yes++; } +} + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); + +session_id("abtest"); +session_start(); +session_decode($hnd->data); + +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); + +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); + +session_write_close(); + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_start(); +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); + + +$_SESSION["c"] = 123; +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); +var_dump($_SESSION["c"]); + +session_write_close(); + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_start(); +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); +var_dump($_SESSION["c"]); + +session_destroy(); +?> +--EXPECTF-- +OPEN: PHPSESSID +READ: abtest +object(foo)#4 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#2 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} +WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}} +CLOSE +OPEN: PHPSESSID +READ: abtest +object(foo)#2 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) +} +array(1) { + [3]=> + object(foo)#4 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) + } +} +int(123) +WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:3;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:3;}}c|i:123; +CLOSE +OPEN: PHPSESSID +READ: abtest +object(foo)#4 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) +} +array(1) { + [3]=> + object(foo)#2 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) + } +} +int(123) +DESTROY: abtest +CLOSE + diff --git a/ext/session/tests/006.phpt b/ext/session/tests/006.phpt new file mode 100644 index 0000000..03fca10 --- /dev/null +++ b/ext/session/tests/006.phpt @@ -0,0 +1,69 @@ +--TEST-- +correct instantiation of references between variables in sessions +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); + +class a { + public $test = "hallo"; +} + +class b { + public $a; + function b(&$a) { + $this->a = &$a; + } +} + +$a = new a(); +$b = new b($a); + +echo "original values:\n"; +var_dump($a,$b); + +$_SESSION["a"] = $a; +$_SESSION["b"] = $b; +session_write_close(); + +unset($_SESSION["a"], $_SESSION["b"]); + +session_start(); + +echo "values after session:\n"; +var_dump($a,$b); +?> +--EXPECTF-- +original values: +object(a)#%d (1) { + ["test"]=> + string(5) "hallo" +} +object(b)#%d (1) { + ["a"]=> + &object(a)#%d (1) { + ["test"]=> + string(5) "hallo" + } +} +values after session: +object(a)#%d (1) { + ["test"]=> + string(5) "hallo" +} +object(b)#%d (1) { + ["a"]=> + &object(a)#%d (1) { + ["test"]=> + string(5) "hallo" + } +} diff --git a/ext/session/tests/009.phpt b/ext/session/tests/009.phpt new file mode 100644 index 0000000..d73bc23 --- /dev/null +++ b/ext/session/tests/009.phpt @@ -0,0 +1,56 @@ +--TEST-- +unset($_SESSION["name"]); test +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +session_id("abtest"); + +### Phase 1 cleanup +session_start(); +session_destroy(); + +### Phase 2 $_SESSION["c"] does not contain any value +session_id("abtest"); +session_start(); +var_dump($_SESSION); +$_SESSION["name"] = "foo"; +var_dump($_SESSION); +session_write_close(); + +### Phase 3 $_SESSION["c"] is set +session_start(); +var_dump($_SESSION); +unset($_SESSION["name"]); +var_dump($_SESSION); +session_write_close(); + +### Phase 4 final + +session_start(); +var_dump($_SESSION); +session_destroy(); +?> +--EXPECT-- +array(0) { +} +array(1) { + ["name"]=> + string(3) "foo" +} +array(1) { + ["name"]=> + string(3) "foo" +} +array(0) { +} +array(0) { +} + diff --git a/ext/session/tests/010.phpt b/ext/session/tests/010.phpt new file mode 100644 index 0000000..79638d2 --- /dev/null +++ b/ext/session/tests/010.phpt @@ -0,0 +1,16 @@ +--TEST-- +$session_array = explode(";", session_encode()); should not segfault +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +--FILE-- +<?php +error_reporting(E_ALL); + +$session_array = explode(";", @session_encode()); +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/011.phpt b/ext/session/tests/011.phpt new file mode 100644 index 0000000..ff1adba --- /dev/null +++ b/ext/session/tests/011.phpt @@ -0,0 +1,17 @@ +--TEST-- +session_decode(); should not segfault +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +--FILE-- +<?php +error_reporting(E_ALL); + +@session_decode("garbage data and no session started"); +@session_decode("userid|s:5:\"mazen\";chatRoom|s:1:\"1\";"); +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/012.phpt b/ext/session/tests/012.phpt new file mode 100644 index 0000000..8708011 --- /dev/null +++ b/ext/session/tests/012.phpt @@ -0,0 +1,32 @@ +--TEST-- +registering $_SESSION should not segfault +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +### Absurd example, value of $_SESSION does not matter + +session_id("abtest"); +session_start(); +$_SESSION["_SESSION"] = Array(); +$_SESSION = "kk"; + +session_write_close(); + +### Restart to test for $_SESSION brokenness + +session_start(); +$_SESSION = "kk"; +session_destroy(); + +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/013.phpt b/ext/session/tests/013.phpt new file mode 100644 index 0000000..8d0f284 --- /dev/null +++ b/ext/session/tests/013.phpt @@ -0,0 +1,24 @@ +--TEST-- +redefining SID should not cause warnings +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); +session_destroy(); +session_id("abtest2"); +session_start(); +session_destroy(); + +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/014.phpt b/ext/session/tests/014.phpt new file mode 100644 index 0000000..73bc28e --- /dev/null +++ b/ext/session/tests/014.phpt @@ -0,0 +1,39 @@ +--TEST-- +a script should not be able to modify session.use_trans_sid +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_trans_sid=0 +session.use_cookies=0 +session.cache_limiter= +session.name=PHPSESSID +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); + +?> +<a href="/link"> +<?php +ini_set("session.use_trans_sid","1"); +?> +<a href="/link"> +<?php +ini_set("session.use_trans_sid","0"); +?> +<a href="/link"> +<?php +session_destroy(); +?> +--EXPECTF-- +<a href="/link"> + +Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line %d +<a href="/link"> + +Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line %d +<a href="/link"> diff --git a/ext/session/tests/015.phpt b/ext/session/tests/015.phpt new file mode 100644 index 0000000..7d7b737 --- /dev/null +++ b/ext/session/tests/015.phpt @@ -0,0 +1,26 @@ +--TEST-- +use_trans_sid should not affect SID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_trans_sid=1 +session.use_cookies=0 +session.use_only_cookies=0 +session.cache_limiter= +arg_separator.output=& +session.name=PHPSESSID +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); +?> +<a href="/link?<?php echo SID; ?>"> +<?php +session_destroy(); +?> +--EXPECT-- +<a href="/link?PHPSESSID=abtest&PHPSESSID=abtest"> diff --git a/ext/session/tests/016.phpt b/ext/session/tests/016.phpt new file mode 100644 index 0000000..8370329 --- /dev/null +++ b/ext/session/tests/016.phpt @@ -0,0 +1,25 @@ +--TEST-- +invalid session.save_path should not cause a segfault +--SKIPIF-- +<?php +if (!extension_loaded("session")) { + die("skip Session module not loaded"); +} +?> +--INI-- +session.save_path="123;:/really\\completely:::/invalid;;,23123;213" +session.use_cookies=0 +session.cache_limiter= +session.save_handler=files +session.serialize_handler=php +--FILE-- +<?php +error_reporting(E_ALL); + +@session_start(); +$HTTP_SESSION_VARS["test"] = 1; +@session_write_close(); +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/017.phpt b/ext/session/tests/017.phpt new file mode 100644 index 0000000..dbe53f5 --- /dev/null +++ b/ext/session/tests/017.phpt @@ -0,0 +1,26 @@ +--TEST-- +setting $_SESSION before session_start() should not cause segfault +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + +error_reporting(E_ALL); + +class Kill { + function Kill() { + global $HTTP_SESSION_VARS; + session_start(); + } +} +$k = new Kill(); + +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/018.phpt b/ext/session/tests/018.phpt new file mode 100644 index 0000000..def1f41 --- /dev/null +++ b/ext/session/tests/018.phpt @@ -0,0 +1,26 @@ +--TEST-- +rewriter correctly handles attribute names which contain dashes +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.use_only_cookies=0 +session.cache_limiter= +session.use_trans_sid=1 +session.name=PHPSESSID +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); +?> +<form accept-charset="ISO-8859-15, ISO-8859-1" action=url.php> +<?php +session_destroy(); +?> +--EXPECT-- +<form accept-charset="ISO-8859-15, ISO-8859-1" action=url.php><input type="hidden" name="PHPSESSID" value="abtest" /> diff --git a/ext/session/tests/019.phpt b/ext/session/tests/019.phpt new file mode 100644 index 0000000..3ee8ccd --- /dev/null +++ b/ext/session/tests/019.phpt @@ -0,0 +1,73 @@ +--TEST-- +serializing references test case using globals +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + +error_reporting(E_ALL); + +class TFoo { + public $c; + function TFoo($c) { + $this->c = $c; + } + function inc() { + $this->c++; + } +} + +session_id("abtest"); +session_start(); + +$_SESSION["o1"] = new TFoo(42); +$_SESSION["o2"] =& $_SESSION["o1"]; + +session_write_close(); + +unset($_SESSION["o1"]); +unset($_SESSION["o2"]); + +session_start(); + +var_dump($_SESSION); + +$_SESSION["o1"]->inc(); +$_SESSION["o2"]->inc(); + +var_dump($_SESSION); + +session_destroy(); +?> +--EXPECTF-- + +array(2) { + ["o1"]=> + &object(TFoo)#%d (1) { + ["c"]=> + int(42) + } + ["o2"]=> + &object(TFoo)#%d (1) { + ["c"]=> + int(42) + } +} +array(2) { + ["o1"]=> + &object(TFoo)#%d (1) { + ["c"]=> + int(44) + } + ["o2"]=> + &object(TFoo)#%d (1) { + ["c"]=> + int(44) + } +} + diff --git a/ext/session/tests/020.phpt b/ext/session/tests/020.phpt new file mode 100644 index 0000000..f43bac5 --- /dev/null +++ b/ext/session/tests/020.phpt @@ -0,0 +1,27 @@ +--TEST-- +rewriter uses arg_seperator.output for modifying URLs +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.use_only_cookies=0 +session.cache_limiter= +session.use_trans_sid=1 +arg_separator.output="&" +session.name=PHPSESSID +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); +?> +<a href="link.php?a=b"> +<?php +session_destroy(); +?> +--EXPECT-- +<a href="link.php?a=b&PHPSESSID=abtest"> diff --git a/ext/session/tests/021.phpt b/ext/session/tests/021.phpt new file mode 100644 index 0000000..1ad3c5d --- /dev/null +++ b/ext/session/tests/021.phpt @@ -0,0 +1,63 @@ +--TEST-- +rewriter handles form and fieldset tags correctly +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.use_only_cookies=0 +session.cache_limiter= +session.use_trans_sid=1 +url_rewriter.tags="a=href,area=href,frame=src,input=src,form=,fieldset=" +session.name=PHPSESSID +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); +?> +<form> +<fieldset> +<?php + +ob_flush(); + +ini_set("url_rewriter.tags", "a=href,area=href,frame=src,input=src,form="); + +?> +<form> +<fieldset> +<?php + +ob_flush(); + +ini_set("url_rewriter.tags", "a=href,area=href,frame=src,input=src,form=fakeentry"); + +?> +<form> +<fieldset> +<?php + +ob_flush(); + +ini_set("url_rewriter.tags", "a=href,fieldset=,area=href,frame=src,input=src"); + +?> +<form> +<fieldset> +<?php + +session_destroy(); +?> +--EXPECT-- +<form><input type="hidden" name="PHPSESSID" value="abtest" /> +<fieldset><input type="hidden" name="PHPSESSID" value="abtest" /> +<form><input type="hidden" name="PHPSESSID" value="abtest" /> +<fieldset> +<form><input type="hidden" name="PHPSESSID" value="abtest" /> +<fieldset> +<form> +<fieldset><input type="hidden" name="PHPSESSID" value="abtest" /> diff --git a/ext/session/tests/022.phpt b/ext/session/tests/022.phpt new file mode 100644 index 0000000..5923bbe --- /dev/null +++ b/ext/session/tests/022.phpt @@ -0,0 +1,32 @@ +--TEST-- +session object serialization +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +class foo { + public $bar = "ok"; + + function method() { $this->yes = "done"; } +} + +$baz = new foo; +$baz->method(); + +$arr[3] = new foo; +$arr[3]->method(); +session_start(); +$_SESSION["baz"] = $baz; +$_SESSION["arr"] = $arr; +var_dump(session_encode()); +session_destroy(); +?> +--EXPECT-- +string(126) "baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}}" diff --git a/ext/session/tests/023.phpt b/ext/session/tests/023.phpt new file mode 100644 index 0000000..42b1e5b --- /dev/null +++ b/ext/session/tests/023.phpt @@ -0,0 +1,46 @@ +--TEST-- +session object deserialization +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +class foo { + public $bar = "ok"; + function method() { $this->yes++; } +} + +session_id("abtest"); +session_start(); +session_decode('baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'); +$baz = $_SESSION['baz']; +$arr = $_SESSION['arr']; + +$baz->method(); +$arr[3]->method(); + +var_dump($baz); +var_dump($arr); +session_destroy(); +--EXPECT-- +object(foo)#1 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#2 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} diff --git a/ext/session/tests/024.phpt b/ext/session/tests/024.phpt new file mode 100644 index 0000000..2ad2606 --- /dev/null +++ b/ext/session/tests/024.phpt @@ -0,0 +1,114 @@ +--TEST-- +session_set_save_handler test +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.name=PHPSESSID +session.serialize_handler=php +--FILE-- +<?php +error_reporting(E_ALL); + +class handler { + public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'; + + function open($save_path, $session_name) + { + print "OPEN: $session_name\n"; + return true; + } + function close() + { + return true; + } + function read($key) + { + print "READ: $key\n"; + return $GLOBALS["hnd"]->data; + } + + function write($key, $val) + { + print "WRITE: $key, $val\n"; + $GLOBALS["hnd"]->data = $val; + return true; + } + + function destroy($key) + { + print "DESTROY: $key\n"; + return true; + } + + function gc() { return true; } +} + +$hnd = new handler; + +class foo { + public $bar = "ok"; + function method() { $this->yes++; } +} + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); + +session_id("abtest"); +session_start(); + +$baz = $_SESSION['baz']; +$arr = $_SESSION['arr']; +$baz->method(); +$arr[3]->method(); + +var_dump($baz); +var_dump($arr); + +session_write_close(); + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_start(); + +var_dump($baz); +var_dump($arr); + +session_destroy(); +?> +--EXPECTF-- +OPEN: PHPSESSID +READ: abtest +object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} +WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}} +OPEN: PHPSESSID +READ: abtest +object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} +DESTROY: abtest diff --git a/ext/session/tests/025.phpt b/ext/session/tests/025.phpt new file mode 100644 index 0000000..4fd095f --- /dev/null +++ b/ext/session/tests/025.phpt @@ -0,0 +1,159 @@ +--TEST-- +custom save handler, multiple session_start()s, complex data structure test. +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.name=PHPSESSID +session.serialize_handler=php +--FILE-- +<?php + +error_reporting(E_ALL); + +class handler { + public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'; + + function open($save_path, $session_name) + { + print "OPEN: $session_name\n"; + return true; + } + function close() + { + print "CLOSE\n"; + return true; + } + function read($key) + { + print "READ: $key\n"; + return $GLOBALS["hnd"]->data; + } + + function write($key, $val) + { + print "WRITE: $key, $val\n"; + $GLOBALS["hnd"]->data = $val; + return true; + } + + function destroy($key) + { + print "DESTROY: $key\n"; + return true; + } + + function gc() { return true; } + + function __construct() + { + if (ini_get("unicode.semantics")) { + $this->data = str_replace('s:', 'U:', $this->data); + } + } +} + +$hnd = new handler; + +class foo { + public $bar = "ok"; + function method() { $this->yes++; } +} + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); + +session_id("abtest"); +session_start(); +$baz = $_SESSION['baz']; +$arr = $_SESSION['arr']; +$baz->method(); +$arr[3]->method(); + +var_dump($baz); +var_dump($arr); + +session_write_close(); + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_start(); +$baz = $_SESSION['baz']; +$arr = $_SESSION['arr']; + + +$baz->method(); +$arr[3]->method(); + + +$c = 123; +$_SESSION['c'] = $c; +var_dump($baz); var_dump($arr); var_dump($c); + +session_write_close(); + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_start(); +var_dump($baz); var_dump($arr); var_dump($c); + +session_destroy(); +?> +--EXPECTF-- +OPEN: PHPSESSID +READ: abtest +object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} +WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}} +CLOSE +OPEN: PHPSESSID +READ: abtest +object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) +} +array(1) { + [3]=> + object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) + } +} +int(123) +WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:3;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:3;}}c|i:123; +CLOSE +OPEN: PHPSESSID +READ: abtest +object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) +} +array(1) { + [3]=> + object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) + } +} +int(123) +DESTROY: abtest +CLOSE diff --git a/ext/session/tests/026.phpt b/ext/session/tests/026.phpt new file mode 100644 index 0000000..06c135d --- /dev/null +++ b/ext/session/tests/026.phpt @@ -0,0 +1,71 @@ +--TEST-- +correct instantiation of references between variables in sessions +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); + +class a { + public $test = "hallo"; +} + +class b { + public $a; + function b(&$a) { + $this->a = &$a; + } +} + +$a = new a(); +$b = new b($a); + +echo "original values:\n"; +var_dump($a,$b); + +$_SESSION['a'] = $a; +$_SESSION['b'] = $b; + +session_write_close(); +unset($_SESSION['a']); +unset($_SESSION['b']); + +session_start(); +$a = $_SESSION['a']; +$b = $_SESSION['b']; +echo "values after session:\n"; +var_dump($a,$b); +?> +--EXPECTF-- +original values: +object(a)#%d (1) { + ["test"]=> + string(5) "hallo" +} +object(b)#%d (1) { + ["a"]=> + &object(a)#%d (1) { + ["test"]=> + string(5) "hallo" + } +} +values after session: +object(a)#%d (1) { + ["test"]=> + string(5) "hallo" +} +object(b)#%d (1) { + ["a"]=> + &object(a)#%d (1) { + ["test"]=> + string(5) "hallo" + } +} diff --git a/ext/session/tests/027.phpt b/ext/session/tests/027.phpt new file mode 100644 index 0000000..600a992 --- /dev/null +++ b/ext/session/tests/027.phpt @@ -0,0 +1,55 @@ +--TEST-- +unset($_SESSION["name"]); should work +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +session_id("abtest"); + +### Phase 1 cleanup +session_start(); +session_destroy(); + +### Phase 2 $_SESSION["c"] does not contain any value +session_id("abtest"); +session_start(); +var_dump($_SESSION); +$_SESSION["name"] = "foo"; +var_dump($_SESSION); +session_write_close(); + +### Phase 3 $_SESSION["c"] is set +session_start(); +var_dump($_SESSION); +unset($_SESSION["name"]); +var_dump($_SESSION); +session_write_close(); + +### Phase 4 final + +session_start(); +var_dump($_SESSION); +session_destroy(); +?> +--EXPECT-- +array(0) { +} +array(1) { + ["name"]=> + string(3) "foo" +} +array(1) { + ["name"]=> + string(3) "foo" +} +array(0) { +} +array(0) { +} diff --git a/ext/session/tests/028.phpt b/ext/session/tests/028.phpt new file mode 100644 index 0000000..79638d2 --- /dev/null +++ b/ext/session/tests/028.phpt @@ -0,0 +1,16 @@ +--TEST-- +$session_array = explode(";", session_encode()); should not segfault +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +--FILE-- +<?php +error_reporting(E_ALL); + +$session_array = explode(";", @session_encode()); +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/029.phpt b/ext/session/tests/029.phpt new file mode 100644 index 0000000..ff1adba --- /dev/null +++ b/ext/session/tests/029.phpt @@ -0,0 +1,17 @@ +--TEST-- +session_decode(); should not segfault +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +--FILE-- +<?php +error_reporting(E_ALL); + +@session_decode("garbage data and no session started"); +@session_decode("userid|s:5:\"mazen\";chatRoom|s:1:\"1\";"); +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/030.phpt b/ext/session/tests/030.phpt new file mode 100644 index 0000000..8d0f284 --- /dev/null +++ b/ext/session/tests/030.phpt @@ -0,0 +1,24 @@ +--TEST-- +redefining SID should not cause warnings +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); +session_destroy(); +session_id("abtest2"); +session_start(); +session_destroy(); + +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/031.phpt b/ext/session/tests/031.phpt new file mode 100644 index 0000000..e8deb3d --- /dev/null +++ b/ext/session/tests/031.phpt @@ -0,0 +1,22 @@ +--TEST-- +setting hash_function to sha512 and hash_bits_per_character > 4 should not crash +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +session.hash_function=sha512 +session.hash_bits_per_character=5 +--FILE-- +<?php +error_reporting(E_ALL); + +session_start(); +session_regenerate_id(TRUE); + +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/bug24592.phpt b/ext/session/tests/bug24592.phpt new file mode 100644 index 0000000..9f6c395 --- /dev/null +++ b/ext/session/tests/bug24592.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #24592 (crash when multiple NULL values are being stored) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +html_errors=0 +session.save_handler=files +--FILE-- +<?php +@session_start(); + +$foo = $_SESSION['foo']; +$bar = $_SESSION['bar']; + +var_dump($foo, $bar, $_SESSION); + +$_SESSION['foo'] = $foo; +$_SESSION['bar'] = $bar; + +var_dump($_SESSION); +?> +--EXPECTF-- +Notice: Undefined index: foo in %s on line %d + +Notice: Undefined index: bar in %s on line %d +NULL +NULL +array(0) { +} +array(2) { + ["foo"]=> + NULL + ["bar"]=> + NULL +} diff --git a/ext/session/tests/bug26862.phpt b/ext/session/tests/bug26862.phpt new file mode 100644 index 0000000..7990f74 --- /dev/null +++ b/ext/session/tests/bug26862.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #26862 (ob_flush() before output_reset_rewrite_vars() results in data loss) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +html_errors=0 +session.use_trans_sid=0 +session.save_handler=files +--FILE-- +<?php +session_start(); +output_add_rewrite_var('var', 'value'); + +echo '<a href="file.php">link</a>'; + +ob_flush(); + +output_reset_rewrite_vars(); +echo '<a href="file.php">link</a>'; +?> +--EXPECT-- +<a href="file.php?var=value">link</a><a href="file.php">link</a> diff --git a/ext/session/tests/bug31454.phpt b/ext/session/tests/bug31454.phpt new file mode 100644 index 0000000..dd60996 --- /dev/null +++ b/ext/session/tests/bug31454.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #31454 (session_set_save_handler crashes PHP when supplied non-existent object ref) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +session_set_save_handler( + array(&$arf, 'open'), + array(&$arf, 'close'), + array(&$arf, 'read'), + array(&$arf, 'write'), + array(&$arf, 'destroy'), + array(&$arf, 'gc')); + +echo "Done\n"; +?> +--EXPECTF-- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %sbug31454.php on line %d +Done diff --git a/ext/session/tests/bug32330.phpt b/ext/session/tests/bug32330.phpt new file mode 100644 index 0000000..98d442a --- /dev/null +++ b/ext/session/tests/bug32330.phpt @@ -0,0 +1,85 @@ +--TEST-- +Bug #32330 (session_destroy, "Failed to initialize storage module", custom session handler) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_trans_sid=0 +session.use_cookies=1 +session.name=sid +session.save_path=/tmp +session.gc_probability=1 +session.gc_divisor=1 +--FILE-- +<?php +error_reporting(E_ALL); + +function sOpen($path, $name) +{ + echo "open: path = {$path}, name = {$name}\n"; + return TRUE; +} + +function sClose() +{ + echo "close\n"; + return TRUE; +} + +function sRead($id) +{ + echo "read: id = {$id}\n"; + return ''; +} + +function sWrite($id, $data) +{ + echo "write: id = {$id}, data = {$data}\n"; + return TRUE; +} + +function sDestroy($id) +{ + echo "destroy: id = {$id}\n"; + return TRUE; +} + +function sGC($maxlifetime) +{ + echo "gc: maxlifetime = {$maxlifetime}\n"; + return TRUE; +} + +session_set_save_handler( 'sOpen', 'sClose', 'sRead', 'sWrite', 'sDestroy', 'sGC' ); + +// without output buffering, the debug messages will cause all manner of warnings +ob_start(); + +session_start(); +$_SESSION['A'] = 'B'; +session_write_close(); + +session_start(); +$_SESSION['C'] = 'D'; +session_destroy(); + +session_start(); +$_SESSION['E'] = 'F'; +// Don't try to destroy this time! + +?> +--EXPECTF-- +open: path = /tmp, name = sid +read: id = %s +gc: maxlifetime = %d +write: id = %s, data = A|s:1:"B"; +close +open: path = /tmp, name = sid +read: id = %s +gc: maxlifetime = %d +destroy: id = %s +close +open: path = /tmp, name = sid +read: id = %s +gc: maxlifetime = %d +write: id = %s, data = E|s:1:"F"; +close diff --git a/ext/session/tests/bug36459.phpt b/ext/session/tests/bug36459.phpt new file mode 100644 index 0000000..66a4ac1 --- /dev/null +++ b/ext/session/tests/bug36459.phpt @@ -0,0 +1,42 @@ +--TEST--
+Bug #31454 (Incorrect adding PHPSESSID to links, which contains \r\n)
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--INI--
+session.use_trans_sid=1
+session.use_cookies=0
+session.use_only_cookies=0
+session.name=sid
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+session_start();
+
+# Do not remove \r from this tests, they are essential!
+?>
+<html>
+ <head>
+ <title>Bug #36459 Incorrect adding PHPSESSID to links, which contains \r\n</title>
+ </head>
+ <body>
+ <p>See source html code</p>
+ <a href="/b2w/www/ru/adm/pages/?action=prev&rec_id=8&pid=2"
+ style="font: normal 11pt Times New Roman">incorrect link</a><br />
+ <br />
+ <a href="/b2w/www/ru/adm/pages/?action=prev&rec_id=8&pid=2" style="font: normal 11pt Times New Roman">correct link</a>
+ </body>
+</html>
+--EXPECTF--
+<html>
+ <head>
+ <title>Bug #36459 Incorrect adding PHPSESSID to links, which contains \r\n</title>
+ </head>
+ <body>
+ <p>See source html code</p>
+ <a href="/b2w/www/ru/adm/pages/?action=prev&rec_id=8&pid=2&sid=%s"
+ style="font: normal 11pt Times New Roman">incorrect link</a><br />
+ <br />
+ <a href="/b2w/www/ru/adm/pages/?action=prev&rec_id=8&pid=2&sid=%s" style="font: normal 11pt Times New Roman">correct link</a>
+ </body>
+</html>
diff --git a/ext/session/tests/bug38377.phpt b/ext/session/tests/bug38377.phpt new file mode 100644 index 0000000..bd33bdd --- /dev/null +++ b/ext/session/tests/bug38377.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #38377 (session_destroy() gives warning after session_regenerate_id()) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +session_start(); +session_regenerate_id(); +session_destroy(); +echo "Done\n"; +?> +--EXPECT-- +Done diff --git a/ext/session/tests/bug41600.phpt b/ext/session/tests/bug41600.phpt new file mode 100644 index 0000000..690347a --- /dev/null +++ b/ext/session/tests/bug41600.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #41600 (url rewriter tags doesn't work with namespaced tags) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.use_only_cookies=0 +session.cache_limiter= +session.use_trans_sid=1 +arg_separator.output="&" +session.name=PHPSESSID +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); +?> +<a href="link.php?a=b"> +<?php +session_destroy(); +?> +--EXPECT-- +<a href="link.php?a=b&PHPSESSID=abtest"> diff --git a/ext/session/tests/bug42596.phpt b/ext/session/tests/bug42596.phpt new file mode 100644 index 0000000..3d11607 --- /dev/null +++ b/ext/session/tests/bug42596.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #42596 (session.save_path MODE option will not set "write" bit for group or world) +--SKIPIF-- +<?php + if(substr(PHP_OS, 0, 3) == "WIN") die("skip not for Windows"); + include('skipif.inc'); +?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.use_trans_sid=1 +arg_separator.output="&" +session.name=PHPSESSID +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +$sessdir = dirname(__FILE__).'/sessions/'; +@rmdir($sessdir); +mkdir($sessdir); +$save_path = '0;0777;'.$sessdir; +umask(0); +session_save_path($save_path); +session_start(); +echo "hello world\n"; +session_write_close(); + +foreach (glob($sessdir. "*") as $sessfile) { + var_dump(decoct(fileperms($sessfile))); + unlink($sessfile); +} +rmdir($sessdir); +--EXPECT-- +hello world +string(6) "100777" + diff --git a/ext/session/tests/bug51338.phpt b/ext/session/tests/bug51338.phpt new file mode 100644 index 0000000..d806c0b --- /dev/null +++ b/ext/session/tests/bug51338.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #51338 (URL-Rewriter should not get enabled if use_only_cookies is set to 1) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_only_cookies=1 +session.use_trans_sid=1 +--FILE-- +<?php +session_start(); +print_r(ob_list_handlers()); +--EXPECT-- +Array +( +) diff --git a/ext/session/tests/bug53141.phpt b/ext/session/tests/bug53141.phpt new file mode 100644 index 0000000..765d272 --- /dev/null +++ b/ext/session/tests/bug53141.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #53141 (autoload misbehaves if called from closing session) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +spl_autoload_register(function ($class) { + var_dump("Loading $class"); + eval('class Bar {}'); +}); + +class Foo +{ + function __sleep() + { + new Bar; + return array(); + } +} + +session_start(); +$_SESSION['foo'] = new Foo; + +?> +--EXPECT-- +string(11) "Loading Bar"
\ No newline at end of file diff --git a/ext/session/tests/bug55688.phpt b/ext/session/tests/bug55688.phpt new file mode 100644 index 0000000..8db4838 --- /dev/null +++ b/ext/session/tests/bug55688.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #55688 (Crash when calling SessionHandler::gc()) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +html_errors=0 +session.save_handler=files +--FILE-- +<?php +ini_set('session.save_handler', 'files'); +$x = new SessionHandler; +$x->gc(1); +?> +--EXPECTF-- +Warning: SessionHandler::gc(): Parent session handler is not open in %s on line %d diff --git a/ext/session/tests/bug60634.phpt b/ext/session/tests/bug60634.phpt new file mode 100644 index 0000000..2ec0c26 --- /dev/null +++ b/ext/session/tests/bug60634.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) +--XFAIL-- +Long term low priority bug, working on it +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +function open($save_path, $session_name) { + return true; +} + +function close() { + die("close: goodbye cruel world\n"); +} + +function read($id) { + return ''; +} + +function write($id, $session_data) { + die("write: goodbye cruel world\n"); +} + +function destroy($id) { + return true; +} + +function gc($maxlifetime) { + return true; +} + +session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc'); +session_start(); +session_write_close(); +echo "um, hi\n"; + +?> +--EXPECTF-- +write: goodbye cruel world diff --git a/ext/session/tests/bug60634_error_1.phpt b/ext/session/tests/bug60634_error_1.phpt new file mode 100644 index 0000000..3b6e394 --- /dev/null +++ b/ext/session/tests/bug60634_error_1.phpt @@ -0,0 +1,49 @@ +--TEST-- +Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - fatal error in write during exec +--XFAIL-- +Long term low priority bug, working on it +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +function open($save_path, $session_name) { + return true; +} + +function close() { + echo "close: goodbye cruel world\n"; +} + +function read($id) { + return ''; +} + +function write($id, $session_data) { + echo "write: goodbye cruel world\n"; + undefined_function(); +} + +function destroy($id) { + return true; +} + +function gc($maxlifetime) { + return true; +} + +session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc'); +session_start(); +session_write_close(); +echo "um, hi\n"; + +?> +--EXPECTF-- +write: goodbye cruel world + +Fatal error: Call to undefined function undefined_function() in %s on line %d diff --git a/ext/session/tests/bug60634_error_2.phpt b/ext/session/tests/bug60634_error_2.phpt new file mode 100644 index 0000000..265fb30 --- /dev/null +++ b/ext/session/tests/bug60634_error_2.phpt @@ -0,0 +1,49 @@ +--TEST-- +Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - exception in write during exec +--XFAIL-- +Long term low priority bug, working on it +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +function open($save_path, $session_name) { + return true; +} + +function close() { + echo "close: goodbye cruel world\n"; +} + +function read($id) { + return ''; +} + +function write($id, $session_data) { + echo "write: goodbye cruel world\n"; + throw new Exception; +} + +function destroy($id) { + return true; +} + +function gc($maxlifetime) { + return true; +} + +session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc'); +session_start(); +session_write_close(); +echo "um, hi\n"; + +?> +--EXPECTF-- +write: goodbye cruel world + +Fatal error: Uncaught exception 'Exception' in %s diff --git a/ext/session/tests/bug60634_error_3.phpt b/ext/session/tests/bug60634_error_3.phpt new file mode 100644 index 0000000..b2004d6 --- /dev/null +++ b/ext/session/tests/bug60634_error_3.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - fatal error in write after exec +--XFAIL-- +Long term low priority bug, working on it +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +function open($save_path, $session_name) { + return true; +} + +function close() { + echo "close: goodbye cruel world\n"; + exit; +} + +function read($id) { + return ''; +} + +function write($id, $session_data) { + echo "write: goodbye cruel world\n"; + undefined_function(); +} + +function destroy($id) { + return true; +} + +function gc($maxlifetime) { + return true; +} + +session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc'); +session_start(); + +?> +--EXPECTF-- +write: goodbye cruel world + +Fatal error: Call to undefined function undefined_function() in %s on line %d diff --git a/ext/session/tests/bug60634_error_4.phpt b/ext/session/tests/bug60634_error_4.phpt new file mode 100644 index 0000000..60bc0dc --- /dev/null +++ b/ext/session/tests/bug60634_error_4.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - exception in write after exec +--XFAIL-- +Long term low priority bug, working on it +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +function open($save_path, $session_name) { + return true; +} + +function close() { + echo "close: goodbye cruel world\n"; + exit; +} + +function read($id) { + return ''; +} + +function write($id, $session_data) { + echo "write: goodbye cruel world\n"; + throw new Exception; +} + +function destroy($id) { + return true; +} + +function gc($maxlifetime) { + return true; +} + +session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc'); +session_start(); + +?> +--EXPECTF-- +write: goodbye cruel world + +Fatal error: Uncaught exception 'Exception' in %s diff --git a/ext/session/tests/bug60634_error_5.phpt b/ext/session/tests/bug60634_error_5.phpt new file mode 100644 index 0000000..8081ab9 --- /dev/null +++ b/ext/session/tests/bug60634_error_5.phpt @@ -0,0 +1,47 @@ +--TEST-- +Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - fatal error in close during exec +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +function open($save_path, $session_name) { + return true; +} + +function close() { + echo "close: goodbye cruel world\n"; + undefined_function(); +} + +function read($id) { + return ''; +} + +function write($id, $session_data) { + return true; +} + +function destroy($id) { + return true; +} + +function gc($maxlifetime) { + return true; +} + +session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc'); +session_start(); +session_write_close(); +echo "um, hi\n"; + +?> +--EXPECTF-- +close: goodbye cruel world + +Fatal error: Call to undefined function undefined_function() in %s on line %d diff --git a/ext/session/tests/bug60860.phpt b/ext/session/tests/bug60860.phpt new file mode 100644 index 0000000..8318586 --- /dev/null +++ b/ext/session/tests/bug60860.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #60860 (session.save_handler=user without defined function core dumps) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_handler=user +--FILE-- +<?php + +session_start(); +echo "ok\n"; + +?> +--EXPECTF-- +Warning: session_start(): user session functions not defined in %s on line 3 + +Fatal error: session_start(): Failed to initialize storage module: user (path:%s) in %s on line 3 diff --git a/ext/session/tests/bug61728.phpt b/ext/session/tests/bug61728.phpt new file mode 100644 index 0000000..3f8dbeb --- /dev/null +++ b/ext/session/tests/bug61728.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bug #61728 (PHP crash when calling ob_start in request_shutdown phase) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +function output_html($ext) { + return strlen($ext); +} + +function open ($save_path, $session_name) { + return true; +} + +function close() { + return true; +} + +function read ($id) { +} + +function write ($id, $sess_data) { + ob_start("output_html"); + echo "laruence"; + ob_end_flush(); + return true; +} + +function destroy ($id) { +} + +function gc ($maxlifetime) { + return true; +} + +session_set_save_handler ("open", "close", "read", "write", "destroy", "gc"); +session_start(); +--EXPECTF-- +8 diff --git a/ext/session/tests/bug63379.phpt b/ext/session/tests/bug63379.phpt new file mode 100644 index 0000000..8094182 --- /dev/null +++ b/ext/session/tests/bug63379.phpt @@ -0,0 +1,57 @@ +--TEST-- +Bug #63379: Warning when using session_regenerate_id(TRUE) with a SessionHandler +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +$handler = new SessionHandler; +session_set_save_handler($handler); + +session_start(); + +$_SESSION['foo'] = 'hello'; +var_dump($_SESSION); + +session_regenerate_id(true); + +echo "*** Regenerated ***\n"; +var_dump($_SESSION); + +$_SESSION['bar'] = 'world'; + +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +--EXPECTF-- +array(1) { + ["foo"]=> + string(5) "hello" +} +*** Regenerated *** +array(1) { + ["foo"]=> + string(5) "hello" +} +array(2) { + ["foo"]=> + string(5) "hello" + ["bar"]=> + string(5) "world" +} +array(2) { + ["foo"]=> + string(5) "hello" + ["bar"]=> + string(5) "world" +} diff --git a/ext/session/tests/bug63379_nodestroy.phpt b/ext/session/tests/bug63379_nodestroy.phpt new file mode 100644 index 0000000..03a9ae7 --- /dev/null +++ b/ext/session/tests/bug63379_nodestroy.phpt @@ -0,0 +1,57 @@ +--TEST-- +Bug #63379: Warning when using session_regenerate_id(TRUE) with a SessionHandler +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +$handler = new SessionHandler; +session_set_save_handler($handler); + +session_start(); + +$_SESSION['foo'] = 'hello'; +var_dump($_SESSION); + +session_regenerate_id(false); + +echo "*** Regenerated ***\n"; +var_dump($_SESSION); + +$_SESSION['bar'] = 'world'; + +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +--EXPECTF-- +array(1) { + ["foo"]=> + string(5) "hello" +} +*** Regenerated *** +array(1) { + ["foo"]=> + string(5) "hello" +} +array(2) { + ["foo"]=> + string(5) "hello" + ["bar"]=> + string(5) "world" +} +array(2) { + ["foo"]=> + string(5) "hello" + ["bar"]=> + string(5) "world" +} diff --git a/ext/session/tests/rfc1867.phpt b/ext/session/tests/rfc1867.phpt new file mode 100644 index 0000000..dc44e8b --- /dev/null +++ b/ext/session/tests/rfc1867.phpt @@ -0,0 +1,129 @@ +--TEST-- +session rfc1867 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +session.upload_progress.min_freq=0.000000001 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_cleanup.phpt b/ext/session/tests/rfc1867_cleanup.phpt new file mode 100644 index 0000000..f70b395 --- /dev/null +++ b/ext/session/tests/rfc1867_cleanup.phpt @@ -0,0 +1,83 @@ +--TEST-- +session rfc1867 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=1 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +session.upload_progress.min_freq=0.000000001 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_cleanup.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_disabled.phpt b/ext/session/tests/rfc1867_disabled.phpt new file mode 100644 index 0000000..4490055 --- /dev/null +++ b/ext/session/tests/rfc1867_disabled.phpt @@ -0,0 +1,76 @@ +--TEST-- +session rfc1867 disabled +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=0 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_disabled_2.phpt b/ext/session/tests/rfc1867_disabled_2.phpt new file mode 100644 index 0000000..e878f46 --- /dev/null +++ b/ext/session/tests/rfc1867_disabled_2.phpt @@ -0,0 +1,76 @@ +--TEST-- +session rfc1867 disabled 2 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_inter.phpt b/ext/session/tests/rfc1867_inter.phpt new file mode 100644 index 0000000..7686371 --- /dev/null +++ b/ext/session/tests/rfc1867_inter.phpt @@ -0,0 +1,133 @@ +--TEST-- +session rfc1867 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +session.upload_progress.min_freq=0.000000001 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_inter.php_1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_inter.php_2 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__) . "_1"]); +var_dump($_SESSION["upload_progress_" . basename(__FILE__) . "_2"]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} +NULL diff --git a/ext/session/tests/rfc1867_invalid_settings-win.phpt b/ext/session/tests/rfc1867_invalid_settings-win.phpt new file mode 100644 index 0000000..ed854e8 --- /dev/null +++ b/ext/session/tests/rfc1867_invalid_settings-win.phpt @@ -0,0 +1,19 @@ +--TEST-- +session rfc1867 invalid settings +--INI-- +session.upload_progress.freq=-1 +error_log= +--SKIPIF-- +<?php +include('skipif.inc'); +if(substr(PHP_OS, 0, 3) != "WIN") + die("skip windows only test"); +?> +--FILE-- +<?php +var_dump(ini_get("session.upload_progress.freq")); +?> +--EXPECTF-- +Warning: PHP Startup: session.upload_progress.freq must be greater than or equal to zero in %s +string(2) "1%" +PHP Warning: PHP Startup: session.upload_progress.freq must be greater than or equal to zero in %s diff --git a/ext/session/tests/rfc1867_invalid_settings.phpt b/ext/session/tests/rfc1867_invalid_settings.phpt new file mode 100644 index 0000000..640c4d2 --- /dev/null +++ b/ext/session/tests/rfc1867_invalid_settings.phpt @@ -0,0 +1,20 @@ +--TEST-- +session rfc1867 invalid settings +--INI-- +session.upload_progress.freq=-1 +error_log= +--SKIPIF-- +<?php +include('skipif.inc'); +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Not for Windows"); +?> +--FILE-- +<?php +var_dump(ini_get("session.upload_progress.freq")); +?> +--EXPECTF-- +PHP Warning: PHP Startup: session.upload_progress.freq must be greater than or equal to zero in %s + +Warning: PHP Startup: session.upload_progress.freq must be greater than or equal to zero in %s +string(%d) "1%" diff --git a/ext/session/tests/rfc1867_invalid_settings_2-win.phpt b/ext/session/tests/rfc1867_invalid_settings_2-win.phpt new file mode 100644 index 0000000..f8e6b6d --- /dev/null +++ b/ext/session/tests/rfc1867_invalid_settings_2-win.phpt @@ -0,0 +1,19 @@ +--TEST-- +session rfc1867 invalid settings 2 +--INI-- +session.upload_progress.freq=200% +error_log= +--SKIPIF-- +<?php +include('skipif.inc'); +if(substr(PHP_OS, 0, 3) != "WIN") + die("skip windows only test"); +?> +--FILE-- +<?php +var_dump(ini_get("session.upload_progress.freq")); +?> +--EXPECTF-- +Warning: PHP Startup: session.upload_progress.freq cannot be over 100% in %s +string(2) "1%" +PHP Warning: PHP Startup: session.upload_progress.freq cannot be over 100% in %s diff --git a/ext/session/tests/rfc1867_invalid_settings_2.phpt b/ext/session/tests/rfc1867_invalid_settings_2.phpt new file mode 100644 index 0000000..c2a0c6a --- /dev/null +++ b/ext/session/tests/rfc1867_invalid_settings_2.phpt @@ -0,0 +1,20 @@ +--TEST-- +session rfc1867 invalid settings 2 +--INI-- +session.upload_progress.freq=200% +error_log= +--SKIPIF-- +<?php +include('skipif.inc'); +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Not for Windows"); +?> +--FILE-- +<?php +var_dump(ini_get("session.upload_progress.freq")); +?> +--EXPECTF-- +PHP Warning: PHP Startup: session.upload_progress.freq cannot be over 100% in %s + +Warning: PHP Startup: session.upload_progress.freq cannot be over 100% in %s +string(%d) "1%" diff --git a/ext/session/tests/rfc1867_no_name.phpt b/ext/session/tests/rfc1867_no_name.phpt new file mode 100644 index 0000000..c1dda81 --- /dev/null +++ b/ext/session/tests/rfc1867_no_name.phpt @@ -0,0 +1,76 @@ +--TEST-- +session rfc1867 no name +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_sid_cookie.phpt b/ext/session/tests/rfc1867_sid_cookie.phpt new file mode 100644 index 0000000..735a5ac --- /dev/null +++ b/ext/session/tests/rfc1867_sid_cookie.phpt @@ -0,0 +1,128 @@ +--TEST-- +session rfc1867 sid cookie +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_cookie.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_get.phpt b/ext/session/tests/rfc1867_sid_get.phpt new file mode 100644 index 0000000..cc5a793 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_get.phpt @@ -0,0 +1,126 @@ +--TEST-- +session rfc1867 sid get +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--GET-- +PHPSESSID=rfc1867-tests +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_get.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_get_2.phpt b/ext/session/tests/rfc1867_sid_get_2.phpt new file mode 100644 index 0000000..1d22e59 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_get_2.phpt @@ -0,0 +1,128 @@ +--TEST-- +session rfc1867 sid get 2 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=0 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests-cookie +--GET-- +PHPSESSID=rfc1867-tests +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_get_2.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_invalid.phpt b/ext/session/tests/rfc1867_sid_invalid.phpt new file mode 100644 index 0000000..b28a2e3 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_invalid.phpt @@ -0,0 +1,79 @@ +--TEST-- +session rfc1867 sid cookie +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.auto_start=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=_ +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_invalid.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +error_reporting(0); +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 +string(%d) "%s" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_sid_only_cookie.phpt b/ext/session/tests/rfc1867_sid_only_cookie.phpt new file mode 100644 index 0000000..9a01056 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_only_cookie.phpt @@ -0,0 +1,128 @@ +--TEST-- +session rfc1867 sid only cookie +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=1 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_only_cookie.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_only_cookie_2.phpt b/ext/session/tests/rfc1867_sid_only_cookie_2.phpt new file mode 100644 index 0000000..e705314 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_only_cookie_2.phpt @@ -0,0 +1,80 @@ +--TEST-- +session rfc1867 sid only cookie 2 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=1 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_only_cookie_2.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "%s" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_sid_post.phpt b/ext/session/tests/rfc1867_sid_post.phpt new file mode 100644 index 0000000..7c1eb2d --- /dev/null +++ b/ext/session/tests/rfc1867_sid_post.phpt @@ -0,0 +1,124 @@ +--TEST-- +session rfc1867 sid post +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_post.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/save_handler.inc b/ext/session/tests/save_handler.inc new file mode 100644 index 0000000..ebe9cac --- /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/save_handler_closures.inc b/ext/session/tests/save_handler_closures.inc new file mode 100644 index 0000000..50f33c1 --- /dev/null +++ b/ext/session/tests/save_handler_closures.inc @@ -0,0 +1,9 @@ +<?php + +require_once 'save_handler.inc'; + +foreach (array ('open', 'close', 'read', 'write', 'destroy', 'gc') as $fn) { + ${$fn.'_closure'} = function () use ($fn) { return call_user_func_array ($fn, func_get_args ()); }; +} + +?> 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 0000000..7166485 --- /dev/null +++ b/ext/session/tests/session_cache_expire_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_cache_expire() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : basic functionality ***\n"; + +var_dump(session_cache_expire()); +var_dump(session_cache_expire(1234567890)); +var_dump(session_cache_expire(180)); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(session_destroy()); +var_dump(session_cache_expire()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : basic functionality *** +int(180) +int(180) +int(1234567890) +bool(true) +int(180) +bool(true) +int(180) +Done + diff --git a/ext/session/tests/session_cache_expire_error.phpt b/ext/session/tests/session_cache_expire_error.phpt new file mode 100644 index 0000000..486ba78 --- /dev/null +++ b/ext/session/tests/session_cache_expire_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_cache_expire() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_cache_expire($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : error functionality *** + +-- Iteration 1 -- +int(180) + +-- Iteration 2 -- +int(0) + +-- Iteration 3 -- +int(1) + +-- Iteration 4 -- +int(12345) + +-- Iteration 5 -- +int(-2345) + +-- Iteration 6 -- +int(10) + +-- Iteration 7 -- +int(-10) + +-- Iteration 8 -- +int(%s) + +-- Iteration 9 -- +int(1) + +-- Iteration 10 -- +int(0) + +-- Iteration 11 -- +int(0) + +-- Iteration 12 -- +int(0) + +-- Iteration 13 -- +int(1) + +-- Iteration 14 -- +int(0) + +-- Iteration 15 -- +int(1) + +-- Iteration 16 -- +int(0) + +-- Iteration 17 -- +int(0) + +-- Iteration 18 -- +int(0) + +-- Iteration 19 -- +int(0) + +-- Iteration 20 -- +int(0) + +-- Iteration 21 -- +int(0) + +-- Iteration 22 -- +int(0) + +-- Iteration 23 -- +int(0) + +-- Iteration 24 -- +int(0) +Done + diff --git a/ext/session/tests/session_cache_expire_variation1.phpt b/ext/session/tests/session_cache_expire_variation1.phpt new file mode 100644 index 0000000..9d0ba27 --- /dev/null +++ b/ext/session/tests/session_cache_expire_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_cache_expire() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.cache_expire=360 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : variation ***\n"; + +var_dump(session_cache_expire()); +var_dump(session_cache_expire(1234567890)); +var_dump(session_cache_expire(180)); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(session_destroy()); +var_dump(session_cache_expire()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : variation *** +int(360) +int(360) +int(1234567890) +bool(true) +int(180) +bool(true) +int(180) +Done + diff --git a/ext/session/tests/session_cache_expire_variation2.phpt b/ext/session/tests/session_cache_expire_variation2.phpt new file mode 100644 index 0000000..f17f471 --- /dev/null +++ b/ext/session/tests/session_cache_expire_variation2.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_cache_expire() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : variation ***\n"; + +ini_set("session.cache_expire", 360); +var_dump(session_cache_expire()); +var_dump(session_cache_expire(1234567890)); +var_dump(session_cache_expire(180)); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(session_destroy()); +var_dump(session_cache_expire()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : variation *** +int(360) +int(360) +int(1234567890) +bool(true) +int(180) +bool(true) +int(180) +Done + + diff --git a/ext/session/tests/session_cache_expire_variation3.phpt b/ext/session/tests/session_cache_expire_variation3.phpt new file mode 100644 index 0000000..c243c1f --- /dev/null +++ b/ext/session/tests/session_cache_expire_variation3.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test session_cache_expire() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : variation ***\n"; + +var_dump(ini_get("session.cache_expire")); +var_dump(session_cache_expire()); +var_dump(ini_get("session.cache_expire")); +var_dump(session_cache_expire(1234567890)); +var_dump(ini_get("session.cache_expire")); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(ini_get("session.cache_expire")); +var_dump(session_destroy()); +var_dump(session_cache_expire()); +var_dump(ini_get("session.cache_expire")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : variation *** +string(3) "180" +int(180) +string(3) "180" +int(180) +string(10) "1234567890" +bool(true) +int(1234567890) +string(10) "1234567890" +bool(true) +int(1234567890) +string(10) "1234567890" +Done + diff --git a/ext/session/tests/session_cache_limiter_basic.phpt b/ext/session/tests/session_cache_limiter_basic.phpt new file mode 100644 index 0000000..d053187 --- /dev/null +++ b/ext/session/tests/session_cache_limiter_basic.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test session_cache_limiter() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : basic functionality ***\n"; + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("public")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("private")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("nocache")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("private_no_expire")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : basic functionality *** +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +bool(true) +string(6) "public" +string(6) "public" +string(7) "private" +bool(true) +bool(true) +string(7) "private" +string(7) "private" +string(7) "nocache" +bool(true) +bool(true) +string(7) "nocache" +string(7) "nocache" +string(17) "private_no_expire" +bool(true) +Done + diff --git a/ext/session/tests/session_cache_limiter_error.phpt b/ext/session/tests/session_cache_limiter_error.phpt new file mode 100644 index 0000000..df689d6 --- /dev/null +++ b/ext/session/tests/session_cache_limiter_error.phpt @@ -0,0 +1,172 @@ +--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 + 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 0000000..7c6e71e --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_cache_limiter() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.cache_limiter=nocache +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : variation ***\n"; + +var_dump(session_cache_limiter()); +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("public")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); +var_dump(session_cache_limiter()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : variation *** +string(7) "nocache" +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +string(6) "public" +Done + diff --git a/ext/session/tests/session_cache_limiter_variation2.phpt b/ext/session/tests/session_cache_limiter_variation2.phpt new file mode 100644 index 0000000..b6d97a3 --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation2.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_cache_limiter() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : variation ***\n"; + +ini_set("session.cache_limiter", "nocache"); +var_dump(session_cache_limiter()); +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("public")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); +var_dump(session_cache_limiter()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : variation *** +string(7) "nocache" +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +string(6) "public" +Done + diff --git a/ext/session/tests/session_cache_limiter_variation3.phpt b/ext/session/tests/session_cache_limiter_variation3.phpt new file mode 100644 index 0000000..7aab95b --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation3.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_cache_limiter() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : variation ***\n"; + +var_dump(ini_get("session.cache_limiter")); +var_dump(session_start()); +var_dump(ini_get("session.cache_limiter")); +var_dump(session_cache_limiter("public")); +var_dump(ini_get("session.cache_limiter")); +var_dump(session_destroy()); +var_dump(ini_get("session.cache_limiter")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : variation *** +string(7) "nocache" +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +string(6) "public" +Done + diff --git a/ext/session/tests/session_commit_basic.phpt b/ext/session/tests/session_commit_basic.phpt new file mode 100644 index 0000000..c20db10 --- /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 0000000..b867572 --- /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 0000000..81240da --- /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 0000000..b38885a --- /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 0000000..4cee2f4 --- /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 0000000..57f4253 --- /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 0000000..f8aa243 --- /dev/null +++ b/ext/session/tests/session_decode_basic.phpt @@ -0,0 +1,273 @@ +--TEST-- +Test session_decode() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : basic functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +var_dump(session_start()); +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + $_SESSION["data"] = $input; + $encoded = session_encode(); + var_dump(session_decode($encoded)); + var_dump($_SESSION); + $iterator++; +}; + +var_dump(session_destroy()); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : basic functionality *** +bool(true) + +-- Iteration 1 -- +bool(true) +array(1) { + ["data"]=> + int(0) +} + +-- Iteration 2 -- +bool(true) +array(1) { + ["data"]=> + int(1) +} + +-- Iteration 3 -- +bool(true) +array(1) { + ["data"]=> + int(12345) +} + +-- Iteration 4 -- +bool(true) +array(1) { + ["data"]=> + int(-2345) +} + +-- Iteration 5 -- +bool(true) +array(1) { + ["data"]=> + float(10.5) +} + +-- Iteration 6 -- +bool(true) +array(1) { + ["data"]=> + float(-10.5) +} + +-- Iteration 7 -- +bool(true) +array(1) { + ["data"]=> + float(123456789000) +} + +-- Iteration 8 -- +bool(true) +array(1) { + ["data"]=> + float(1.23456789E-9) +} + +-- Iteration 9 -- +bool(true) +array(1) { + ["data"]=> + float(0.5) +} + +-- Iteration 10 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 11 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 12 -- +bool(true) +array(1) { + ["data"]=> + bool(true) +} + +-- Iteration 13 -- +bool(true) +array(1) { + ["data"]=> + bool(false) +} + +-- Iteration 14 -- +bool(true) +array(1) { + ["data"]=> + bool(true) +} + +-- Iteration 15 -- +bool(true) +array(1) { + ["data"]=> + bool(false) +} + +-- Iteration 16 -- +bool(true) +array(1) { + ["data"]=> + string(0) "" +} + +-- Iteration 17 -- +bool(true) +array(1) { + ["data"]=> + string(0) "" +} + +-- Iteration 18 -- +bool(true) +array(1) { + ["data"]=> + string(7) "Nothing" +} + +-- Iteration 19 -- +bool(true) +array(1) { + ["data"]=> + string(7) "Nothing" +} + +-- Iteration 20 -- +bool(true) +array(1) { + ["data"]=> + string(12) "Hello World!" +} + +-- Iteration 21 -- +bool(true) +array(1) { + ["data"]=> + object(classA)#2 (0) { + } +} + +-- Iteration 22 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 23 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 24 -- +bool(true) +array(1) { + ["data"]=> + int(0) +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_error.phpt b/ext/session/tests/session_decode_error.phpt new file mode 100644 index 0000000..098ecce --- /dev/null +++ b/ext/session/tests/session_decode_error.phpt @@ -0,0 +1,223 @@ +--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 diff --git a/ext/session/tests/session_decode_error2.phpt b/ext/session/tests/session_decode_error2.phpt new file mode 100644 index 0000000..4160f87 --- /dev/null +++ b/ext/session/tests/session_decode_error2.phpt @@ -0,0 +1,615 @@ +--TEST-- +Test session_decode() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : error functionality ***\n"; +$data = "foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;"; + +var_dump(session_start()); +for($index = 0; $index < strlen($data); $index++) { + echo "\n-- Iteration $index --\n"; + $encoded = substr($data, 0, $index); + var_dump(session_decode($encoded)); + var_dump($_SESSION); +}; + +var_dump(session_destroy()); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : error functionality *** +bool(true) + +-- Iteration 0 -- +bool(true) +array(0) { +} + +-- Iteration 1 -- +bool(true) +array(0) { +} + +-- Iteration 2 -- +bool(true) +array(0) { +} + +-- Iteration 3 -- +bool(true) +array(0) { +} + +-- Iteration 4 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 5 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 6 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 7 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 8 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 9 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 10 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 11 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 12 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 13 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 14 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 15 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 16 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 17 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 18 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 19 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 20 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 21 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 22 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 23 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 24 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 25 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 26 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 27 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 28 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 29 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 30 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 31 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 32 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 33 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 34 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 35 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 36 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 37 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 38 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 39 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 40 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 41 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 42 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 43 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 44 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 45 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 46 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 47 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 48 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} + +-- Iteration 49 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} + +-- Iteration 50 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} + +-- Iteration 51 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_variation1.phpt b/ext/session/tests/session_decode_variation1.phpt new file mode 100644 index 0000000..b2d06b1 --- /dev/null +++ b/ext/session/tests/session_decode_variation1.phpt @@ -0,0 +1,189 @@ +--TEST-- +Test session_decode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : variation *** +bool(true) +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_variation2.phpt b/ext/session/tests/session_decode_variation2.phpt new file mode 100644 index 0000000..1a9b687 --- /dev/null +++ b/ext/session/tests/session_decode_variation2.phpt @@ -0,0 +1,78 @@ +--TEST-- +Test session_decode() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +$_SESSION["foo"] = 1234567890; +$_SESSION["bar"] = "Hello World!"; +$_SESSION["guff"] = 123.456; +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : variation *** +bool(true) +array(0) { +} +array(3) { + ["foo"]=> + int(1234567890) + ["bar"]=> + string(12) "Hello World!" + ["guff"]=> + float(123.456) +} +bool(true) +array(4) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["bar"]=> + string(12) "Hello World!" + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_variation3.phpt b/ext/session/tests/session_decode_variation3.phpt new file mode 100644 index 0000000..4a6f768 --- /dev/null +++ b/ext/session/tests/session_decode_variation3.phpt @@ -0,0 +1,64 @@ +--TEST-- +Test session_decode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.serialize_handler=blah +--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"] = "Blah!"; +$_SESSION["guff"] = 123.456; +var_dump($_SESSION); +$encoded = "foo|i:1234567890;"; +var_dump(session_decode($encoded)); +var_dump($_SESSION); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : variation *** + +Warning: session_start(): Cannot find serialization handler 'blah' - session startup failed in %s on line %d +bool(false) + +Notice: Undefined variable: _SESSION in %s on line %d +NULL +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) +} + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) +Done diff --git a/ext/session/tests/session_decode_variation4.phpt b/ext/session/tests/session_decode_variation4.phpt new file mode 100644 index 0000000..8164275 --- /dev/null +++ b/ext/session/tests/session_decode_variation4.phpt @@ -0,0 +1,56 @@ +--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); +$_SESSION["foo"] = 1234567890; +$_SESSION["bar"] = "Blah!"; +$_SESSION["guff"] = 123.456; +var_dump($_SESSION); +$encoded = "A2Zvb2k6MTIzNDU2Nzg5MDs="; +var_dump(session_decode(base64_decode($encoded))); +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(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_destroy_error.phpt b/ext/session/tests/session_destroy_error.phpt new file mode 100644 index 0000000..a3e443e --- /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 0000000..fdbdf08 --- /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 0000000..c72c65b --- /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 0000000..b63c17e --- /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 0000000..dfe40d2 --- /dev/null +++ b/ext/session/tests/session_encode_basic.phpt @@ -0,0 +1,176 @@ +--TEST-- +Test session_encode() function : basic functionality +--INI-- +serialize_precision=100 +--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(%d) "data|d:1.2345678899999999145113427164344339914681114578343112953007221221923828125E-9;" + +-- Iteration 9 -- +string(11) "data|d:0.5;" + +-- Iteration 10 -- +string(7) "data|N;" + +-- Iteration 11 -- +string(7) "data|N;" + +-- Iteration 12 -- +string(9) "data|b:1;" + +-- Iteration 13 -- +string(9) "data|b:0;" + +-- Iteration 14 -- +string(9) "data|b:1;" + +-- Iteration 15 -- +string(9) "data|b:0;" + +-- Iteration 16 -- +string(12) "data|s:0:"";" + +-- Iteration 17 -- +string(12) "data|s:0:"";" + +-- Iteration 18 -- +string(19) "data|s:7:"Nothing";" + +-- Iteration 19 -- +string(19) "data|s:7:"Nothing";" + +-- Iteration 20 -- +string(25) "data|s:12:"Hello World!";" + +-- Iteration 21 -- +string(22) "data|O:6:"classA":0:{}" + +-- Iteration 22 -- +string(7) "data|N;" + +-- Iteration 23 -- +string(7) "data|N;" + +-- Iteration 24 -- +string(9) "data|i:0;" +bool(true) +Done + diff --git a/ext/session/tests/session_encode_error.phpt b/ext/session/tests/session_encode_error.phpt new file mode 100644 index 0000000..955aff4 --- /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 0000000..2c31ceb --- /dev/null +++ b/ext/session/tests/session_encode_error2.phpt @@ -0,0 +1,251 @@ +--TEST-- +Test session_encode() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_start()); + $_SESSION[$input] = "Hello World!"; + var_dump(session_encode()); + var_dump(session_destroy()); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : error functionality *** + +-- Iteration 1 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0 in %s on line %d +bool(false) +bool(true) + +-- Iteration 2 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 1 in %s on line %d +bool(false) +bool(true) + +-- Iteration 3 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 12345 in %s on line %d +bool(false) +bool(true) + +-- Iteration 4 -- +bool(true) + +Notice: session_encode(): Skipping numeric key -2345 in %s on line %d +bool(false) +bool(true) + +-- Iteration 5 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 10 in %s on line %d +bool(false) +bool(true) + +-- Iteration 6 -- +bool(true) + +Notice: session_encode(): Skipping numeric key -10 in %s on line %d +bool(false) +bool(true) + +-- Iteration 7 -- +bool(true) + +Notice: session_encode(): Skipping numeric key %s in %s on line %d +bool(false) +bool(true) + +-- Iteration 8 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0 in %s on line %d +bool(false) +bool(true) + +-- Iteration 9 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0 in %s on line %d +bool(false) +bool(true) + +-- Iteration 10 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 11 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 12 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 1 in %s on line %d +bool(false) +bool(true) + +-- Iteration 13 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0 in %s on line %d +bool(false) +bool(true) + +-- Iteration 14 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 1 in %s on line %d +bool(false) +bool(true) + +-- Iteration 15 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0 in %s on line %d +bool(false) +bool(true) + +-- Iteration 16 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 17 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 18 -- +bool(true) +string(28) "Nothing|s:12:"Hello World!";" +bool(true) + +-- Iteration 19 -- +bool(true) +string(28) "Nothing|s:12:"Hello World!";" +bool(true) + +-- Iteration 20 -- +bool(true) +bool(false) +bool(true) + +-- Iteration 21 -- +bool(true) + +Warning: Illegal offset type in %s on line 82 +bool(false) +bool(true) + +-- Iteration 22 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 23 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 24 -- +bool(true) + +Strict Standards: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d + +Notice: session_encode(): Skipping numeric key %d in %s on line %d +bool(false) +bool(true) +Done diff --git a/ext/session/tests/session_encode_variation1.phpt b/ext/session/tests/session_encode_variation1.phpt new file mode 100644 index 0000000..ce3a921 --- /dev/null +++ b/ext/session/tests/session_encode_variation1.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_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 0000000..93fab30 --- /dev/null +++ b/ext/session/tests/session_encode_variation2.phpt @@ -0,0 +1,34 @@ +--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 0000000..47b2441 --- /dev/null +++ b/ext/session/tests/session_encode_variation3.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); + +$array = array(1,2,3); +$_SESSION["foo"] = &$array; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(34) "foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}" +bool(true) +Done diff --git a/ext/session/tests/session_encode_variation4.phpt b/ext/session/tests/session_encode_variation4.phpt new file mode 100644 index 0000000..89af6eb --- /dev/null +++ b/ext/session/tests/session_encode_variation4.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); + +$array = array(1,2,3); +$_SESSION["foo"] = &$array; +$_SESSION["guff"] = &$array; +$_SESSION["blah"] = &$array; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(52) "foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;" +bool(true) +Done diff --git a/ext/session/tests/session_encode_variation5.phpt b/ext/session/tests/session_encode_variation5.phpt new file mode 100644 index 0000000..d7639fa --- /dev/null +++ b/ext/session/tests/session_encode_variation5.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); + +$array = array(1,2,3); +$array["foo"] = &$array; +$array["blah"] = &$array; +$_SESSION["data"] = &$array; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(64) "data|a:5:{i:0;i:1;i:1;i:2;i:2;i:3;s:3:"foo";R:1;s:4:"blah";R:1;}" +bool(true) +Done diff --git a/ext/session/tests/session_encode_variation6.phpt b/ext/session/tests/session_encode_variation6.phpt new file mode 100644 index 0000000..c5f1f4b --- /dev/null +++ b/ext/session/tests/session_encode_variation6.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); +$_SESSION[] = 1234567890; +var_dump(session_encode()); +var_dump(session_destroy()); +var_dump(session_start()); +$_SESSION[1234567890] = "Hello World!"; +var_dump(session_encode()); +var_dump(session_destroy()); +var_dump(session_start()); +$_SESSION[-1234567890] = 1234567890; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) + +Notice: session_encode(): Skipping numeric key 0 in %s on line %d +bool(false) +bool(true) +bool(true) + +Notice: session_encode(): Skipping numeric key 1234567890 in %s on line %d +bool(false) +bool(true) +bool(true) + +Notice: session_encode(): Skipping numeric key -1234567890 in %s on line %d +bool(false) +bool(true) +Done diff --git a/ext/session/tests/session_encode_variation7.phpt b/ext/session/tests/session_encode_variation7.phpt new file mode 100644 index 0000000..04cfe44 --- /dev/null +++ b/ext/session/tests/session_encode_variation7.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.serialize_handler=php_binary +--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["foo"] = 1234567890; +$encoded = session_encode(); +var_dump(base64_encode($encoded)); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--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 0000000..7ffa948 --- /dev/null +++ b/ext/session/tests/session_encode_variation8.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.serialize_handler=blah +--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["foo"] = 1234567890; +$encoded = session_encode(); +var_dump(base64_encode($encoded)); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** + +Warning: session_start(): Cannot find serialization handler 'blah' - session startup failed in %s on line %d +bool(false) + +Warning: session_encode(): Cannot encode non-existent session in %s on line %d +string(0) "" + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) +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 0000000..e984f55 --- /dev/null +++ b/ext/session/tests/session_get_cookie_params_basic.phpt @@ -0,0 +1,73 @@ +--TEST-- +Test session_get_cookie_params() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.cookie_lifetime=0 +session.cookie_path="/" +session.cookie_domain="" +session.cookie_secure=0 +session.cookie_httponly=0 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : array session_get_cookie_params(void) + * Description : Get the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_get_cookie_params() : basic functionality ***\n"; + +var_dump(session_get_cookie_params()); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, FALSE)); +var_dump(session_get_cookie_params()); +var_dump(session_set_cookie_params(1234567890, "/guff", "foo", TRUE, TRUE)); +var_dump(session_get_cookie_params()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_get_cookie_params() : basic functionality *** +array(5) { + ["lifetime"]=> + int(0) + ["path"]=> + string(1) "/" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +NULL +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(4) "blah" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +NULL +array(5) { + ["lifetime"]=> + int(1234567890) + ["path"]=> + string(5) "/guff" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(true) + ["httponly"]=> + bool(true) +} +Done diff --git a/ext/session/tests/session_get_cookie_params_error.phpt b/ext/session/tests/session_get_cookie_params_error.phpt new file mode 100644 index 0000000..243536c --- /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 0000000..bb921a5 --- /dev/null +++ b/ext/session/tests/session_get_cookie_params_variation1.phpt @@ -0,0 +1,114 @@ +--TEST-- +Test session_get_cookie_params() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.cookie_lifetime=0 +session.cookie_path="/" +session.cookie_domain="" +session.cookie_secure=0 +session.cookie_httponly=0 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : array session_get_cookie_params(void) + * Description : Get the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_get_cookie_params() : variation ***\n"; + +var_dump(session_get_cookie_params()); +ini_set("session.cookie_lifetime", 3600); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_path", "/path"); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_domain", "foo"); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_secure", TRUE); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_httponly", TRUE); +var_dump(session_get_cookie_params()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_get_cookie_params() : variation *** +array(5) { + ["lifetime"]=> + int(0) + ["path"]=> + string(1) "/" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(1) "/" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(true) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(true) + ["httponly"]=> + bool(true) +} +Done + diff --git a/ext/session/tests/session_id_basic.phpt b/ext/session/tests/session_id_basic.phpt new file mode 100644 index 0000000..5cb13c2 --- /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 0000000..6337cb9 --- /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, 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 0000000..05284e7 --- /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 0000000..fc29138 --- /dev/null +++ b/ext/session/tests/session_id_error3.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test session_id() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : error functionality ***\n"; + +@session_start(); +var_dump(session_id()); +var_dump(session_id("!")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("?><")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("£$%^&*()")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("\r\n")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("\0")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("¬``@~:{>?><,./[]+--")); +var_dump(session_id()); +@session_destroy(); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : error functionality *** +string(%d) "%s" +string(%d) "%s" +string(1) "!" +string(%d) "%s" +string(%d) "%s" +string(3) "?><" +string(%d) "%s" +string(%d) "%s" +string(8) "£$%^&*()" +string(%d) "%s" +string(%d) "%s" +string(2) " +" +string(%d) "%s" +string(%d) "%s" +string(0) "" +string(%d) "%s" +string(%d) "%s" +string(19) "¬``@~:{>?><,./[]+--" +Done + diff --git a/ext/session/tests/session_id_error4.phpt b/ext/session/tests/session_id_error4.phpt new file mode 100644 index 0000000..6c1fdbc --- /dev/null +++ b/ext/session/tests/session_id_error4.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test session_id() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.hash_function=0 +session.hash_bits_per_character=4 +--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(ini_set("session.hash_function", -1)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : error functionality *** +string(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 0000000..983ca29 --- /dev/null +++ b/ext/session/tests/session_id_variation1.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test session_id() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.hash_function=0 +--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() : variation ***\n"; + +var_dump(ini_set("session.hash_function", 0)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); + +var_dump(ini_set("session.hash_function", 1)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : variation *** +string(1) "0" +string(0) "" +bool(true) +string(%d) "%s" +bool(true) +string(1) "0" +string(0) "" +bool(true) +string(%d) "%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 0000000..f69aa44 --- /dev/null +++ b/ext/session/tests/session_id_variation2.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test session_id() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.hash_function=0 +session.entropy_file= +session.entropy_length=0 +--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() : variation ***\n"; + +$directory = dirname(__FILE__); +$filename = ($directory."/entropy.txt"); +var_dump(ini_set("session.entropy_file", $filename)); +var_dump(file_put_contents($filename, "Hello World!")); +var_dump(ini_set("session.entropy_length", filesize($filename))); + +var_dump(ini_set("session.hash_function", 0)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); + +var_dump(ini_set("session.hash_function", 1)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(unlink($filename)); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : variation *** +string(0) "" +int(12) +string(1) "0" +string(1) "0" +string(0) "" +bool(true) +string(%d) "%s" +bool(true) +string(1) "0" +string(0) "" +bool(true) +string(%d) "%s" +bool(true) +bool(true) +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 0000000..2daf6fc --- /dev/null +++ b/ext/session/tests/session_module_name_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_module_name() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : basic functionality ***\n"; +var_dump(session_module_name("files")); +var_dump(session_module_name()); +var_dump(session_start()); +var_dump(session_module_name()); +var_dump(session_destroy()); +var_dump(session_module_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : basic functionality *** +string(%d) "%s" +string(5) "files" +bool(true) +string(5) "files" +bool(true) +string(5) "files" +Done diff --git a/ext/session/tests/session_module_name_error.phpt b/ext/session/tests/session_module_name_error.phpt new file mode 100644 index 0000000..08c080a --- /dev/null +++ b/ext/session/tests/session_module_name_error.phpt @@ -0,0 +1,216 @@ +--TEST-- +Test session_module_name() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_module_name($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : error functionality *** + +-- Iteration 1 -- + +Warning: session_module_name(): Cannot find named PHP session module (0) in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: session_module_name(): Cannot find named PHP session module (1) in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: session_module_name(): Cannot find named PHP session module (12345) in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: session_module_name(): Cannot find named PHP session module (-2345) in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: session_module_name(): Cannot find named PHP session module (10.5) in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: session_module_name(): Cannot find named PHP session module (-10.5) in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: session_module_name(): Cannot find named PHP session module (123456789000) in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: session_module_name(): Cannot find named PHP session module (1.23456789E-9) in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: session_module_name(): Cannot find named PHP session module (0.5) in %s on line %d +bool(false) + +-- Iteration 10 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: session_module_name(): Cannot find named PHP session module (1) in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: session_module_name(): Cannot find named PHP session module (1) in %s on line %d +bool(false) + +-- Iteration 15 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: session_module_name(): Cannot find named PHP session module (Nothing) in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: session_module_name(): Cannot find named PHP session module (Nothing) in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: session_module_name(): Cannot find named PHP session module (Hello World!) in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: session_module_name(): Cannot find named PHP session module (Hello World!) in %s on line %d +bool(false) + +-- Iteration 22 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 23 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 24 -- + +Warning: session_module_name() expects parameter 1 to be 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 0000000..2034b7e --- /dev/null +++ b/ext/session/tests/session_module_name_variation1.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_module_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : variation ***\n"; +var_dump(session_module_name("blah")); +var_dump(session_start()); +var_dump(session_module_name()); +var_dump(session_destroy()); +var_dump(session_module_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : variation *** + +Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d +bool(false) +bool(true) +string(%d) "%s" +bool(true) +string(%d) "%s" +Done diff --git a/ext/session/tests/session_module_name_variation2.phpt b/ext/session/tests/session_module_name_variation2.phpt new file mode 100644 index 0000000..aa7b33c --- /dev/null +++ b/ext/session/tests/session_module_name_variation2.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test session_module_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : variation ***\n"; + +function open($save_path, $session_name) { } +function close() { } +function read($id) { } +function write($id, $session_data) { } +function destroy($id) { } +function gc($maxlifetime) { } + +var_dump(session_module_name("files")); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +var_dump(session_module_name()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : variation *** +string(%d) "%s" +string(4) "user" diff --git a/ext/session/tests/session_module_name_variation3.phpt b/ext/session/tests/session_module_name_variation3.phpt new file mode 100644 index 0000000..dc1c6ba --- /dev/null +++ b/ext/session/tests/session_module_name_variation3.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_module_name() function : variation +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : variation ***\n"; +function open($save_path, $session_name) { + throw new Exception("Stop...!"); +} + +function close() { } +function read($id) { } +function write($id, $session_data) { } +function destroy($id) { } +function gc($maxlifetime) { } + +var_dump(session_module_name("files")); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +var_dump(session_module_name()); +var_dump(session_start()); +var_dump(session_module_name()); +var_dump(session_destroy()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : variation *** +string(%d) "%s" +string(4) "user" + +Fatal error: Uncaught exception 'Exception' with message 'Stop...!' in %s:%d +Stack trace: +#0 [internal function]: open('', 'PHPSESSID') +#1 %s(%d): session_start() +#2 {main} + thrown in %s on line %d diff --git a/ext/session/tests/session_module_name_variation4.phpt b/ext/session/tests/session_module_name_variation4.phpt new file mode 100644 index 0000000..0748b3d --- /dev/null +++ b/ext/session/tests/session_module_name_variation4.phpt @@ -0,0 +1,67 @@ +--TEST-- +Test session_module_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.gc_probability=1 +session.gc_divisor=1 +session.gc_maxlifetime=0 +--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"; + +require_once "save_handler.inc"; +$path = dirname(__FILE__); +session_save_path($path); +session_module_name("files"); + +session_start(); +$_SESSION["Blah"] = "Hello World!"; +$_SESSION["Foo"] = FALSE; +$_SESSION["Guff"] = 1234567890; +var_dump($_SESSION); + +var_dump(session_write_close()); +session_start(); +var_dump($_SESSION); +var_dump(session_destroy()); +session_start(); +var_dump($_SESSION); +var_dump(session_destroy()); + +ob_end_flush(); +?> +--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_name_basic.phpt b/ext/session/tests/session_name_basic.phpt new file mode 100644 index 0000000..959f406 --- /dev/null +++ b/ext/session/tests/session_name_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_name() function : error functionality +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_name([string $name]) + * Description : Get and/or set the current session name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_name() : error functionality ***\n"; + +var_dump(session_name()); +var_dump(session_name("blah")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_name() : error functionality *** +string(9) "PHPSESSID" +string(9) "PHPSESSID" +bool(true) +string(4) "blah" +bool(true) +string(4) "blah" +Done + diff --git a/ext/session/tests/session_name_error.phpt b/ext/session/tests/session_name_error.phpt new file mode 100644 index 0000000..2ed10d9 --- /dev/null +++ b/ext/session/tests/session_name_error.phpt @@ -0,0 +1,174 @@ +--TEST-- +Test session_name() function : error functionality +--INI-- +session.save_path= +session.name=PHPSESSID +--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 + diff --git a/ext/session/tests/session_name_variation1.phpt b/ext/session/tests/session_name_variation1.phpt new file mode 100644 index 0000000..16d6ad4 --- /dev/null +++ b/ext/session/tests/session_name_variation1.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test session_name() function : variation +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_name([string $name]) + * Description : Get and/or set the current session name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_name() : variation ***\n"; + +var_dump(session_name("\0")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +var_dump(session_name("\t")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +var_dump(session_name("")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_name() : variation *** +string(9) "PHPSESSID" +bool(true) +string(0) "" +bool(true) +string(0) "" +string(0) "" +bool(true) +string(1) " " +bool(true) +string(1) " " +string(1) " " +bool(true) +string(0) "" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_name_variation2.phpt b/ext/session/tests/session_name_variation2.phpt new file mode 100644 index 0000000..84bfeba --- /dev/null +++ b/ext/session/tests/session_name_variation2.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.name=blah +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_name([string $name]) + * Description : Get and/or set the current session name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_name() : variation ***\n"; + +var_dump(session_name()); +var_dump(session_name("blah")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_name() : variation *** +string(4) "blah" +string(4) "blah" +bool(true) +string(4) "blah" +bool(true) +string(4) "blah" +Done + diff --git a/ext/session/tests/session_regenerate_id_basic.phpt b/ext/session/tests/session_regenerate_id_basic.phpt new file mode 100644 index 0000000..910620a --- /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 0000000..9e119f1 --- /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 0000000..95d4a77 --- /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 0000000..2895f46 --- /dev/null +++ b/ext/session/tests/session_save_path_basic.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test session_save_path() function : basic functionality +--INI-- +session.gc_probability=0 +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : error functionality ***\n"; + +$directory = dirname(__FILE__); +var_dump(session_save_path()); +var_dump(session_save_path($directory)); +var_dump(session_save_path()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : error functionality *** +string(0) "" +string(0) "" +string(%d) "%s" +Done + diff --git a/ext/session/tests/session_save_path_error.phpt b/ext/session/tests/session_save_path_error.phpt new file mode 100644 index 0000000..815feee --- /dev/null +++ b/ext/session/tests/session_save_path_error.phpt @@ -0,0 +1,178 @@ +--TEST-- +Test session_save_path() function : error functionality +--INI-- +session.gc_probability=0 +session.save_path= +session.name=PHPSESSID +--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 + 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 0000000..d5f64d9 --- /dev/null +++ b/ext/session/tests/session_save_path_variation1.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test session_save_path() function : variation +--INI-- +session.gc_probability=0 +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; + +$directory = dirname(__FILE__); +var_dump(session_save_path()); +var_dump(session_start()); +var_dump(session_save_path()); +var_dump(session_save_path($directory)); +var_dump(session_save_path()); +var_dump(session_destroy()); +var_dump(session_save_path()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : variation *** +string(0) "" +bool(true) +string(0) "" +string(0) "" +string(%d) "%s" +bool(true) +string(%d) "%s" +Done + diff --git a/ext/session/tests/session_save_path_variation2.phpt b/ext/session/tests/session_save_path_variation2.phpt new file mode 100644 index 0000000..6b08480 --- /dev/null +++ b/ext/session/tests/session_save_path_variation2.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_handler=files +session.gc_probability=0 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; + +ini_set("session.save_path", "/blah"); +var_dump(ini_get("session.save_path")); +var_dump(session_start()); +var_dump(ini_get("session.save_path")); +var_dump(session_destroy()); +var_dump(ini_get("session.save_path")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : variation *** +string(5) "/blah" + +Warning: session_start(): open(%s, O_RDWR) failed: No such file or directory (2) in %s on line %d +bool(true) +string(5) "/blah" +bool(true) +string(5) "/blah" +Done diff --git a/ext/session/tests/session_save_path_variation3.phpt b/ext/session/tests/session_save_path_variation3.phpt new file mode 100644 index 0000000..b064f30 --- /dev/null +++ b/ext/session/tests/session_save_path_variation3.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_handler=files +session.gc_probability=0 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; + +ini_set("session.save_path", "/blah"); +var_dump(session_save_path()); +var_dump(session_start()); +var_dump(session_save_path()); +var_dump(session_destroy()); +var_dump(session_save_path()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : variation *** +string(5) "/blah" + +Warning: session_start(): open(%s, O_RDWR) failed: No such file or directory (2) in %s on line %d +bool(true) +string(5) "/blah" +bool(true) +string(5) "/blah" +Done diff --git a/ext/session/tests/session_save_path_variation4.phpt b/ext/session/tests/session_save_path_variation4.phpt new file mode 100644 index 0000000..80db6ca --- /dev/null +++ b/ext/session/tests/session_save_path_variation4.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- +<?php include('skipif.inc');?> +--INI-- +open_basedir=. +session.save_handler=files +session.save_path= +session.name=PHPSESSID +--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"; +$initdir = getcwd(); +$sessions = ($initdir."/sessions"); + +chdir($initdir); + +// Delete the existing directory +if (file_exists($sessions) === TRUE) { + @rmdir($sessions); +} + +var_dump(mkdir($sessions)); +var_dump(chdir($sessions)); +ini_set("session.save_path", $initdir); +var_dump(session_save_path()); +var_dump(session_start()); +var_dump(session_save_path()); +var_dump(session_destroy()); +var_dump(session_save_path()); +var_dump(rmdir($sessions)); + +echo "Done"; +ob_end_flush(); +?> +--CLEAN-- +$initdir = getcwd(); +$sessions = ($initdir."/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 0000000..5407b5e --- /dev/null +++ b/ext/session/tests/session_save_path_variation5.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- +<?php include('skipif.inc'); +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Not for Windows"); +?> +--INI-- +session.save_handler=files +session.save_path= +session.name=PHPSESSID +open_basedir=. +--FILE-- +<?php + +ob_start(); +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; +$directory = dirname(__FILE__); +$sessions = ($directory."/sessions"); + +chdir($directory); + +// Delete the existing directory +if (file_exists($sessions) === TRUE) { + @rmdir($sessions); +} + +var_dump(mkdir($sessions)); +var_dump(chdir($sessions)); +ini_set("session.save_path", $directory); +var_dump(session_save_path()); +var_dump(rmdir($sessions)); + +echo "Done"; +ob_end_flush(); +?> +--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) +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 0000000..5055d1c --- /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 0000000..0dc5310 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_error.phpt @@ -0,0 +1,306 @@ +--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 -- +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 + 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 0000000..02b901f --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation1.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_lifetime=3600 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_set_cookie_params(3600)); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_set_cookie_params(1800)); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_set_cookie_params(1234567890)); +var_dump(ini_get("session.cookie_lifetime")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(4) "3600" +NULL +string(4) "3600" +bool(true) +string(4) "3600" +NULL +string(4) "1800" +bool(true) +string(4) "1800" +NULL +string(10) "1234567890" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation2.phpt b/ext/session/tests/session_set_cookie_params_variation2.phpt new file mode 100644 index 0000000..5d7a010 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation2.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_path=/path +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_path")); +var_dump(session_set_cookie_params(3600, "/foo")); +var_dump(ini_get("session.cookie_path")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_path")); +var_dump(session_set_cookie_params(3600, "/blah")); +var_dump(ini_get("session.cookie_path")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_path")); +var_dump(session_set_cookie_params(3600, "/guff")); +var_dump(ini_get("session.cookie_path")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(5) "/path" +NULL +string(4) "/foo" +bool(true) +string(4) "/foo" +NULL +string(5) "/blah" +bool(true) +string(5) "/blah" +NULL +string(5) "/guff" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation3.phpt b/ext/session/tests/session_set_cookie_params_variation3.phpt new file mode 100644 index 0000000..5e8f0ff --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation3.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_domain=foo +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_domain")); +var_dump(session_set_cookie_params(3600, "/path", "blah")); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_set_cookie_params(3600, "/path", "guff")); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_set_cookie_params(3600, "/path", "foo")); +var_dump(ini_get("session.cookie_domain")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(3) "foo" +NULL +string(4) "blah" +bool(true) +string(4) "blah" +NULL +string(4) "guff" +bool(true) +string(4) "guff" +NULL +string(3) "foo" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation4.phpt b/ext/session/tests/session_set_cookie_params_variation4.phpt new file mode 100644 index 0000000..7b82596 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation4.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_secure=TRUE +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_secure")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE)); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_set_cookie_params(3600, "/path", "blah", TRUE)); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE)); +var_dump(ini_get("session.cookie_secure")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(1) "1" +NULL +string(1) "0" +bool(true) +string(1) "0" +NULL +string(1) "1" +bool(true) +string(1) "1" +NULL +string(1) "0" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation5.phpt b/ext/session/tests/session_set_cookie_params_variation5.phpt new file mode 100644 index 0000000..29559f7 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation5.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_httponly=TRUE +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, FALSE)); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, TRUE)); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, FALSE)); +var_dump(ini_get("session.cookie_httponly")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(1) "1" +NULL +string(1) "0" +bool(true) +string(1) "0" +NULL +string(1) "1" +bool(true) +string(1) "1" +NULL +string(1) "0" +Done + diff --git a/ext/session/tests/session_set_save_handler_basic.phpt b/ext/session/tests/session_set_save_handler_basic.phpt new file mode 100644 index 0000000..3897ba9 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_basic.phpt @@ -0,0 +1,95 @@ +--TEST-- +Test session_set_save_handler() function : basic functionality +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : basic functionality ***\n"; + +require_once "save_handler.inc"; +var_dump(session_module_name()); +var_dump(session_module_name(FALSE)); +var_dump(session_module_name("blah")); +var_dump(session_module_name("foo")); + +$path = dirname(__FILE__); +session_save_path($path); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); + +session_start(); +$_SESSION["Blah"] = "Hello World!"; +$_SESSION["Foo"] = FALSE; +$_SESSION["Guff"] = 1234567890; +var_dump($_SESSION); + +session_write_close(); +session_unset(); +var_dump($_SESSION); + +echo "Starting session again..!\n"; +session_id($session_id); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_start(); +var_dump($_SESSION); +session_write_close(); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : basic functionality *** + +string(%d) "%s" + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d +bool(false) + +Warning: session_module_name(): Cannot find named PHP session module (foo) in %s on line %d +bool(false) +Open [%s,PHPSESSID] +Read [%s,%s] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Close [%s,PHPSESSID] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Starting session again..! +Open [%s,PHPSESSID] +Read [%s,%s] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Close [%s,PHPSESSID] diff --git a/ext/session/tests/session_set_save_handler_class_001.phpt b/ext/session/tests/session_set_save_handler_class_001.phpt new file mode 100644 index 0000000..83e899a --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_001.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test session_set_save_handler() : basic class wrapping existing handler +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : basic class wrapping existing handler ***\n"; + +class MySession extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } +} + +$oldHandler = ini_get('session.save_handler'); +$handler = new MySession; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); + +$_SESSION['foo'] = "hello"; + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() : basic class wrapping existing handler *** +Open +Read %s +string(%d) "%s" +string(5) "files" +string(4) "user" +int(2) +array(0) { +} +Open %s +Read %s +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_class_002.phpt b/ext/session/tests/session_set_save_handler_class_002.phpt new file mode 100644 index 0000000..6fb831f --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_002.phpt @@ -0,0 +1,113 @@ +--TEST-- +Test session_set_save_handler() : full handler implementation +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : full handler implementation ***\n"; + +class MySession2 extends SessionHandler { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } +} + +$handler = new MySession2; +session_set_save_handler(array($handler, 'open'), array($handler, 'close'), + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc')); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() : full handler implementation *** +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_class_003.phpt b/ext/session/tests/session_set_save_handler_class_003.phpt new file mode 100644 index 0000000..e9a3cc2 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_003.phpt @@ -0,0 +1,78 @@ +--TEST-- +Test session_set_save_handler() : inheritance +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : inheritance ***\n"; + +class MySession3 extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + return parent::read($key); + } +} + +class MySession4 extends MySession3 { + public function write($id, $data) { + $this->i = "hai"; + return parent::write($id, $data); + } +} + +$handler = new MySession3; +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = "hello"; + +session_write_close(); +session_unset(); + +session_start(); + +var_dump($_SESSION, $handler->i); + +session_write_close(); +session_unset(); + +$handler = new MySession4; +session_set_save_handler($handler); + +session_start(); + +session_write_close(); +session_unset(); + +var_dump(session_id(), $_SESSION, $handler->i); + +--EXPECTF-- +*** Testing session_set_save_handler() : inheritance *** +array(1) { + ["foo"]=> + string(5) "hello" +} +int(4) +string(%d) "%s" +array(1) { + ["foo"]=> + string(5) "hello" +} +string(3) "hai" diff --git a/ext/session/tests/session_set_save_handler_class_004.phpt b/ext/session/tests/session_set_save_handler_class_004.phpt new file mode 100644 index 0000000..103b13b --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_004.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test session_set_save_handler() : default object +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : default object ***\n"; + +session_set_save_handler(new SessionHandler); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); +session_start(); + +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() : default object *** +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_class_005.phpt b/ext/session/tests/session_set_save_handler_class_005.phpt new file mode 100644 index 0000000..a996eb8 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_005.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test session_set_save_handler() : incomplete implementation +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : incomplete implementation ***\n"; + +class MySession6 extends SessionHandler { + public function open($path, $name) { + // don't call parent + return true; + } + + public function read($id) { + // should error because parent::open hasn't been called + return parent::read($id); + } +} + +$handler = new MySession6; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + + +--EXPECTF-- +*** Testing session_set_save_handler() : incomplete implementation *** + +Warning: SessionHandler::read(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d +string(%d) "%s" +string(4) "user" +array(0) { +} + +Warning: SessionHandler::write(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d + +Warning: SessionHandler::close(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d diff --git a/ext/session/tests/session_set_save_handler_class_006.phpt b/ext/session/tests/session_set_save_handler_class_006.phpt new file mode 100644 index 0000000..5830b6d --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_006.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test session_set_save_handler() : using objects in close +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : using objects in close ***\n"; + +class MySession7_Foo { + public $state = 'ok'; + function __destruct() { + $this->state = 'destroyed'; + } +} + +class MySession7 extends SessionHandler { + public $foo; + public function close() { + var_dump($this->foo); + @var_dump($GLOBALS['bar']); + return parent::close(); + } +} + +$bar = new MySession7_Foo; +$handler = new MySession7; +$handler->foo = new MySession7_Foo; +session_set_save_handler($handler); +session_start(); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : using objects in close *** +object(MySession7_Foo)#%d (%d) { + ["state"]=> + string(2) "ok" +} +object(MySession7_Foo)#%d (%d) { + ["state"]=> + string(2) "ok" +} diff --git a/ext/session/tests/session_set_save_handler_class_007.phpt b/ext/session/tests/session_set_save_handler_class_007.phpt new file mode 100644 index 0000000..7344ae1 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_007.phpt @@ -0,0 +1,74 @@ +--TEST-- +Test session_set_save_handler() : manual shutdown, reopen +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : manual shutdown, reopen ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = 'bar'; + +// explicit close +$handler->finish(); + +$handler = new MySession(2); +session_set_save_handler($handler); +session_start(); + +// implicit close (called by shutdown function) +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : manual shutdown, reopen *** +(#1) constructor called +(#1) finish called %s +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +(#2) constructor called +(#1) destructor called +done +(#2) writing %s = foo|s:3:"bar"; +(#2) closing %s +(#2) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_008.phpt b/ext/session/tests/session_set_save_handler_class_008.phpt new file mode 100644 index 0000000..28cb692 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_008.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test session_set_save_handler() : manual shutdown +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : manual shutdown ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = 'bar'; + +// explicit close +$handler->finish(); + +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : manual shutdown *** +(#1) constructor called +(#1) finish called %s +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +done +(#1) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_009.phpt b/ext/session/tests/session_set_save_handler_class_009.phpt new file mode 100644 index 0000000..a8b57dc --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_009.phpt @@ -0,0 +1,62 @@ +--TEST-- +Test session_set_save_handler() : implicit shutdown +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : implicit shutdown ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + $this->shutdown(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = 'bar'; + +// implicit close +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : implicit shutdown *** +(#1) constructor called +done +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +(#1) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_010.phpt b/ext/session/tests/session_set_save_handler_class_010.phpt new file mode 100644 index 0000000..02304f4 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_010.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test session_set_save_handler() : manual shutdown function +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : manual shutdown function ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler, false); +register_shutdown_function(array($handler, 'finish')); +session_start(); + +$_SESSION['foo'] = 'bar'; + +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : manual shutdown function *** +(#1) constructor called +done +(#1) finish called %s +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +(#1) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_011.phpt b/ext/session/tests/session_set_save_handler_class_011.phpt new file mode 100644 index 0000000..7fa3657 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_011.phpt @@ -0,0 +1,66 @@ +--TEST-- +Test session_set_save_handler() : shutdown failure +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : shutdown failure ***\n"; + +class MySession extends SessionHandler { + public $num; + public $destroyed = false; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + $this->destroyed = true; + } + public function write($id, $data) { + if ($this->destroyed) { + echo "(#$this->num) destroyed, cannot write\n"; + } else { + echo "(#$this->num) writing $id = $data\n"; + } + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + if ($this->destroyed) { + echo "(#$this->num) destroyed, cannot write\n"; + } else { + echo "(#$this->num) closing $id\n"; + } + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler, false); +session_start(); + +$_SESSION['foo'] = 'bar'; + +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : shutdown failure *** +(#1) constructor called +done +(#1) destructor called +(#1) destroyed, cannot write +(#1) destroyed, cannot write diff --git a/ext/session/tests/session_set_save_handler_class_012.phpt b/ext/session/tests/session_set_save_handler_class_012.phpt new file mode 100644 index 0000000..706ef79 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_012.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test session_set_save_handler() : incorrect arguments for existing handler open +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : incorrect arguments for existing handler open ***\n"; + +class MySession extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open(); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } +} + +$oldHandler = ini_get('session.save_handler'); +$handler = new MySession; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); + +--EXPECTF-- +*** Testing session_set_save_handler() : incorrect arguments for existing handler open *** +Open + +Warning: SessionHandler::open() expects exactly 2 parameters, 0 given in %s on line %d +Read %s + +Warning: SessionHandler::read(): Parent session handler is not open in %s on line %d +string(%d) "%s" +string(5) "files" +string(4) "user" +int(2) +array(0) { +} + +Warning: Unknown: Parent session handler is not open in Unknown on line 0 + +Warning: Unknown: Parent session handler is not open in Unknown on line 0 diff --git a/ext/session/tests/session_set_save_handler_class_013.phpt b/ext/session/tests/session_set_save_handler_class_013.phpt new file mode 100644 index 0000000..f536aa7 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_013.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test session_set_save_handler() : incorrect arguments for existing handler close +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : incorrect arguments for existing handler close ***\n"; + +class MySession extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } + public function close() { + return parent::close(false); + } +} + +$oldHandler = ini_get('session.save_handler'); +$handler = new MySession; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); + +--EXPECTF-- +*** Testing session_set_save_handler() : incorrect arguments for existing handler close *** +Open +Read %s +string(%d) "%s" +string(5) "files" +string(4) "user" +int(2) +array(0) { +} + +Warning: SessionHandler::close() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/session/tests/session_set_save_handler_class_014.phpt b/ext/session/tests/session_set_save_handler_class_014.phpt new file mode 100644 index 0000000..ea62beb --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_014.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test session_set_save_handler() : calling default handler when save_handler=user +--INI-- +session.save_handler=user +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : calling default handler when save_handler=user ***\n"; + +$oldHandler = ini_get('session.save_handler'); +$handler = new SessionHandler; +session_set_save_handler($handler); + +session_start(); + +--EXPECTF-- +*** Testing session_set_save_handler() : calling default handler when save_handler=user *** + +Fatal error: SessionHandler::open(): Cannot call default session handler in %s on line %d diff --git a/ext/session/tests/session_set_save_handler_class_015.phpt b/ext/session/tests/session_set_save_handler_class_015.phpt new file mode 100644 index 0000000..3bef51b --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_015.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test session_set_save_handler() : register session handler but don't start +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : register session handler but don't start ***\n"; + +session_set_save_handler(new SessionHandler); + +--EXPECTF-- +*** Testing session_set_save_handler() : register session handler but don't start *** diff --git a/ext/session/tests/session_set_save_handler_closures.phpt b/ext/session/tests/session_set_save_handler_closures.phpt new file mode 100644 index 0000000..21b2c68 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_closures.phpt @@ -0,0 +1,95 @@ +--TEST-- +Test session_set_save_handler() function : using closures as callbacks +--INI-- +session.save_path= +session.name=PHPSESSID +--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() : using closures as callbacks ***\n"; + +require_once "save_handler_closures.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_closure, $close_closure, $read_closure, $write_closure, $destroy_closure, $gc_closure); + +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_closure, $close_closure, $read_closure, $write_closure, $destroy_closure, $gc_closure); +session_start(); +var_dump($_SESSION); +session_write_close(); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : using closures as callbacks *** + +string(%d) "%s" + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d +bool(false) + +Warning: session_module_name(): Cannot find named PHP session module (foo) in %s on line %d +bool(false) +Open [%s,PHPSESSID] +Read [%s,%s] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Close [%s,PHPSESSID] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Starting session again..! +Open [%s,PHPSESSID] +Read [%s,%s] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Close [%s,PHPSESSID] diff --git a/ext/session/tests/session_set_save_handler_error.phpt b/ext/session/tests/session_set_save_handler_error.phpt new file mode 100644 index 0000000..bf9d25d --- /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 0000000..03ba3b0 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_error2.phpt @@ -0,0 +1,62 @@ +--TEST-- +Test session_set_save_handler() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : error functionality ***\n"; + +function open($save_path, $session_name) { return true; } +function close() { return true; } +function read($id) { return false; } +function write($id, $session_data) { } +function destroy($id) { return true; } +function gc($maxlifetime) { return true; } + +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); + +session_start(); +$_SESSION["Blah"] = "Hello World!"; +$_SESSION["Foo"] = FALSE; +$_SESSION["Guff"] = 1234567890; +var_dump($_SESSION); + +session_write_close(); +var_dump($_SESSION); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_start(); +var_dump($_SESSION); +session_destroy(); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : error functionality *** +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +array(0) { +} + diff --git a/ext/session/tests/session_set_save_handler_error3.phpt b/ext/session/tests/session_set_save_handler_error3.phpt new file mode 100644 index 0000000..446ef7b --- /dev/null +++ b/ext/session/tests/session_set_save_handler_error3.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_set_save_handler() function : error functionality +--INI-- +session.save_path= +session.name=PHPSESSID +--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 0000000..4debde5 --- /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_iface_001.phpt b/ext/session/tests/session_set_save_handler_iface_001.phpt new file mode 100644 index 0000000..39a4b99 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_iface_001.phpt @@ -0,0 +1,113 @@ +--TEST-- +Test session_set_save_handler() function: interface +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandlerInterface $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() function: interface ***\n"; + +class MySession2 implements SessionHandlerInterface { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } +} + +$handler = new MySession2; +session_set_save_handler(array($handler, 'open'), array($handler, 'close'), + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc')); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() function: interface *** +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_iface_002.phpt b/ext/session/tests/session_set_save_handler_iface_002.phpt new file mode 100644 index 0000000..40c9ac6 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_iface_002.phpt @@ -0,0 +1,90 @@ +--TEST-- +Test session_set_save_handler() function: interface wrong +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandlerInterface $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() function: interface wrong ***\n"; + +interface MySessionHandlerInterface { + public function open($path, $name); + public function close(); + public function read($id); + public function write($id, $data); + public function destroy($id); + public function gc($maxlifetime); +} + +class MySession2 implements MySessionHandlerInterface { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + echo "Unsupported session handler in use\n"; + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } +} + +function good_write($id, $data) { + global $handler; + echo "good handler writing\n"; + return file_put_contents($handler->path . $id, $data); +} + +$handler = new MySession2; + +$ret = session_set_save_handler(array($handler, 'open'), array($handler, 'close'), + array($handler, 'read'), 'good_write', array($handler, 'destroy'), array($handler, 'gc')); + +var_dump($ret); +$ret = session_set_save_handler($handler); +var_dump($ret); + +session_start(); + +--EXPECTF-- +*** Testing session_set_save_handler() function: interface wrong *** +bool(true) + +Warning: session_set_save_handler() expects parameter 1 to be SessionHandlerInterface, object given in %s +bool(false) +good handler writing diff --git a/ext/session/tests/session_set_save_handler_variation1.phpt b/ext/session/tests/session_set_save_handler_variation1.phpt new file mode 100644 index 0000000..fe1d2b0 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation1.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_set_save_handler() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : variation ***\n"; + +var_dump(session_module_name()); +var_dump(session_module_name(FALSE)); +var_dump(session_module_name()); +var_dump(session_module_name("blah")); +var_dump(session_module_name()); +var_dump(session_module_name("files")); +var_dump(session_module_name()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : variation *** +string(%d) "%s" + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) +string(%d) "%s" + +Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d +bool(false) +string(%d) "%s" +string(%d) "%s" +string(5) "files" diff --git a/ext/session/tests/session_set_save_handler_variation2.phpt b/ext/session/tests/session_set_save_handler_variation2.phpt new file mode 100644 index 0000000..1c019bb --- /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 0000000..774d0db --- /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_set_save_handler_variation4.phpt b/ext/session/tests/session_set_save_handler_variation4.phpt new file mode 100644 index 0000000..3485f23 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation4.phpt @@ -0,0 +1,83 @@ +--TEST-- +Test session_set_save_handler() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.gc_probability=1 +session.gc_divisor=1 +session.gc_maxlifetime=0 +session.save_path= +session.name=PHPSESSID +--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"; + +function noisy_gc($maxlifetime) { + echo("GC [".$maxlifetime."]\n"); + gc($maxlifetime); +} + +require_once "save_handler.inc"; +$path = dirname(__FILE__); +session_save_path($path); +session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc"); + +session_start(); +$_SESSION["Blah"] = "Hello World!"; +$_SESSION["Foo"] = FALSE; +$_SESSION["Guff"] = 1234567890; +var_dump($_SESSION); +$session_id = session_id(); +var_dump(session_write_close()); + +session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc"); +session_id($session_id); +session_start(); +var_dump($_SESSION); +var_dump(session_destroy()); + +ob_end_flush(); +?> +--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) + diff --git a/ext/session/tests/session_start_error.phpt b/ext/session/tests/session_start_error.phpt new file mode 100644 index 0000000..8cbf42c --- /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 0000000..1c8f3eb --- /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 0000000..6c9b29e --- /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 0000000..e87f84b --- /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 0000000..4289549 --- /dev/null +++ b/ext/session/tests/session_start_variation4.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +$_SESSION['blah'] = 'foo'; +var_dump($_SESSION); +session_start(); +var_dump($_SESSION); + +session_destroy(); +echo "Done"; +ob_end_flush(); + +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(1) { + ["blah"]=> + string(3) "foo" +} +array(0) { +} +Done + diff --git a/ext/session/tests/session_start_variation5.phpt b/ext/session/tests/session_start_variation5.phpt new file mode 100644 index 0000000..4dcafac --- /dev/null +++ b/ext/session/tests/session_start_variation5.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +session_start(); + +$_SESSION['colour'] = 'green'; +$_SESSION['animal'] = 'cat'; +$_SESSION['person'] = 'julia'; +$_SESSION['age'] = 6; + +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); + +session_start(); +session_destroy(); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +NULL +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +Done + diff --git a/ext/session/tests/session_start_variation6.phpt b/ext/session/tests/session_start_variation6.phpt new file mode 100644 index 0000000..378554b --- /dev/null +++ b/ext/session/tests/session_start_variation6.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +session_start(); + +$_SESSION['colour'] = 'green'; +$_SESSION['animal'] = 'cat'; +$_SESSION['person'] = 'julia'; +$_SESSION['age'] = 6; + +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +session_start(); +var_dump($_SESSION); + +session_destroy(); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +NULL +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +Done + diff --git a/ext/session/tests/session_start_variation7.phpt b/ext/session/tests/session_start_variation7.phpt new file mode 100644 index 0000000..be079f3 --- /dev/null +++ b/ext/session/tests/session_start_variation7.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +session_start(); + +$_SESSION['colour'] = 'green'; +$_SESSION['animal'] = 'cat'; +$_SESSION['person'] = 'julia'; +$_SESSION['age'] = 6; + +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); +session_start(); +var_dump($_SESSION); + +session_destroy(); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +bool(true) +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +array(0) { +} +Done + diff --git a/ext/session/tests/session_start_variation8.phpt b/ext/session/tests/session_start_variation8.phpt new file mode 100644 index 0000000..9365475 --- /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 0000000..21523e0 --- /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_status.phpt b/ext/session/tests/session_status.phpt new file mode 100644 index 0000000..d1f7e2f --- /dev/null +++ b/ext/session/tests/session_status.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test session_status() function : active, none +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +echo "*** Testing session_status() : active, none\n"; + +var_dump(PHP_SESSION_NONE != PHP_SESSION_ACTIVE); +var_dump(session_status() == PHP_SESSION_NONE); + +session_start(); + +var_dump(session_status() == PHP_SESSION_ACTIVE); + +?> +--EXPECTF-- +*** Testing session_status() : active, none +bool(true) +bool(true) +bool(true) diff --git a/ext/session/tests/session_status_disabled.phpt b/ext/session/tests/session_status_disabled.phpt new file mode 100644 index 0000000..24e0ecd --- /dev/null +++ b/ext/session/tests/session_status_disabled.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test session_status() function : disabled +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_handler=non-existant +--FILE-- +<?php + +echo "*** Testing session_status() : disabled\n"; + +var_dump(session_status() == PHP_SESSION_DISABLED); + +?> +--EXPECTF-- +*** Testing session_status() : disabled +bool(true) diff --git a/ext/session/tests/session_unset_basic.phpt b/ext/session/tests/session_unset_basic.phpt new file mode 100644 index 0000000..21b12c4 --- /dev/null +++ b/ext/session/tests/session_unset_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_unset() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_unset(void) + * Description : Free all session variables + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unset() : basic functionality ***\n"; + +var_dump(session_start()); +$_SESSION["foo"] = "Hello World!"; +var_dump($_SESSION); +var_dump(session_unset()); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unset() : basic functionality *** +bool(true) +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +NULL +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_unset_error.phpt b/ext/session/tests/session_unset_error.phpt new file mode 100644 index 0000000..9478345 --- /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 0000000..17ab283 --- /dev/null +++ b/ext/session/tests/session_unset_variation1.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test session_unset() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_unset(void) + * Description : Free all session variables + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unset() : variation ***\n"; + +var_dump(session_unset()); +var_dump(session_start()); +var_dump(session_unset()); +$_SESSION["foo"] = "Hello World!"; +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump(session_unset()); +var_dump($_SESSION); +var_dump(session_unset()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unset() : variation *** +bool(false) +bool(true) +NULL +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +bool(true) +bool(false) +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +bool(false) +Done + diff --git a/ext/session/tests/session_write_close_basic.phpt b/ext/session/tests/session_write_close_basic.phpt new file mode 100644 index 0000000..0841afe --- /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 0000000..cbdb55f --- /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 0000000..595796d --- /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 0000000..40871c5 --- /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 0000000..0f80616 --- /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 0000000..249c155 --- /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 + diff --git a/ext/session/tests/sessionhandler_open_001.phpt b/ext/session/tests/sessionhandler_open_001.phpt new file mode 100644 index 0000000..6ade9e0 --- /dev/null +++ b/ext/session/tests/sessionhandler_open_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing repated SessionHandler::open() calls +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ini_set('session.save_handler', 'files'); +$x = new SessionHandler; +$x->open('',''); +$x->open('',''); +$x->open('',''); +$x->open('',''); + +print "Done!\n"; + +?> +--EXPECTF-- +Done! diff --git a/ext/session/tests/skipif.inc b/ext/session/tests/skipif.inc new file mode 100644 index 0000000..e63f963 --- /dev/null +++ b/ext/session/tests/skipif.inc @@ -0,0 +1,25 @@ +<?php +// This script prints "skip" if condition does not meet. +if (!extension_loaded("session") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("session$dlext"); +} +if (!extension_loaded("session")) { + die("skip Session module not loaded"); +} +$save_path = ini_get("session.save_path"); +if ($save_path) { + if (!file_exists($save_path)) { + die("skip Session save_path doesn't exist"); + } + + if ($save_path && !@is_writable($save_path)) { + if (($p = strpos($save_path, ';')) !== false) { + $save_path = substr($save_path, ++$p); + } + if (!@is_writable($save_path)) { + die("skip session.save_path $save_path is not writable\n"); + } + } +} +?> |