Annotation of embedaddon/php/ext/session/tests/session_set_save_handler_class_001.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test session_set_save_handler() : basic class wrapping existing handler
! 3: --INI--
! 4: session.save_handler=files
! 5: session.name=PHPSESSID
! 6: --SKIPIF--
! 7: <?php include('skipif.inc'); ?>
! 8: --FILE--
! 9: <?php
! 10:
! 11: ob_start();
! 12:
! 13: /*
! 14: * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true])
! 15: * Description : Sets user-level session storage functions
! 16: * Source code : ext/session/session.c
! 17: */
! 18:
! 19: echo "*** Testing session_set_save_handler() : basic class wrapping existing handler ***\n";
! 20:
! 21: class MySession extends SessionHandler {
! 22: public $i = 0;
! 23: public function open($path, $name) {
! 24: ++$this->i;
! 25: echo 'Open ', session_id(), "\n";
! 26: return parent::open($path, $name);
! 27: }
! 28: public function read($key) {
! 29: ++$this->i;
! 30: echo 'Read ', session_id(), "\n";
! 31: return parent::read($key);
! 32: }
! 33: }
! 34:
! 35: $oldHandler = ini_get('session.save_handler');
! 36: $handler = new MySession;
! 37: session_set_save_handler($handler);
! 38: session_start();
! 39:
! 40: var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION);
! 41:
! 42: $_SESSION['foo'] = "hello";
! 43:
! 44: session_write_close();
! 45: session_unset();
! 46:
! 47: session_start();
! 48: var_dump($_SESSION);
! 49:
! 50: session_write_close();
! 51: session_unset();
! 52:
! 53: --EXPECTF--
! 54: *** Testing session_set_save_handler() : basic class wrapping existing handler ***
! 55: Open
! 56: Read %s
! 57: string(%d) "%s"
! 58: string(5) "files"
! 59: string(4) "user"
! 60: int(2)
! 61: array(0) {
! 62: }
! 63: Open %s
! 64: Read %s
! 65: array(1) {
! 66: ["foo"]=>
! 67: string(5) "hello"
! 68: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>