Annotation of embedaddon/php/ext/session/tests/session_set_save_handler_class_011.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test session_set_save_handler() : shutdown failure
                      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() : shutdown failure ***\n";
                     20: 
                     21: class MySession extends SessionHandler {
                     22:        public $num;
                     23:        public $destroyed = false;
                     24:        public function __construct($num) {
                     25:                $this->num = $num;
                     26:                echo "(#$this->num) constructor called\n";
                     27:        }
                     28:        public function __destruct() {
                     29:                echo "(#$this->num) destructor called\n";
                     30:                $this->destroyed = true;
                     31:        }
                     32:        public function write($id, $data) {
                     33:                if ($this->destroyed) {
                     34:                        echo "(#$this->num) destroyed, cannot write\n";
                     35:                } else {
                     36:                        echo "(#$this->num) writing $id = $data\n";
                     37:                }
                     38:                return parent::write($id, $data);
                     39:        }
                     40:        public function close() {
                     41:                $id = session_id();
                     42:                if ($this->destroyed) {
                     43:                        echo "(#$this->num) destroyed, cannot write\n";
                     44:                } else {
                     45:                        echo "(#$this->num) closing $id\n";
                     46:                }
                     47:                return parent::close();
                     48:        }
                     49: }
                     50: 
                     51: $handler = new MySession(1);
                     52: session_set_save_handler($handler, false);
                     53: session_start();
                     54: 
                     55: $_SESSION['foo'] = 'bar';
                     56: 
                     57: echo "done\n";
                     58: ob_end_flush();
                     59: ?>
                     60: --EXPECTF--
                     61: *** Testing session_set_save_handler() : shutdown failure ***
                     62: (#1) constructor called
                     63: done
                     64: (#1) destructor called
                     65: (#1) destroyed, cannot write
                     66: (#1) destroyed, cannot write

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>