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

1.1       misho       1: --TEST--
                      2: custom save handler, multiple session_start()s, complex data structure test.
                      3: --SKIPIF--
                      4: <?php include('skipif.inc'); ?>
                      5: --INI--
                      6: session.use_cookies=0
                      7: session.cache_limiter=
                      8: register_globals=1
                      9: session.name=PHPSESSID
                     10: session.serialize_handler=php
                     11: --FILE--
                     12: <?php
                     13: 
                     14: error_reporting(E_ALL);
                     15: 
                     16: class handler {
                     17:        public $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;}}';
                     18:     function open($save_path, $session_name)
                     19:     {
                     20:         print "OPEN: $session_name\n";
                     21:         return true;
                     22:     }
                     23:     function close()
                     24:     {
                     25:                print "CLOSE\n";
                     26:         return true;
                     27:     }
                     28:     function read($key)
                     29:     {
                     30:         print "READ: $key\n";
                     31:         return $GLOBALS["hnd"]->data;
                     32:     }
                     33: 
                     34:     function write($key, $val)
                     35:     {
                     36:         print "WRITE: $key, $val\n";
                     37:                $GLOBALS["hnd"]->data = $val;
                     38:         return true;
                     39:     }
                     40: 
                     41:     function destroy($key)
                     42:     {
                     43:         print "DESTROY: $key\n";
                     44:         return true;
                     45:     }
                     46: 
                     47:     function gc() { return true; }
                     48: }
                     49: 
                     50: $hnd = new handler;
                     51: 
                     52: class foo {
                     53:     public $bar = "ok";
                     54:     function method() { $this->yes++; }
                     55: }
                     56: 
                     57: session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc"));
                     58: 
                     59: session_id("abtest");
                     60: session_start();
                     61: $baz->method();
                     62: $arr[3]->method();
                     63: 
                     64: var_dump($baz);
                     65: var_dump($arr);
                     66: 
                     67: session_write_close();
                     68: 
                     69: session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc"));
                     70: session_start();
                     71: $baz->method();
                     72: $arr[3]->method();
                     73: 
                     74: 
                     75: $c = 123;
                     76: session_register("c");
                     77: var_dump($baz); var_dump($arr); var_dump($c);
                     78: 
                     79: session_write_close();
                     80: 
                     81: session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc"));
                     82: session_start();
                     83: var_dump($baz); var_dump($arr); var_dump($c);
                     84: 
                     85: session_destroy();
                     86: ?>
                     87: --EXPECTF--
                     88: Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
                     89: OPEN: PHPSESSID
                     90: READ: abtest
                     91: object(foo)#2 (2) {
                     92:   ["bar"]=>
                     93:   string(2) "ok"
                     94:   ["yes"]=>
                     95:   int(2)
                     96: }
                     97: array(1) {
                     98:   [3]=>
                     99:   object(foo)#3 (2) {
                    100:     ["bar"]=>
                    101:     string(2) "ok"
                    102:     ["yes"]=>
                    103:     int(2)
                    104:   }
                    105: }
                    106: WRITE: abtest, 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;}}
                    107: CLOSE
                    108: OPEN: PHPSESSID
                    109: READ: abtest
                    110: 
                    111: Deprecated: Function session_register() is deprecated in %s on line %d
                    112: object(foo)#4 (2) {
                    113:   ["bar"]=>
                    114:   string(2) "ok"
                    115:   ["yes"]=>
                    116:   int(3)
                    117: }
                    118: array(1) {
                    119:   [3]=>
                    120:   object(foo)#2 (2) {
                    121:     ["bar"]=>
                    122:     string(2) "ok"
                    123:     ["yes"]=>
                    124:     int(3)
                    125:   }
                    126: }
                    127: int(123)
                    128: WRITE: abtest, 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;
                    129: CLOSE
                    130: OPEN: PHPSESSID
                    131: READ: abtest
                    132: object(foo)#3 (2) {
                    133:   ["bar"]=>
                    134:   string(2) "ok"
                    135:   ["yes"]=>
                    136:   int(3)
                    137: }
                    138: array(1) {
                    139:   [3]=>
                    140:   object(foo)#4 (2) {
                    141:     ["bar"]=>
                    142:     string(2) "ok"
                    143:     ["yes"]=>
                    144:     int(3)
                    145:   }
                    146: }
                    147: int(123)
                    148: DESTROY: abtest
                    149: CLOSE
                    150: 

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