summaryrefslogtreecommitdiff
path: root/ext/session/tests/session_set_save_handler_class_003.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/session/tests/session_set_save_handler_class_003.phpt')
-rw-r--r--ext/session/tests/session_set_save_handler_class_003.phpt78
1 files changed, 78 insertions, 0 deletions
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"