From: Sascha Schumann Date: Sun, 24 Dec 2000 16:33:27 +0000 (+0000) Subject: Add session_set_save_handler test X-Git-Tag: php-4.0.5RC1~792 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e22a8a73b544c56e24d78f90238194e31c675b5;p=php Add session_set_save_handler test --- diff --git a/ext/session/tests/004.phpt b/ext/session/tests/004.phpt new file mode 100644 index 0000000000..0840dcb137 --- /dev/null +++ b/ext/session/tests/004.phpt @@ -0,0 +1,85 @@ +--TEST-- +session_set_save_handler test +--FILE-- +data; + } + + function write($key, $val) + { + print "WRITE: $key, $val\n"; + $this->data = $val; + return true; + } + + function destroy($key) + { + print "DESTROY: $key\n"; + return true; + } + + function gc() { return true; } +} + +$hnd = new handler; + +class foo { + var $bar = "ok"; + function method() { $this->yes++; } +} + +ob_start(); + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); + +session_id("test"); +session_start(); +$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(); + +session_destroy(); +--EXPECT-- +OPEN: /tmp, PHPSESSID +READ: test +object(foo)(2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + &object(foo)(2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} +WRITE: test, 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: /tmp, PHPSESSID +READ: test +DESTROY: test