summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2001-01-07 10:40:41 +0000
committerSascha Schumann <sas@php.net>2001-01-07 10:40:41 +0000
commit41cd55dd44e296b56cccf91c9f2c074b414a32b0 (patch)
tree7600c6141bc642e5850a8b58ab07f55dfce72564
parent24c49a21b9ecf0833a4816bd6d24acb105356ce4 (diff)
downloadphp-git-41cd55dd44e296b56cccf91c9f2c074b414a32b0.tar.gz
Add a new test and refine the fourth test
-rw-r--r--ext/session/tests/004.phpt22
-rw-r--r--ext/session/tests/005.phpt138
2 files changed, 158 insertions, 2 deletions
diff --git a/ext/session/tests/004.phpt b/ext/session/tests/004.phpt
index 0840dcb137..8e6ec4e8d3 100644
--- a/ext/session/tests/004.phpt
+++ b/ext/session/tests/004.phpt
@@ -17,13 +17,13 @@ class handler {
function read($key)
{
print "READ: $key\n";
- return $this->data;
+ return $GLOBALS["hnd"]->data;
}
function write($key, $val)
{
print "WRITE: $key, $val\n";
- $this->data = $val;
+ $GLOBALS["hnd"]->data = $val;
return true;
}
@@ -60,6 +60,9 @@ 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();
--EXPECT--
OPEN: /tmp, PHPSESSID
@@ -82,4 +85,19 @@ array(1) {
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
+object(foo)(2) {
+ ["bar"]=>
+ string(2) "ok"
+ ["yes"]=>
+ int(2)
+}
+array(1) {
+ [3]=>
+ object(foo)(2) {
+ ["bar"]=>
+ string(2) "ok"
+ ["yes"]=>
+ int(2)
+ }
+}
DESTROY: test
diff --git a/ext/session/tests/005.phpt b/ext/session/tests/005.phpt
new file mode 100644
index 0000000000..38e660b100
--- /dev/null
+++ b/ext/session/tests/005.phpt
@@ -0,0 +1,138 @@
+--TEST--
+Custom save handler, multiple session_start()s, complex data structure test.
+--FILE--
+<?php
+
+class handler {
+ var $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: $save_path, $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 {
+ 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();
+$baz->method();
+$arr[3]->method();
+
+
+$c = 123;
+session_register("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();
+?>
+--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;}}
+CLOSE
+OPEN: /tmp, PHPSESSID
+READ: test
+object(foo)(2) {
+ ["bar"]=>
+ string(2) "ok"
+ ["yes"]=>
+ int(3)
+}
+array(1) {
+ [3]=>
+ &object(foo)(2) {
+ ["bar"]=>
+ string(2) "ok"
+ ["yes"]=>
+ int(3)
+ }
+}
+int(123)
+WRITE: test, 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: /tmp, PHPSESSID
+READ: test
+object(foo)(2) {
+ ["bar"]=>
+ string(2) "ok"
+ ["yes"]=>
+ int(3)
+}
+array(1) {
+ [3]=>
+ object(foo)(2) {
+ ["bar"]=>
+ string(2) "ok"
+ ["yes"]=>
+ int(3)
+ }
+}
+int(123)
+DESTROY: test
+CLOSE