Annotation of embedaddon/php/ext/spl/tests/observer_004.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: SPL: SplObjectStorage serialization & overloading
        !             3: --FILE--
        !             4: <?php
        !             5: 
        !             6: class TestClass
        !             7: {
        !             8:        public $test = 25;
        !             9:        
        !            10:        public function __construct($test = 42)
        !            11:        {
        !            12:                $this->test = $test;
        !            13:        }
        !            14: }
        !            15: 
        !            16: class MyStorage extends SplObjectStorage
        !            17: {
        !            18:        public $bla = 25;
        !            19:        
        !            20:        public function __construct($bla = 26)
        !            21:        {
        !            22:                $this->bla = $bla;
        !            23:        }
        !            24: }
        !            25: 
        !            26: $storage = new MyStorage();
        !            27: 
        !            28: foreach(array(1,2) as $value)
        !            29: {
        !            30:      $storage->attach(new TestClass($value));
        !            31: }
        !            32: 
        !            33: var_dump(count($storage));
        !            34: 
        !            35: foreach($storage as $object)
        !            36: {
        !            37:        var_dump($object->test);
        !            38: }
        !            39: 
        !            40: var_dump($storage);
        !            41: 
        !            42: var_dump(serialize($storage));
        !            43: echo "===UNSERIALIZE===\n";
        !            44: 
        !            45: $storage2 = unserialize(serialize($storage));
        !            46: 
        !            47: var_dump(count($storage2));
        !            48: 
        !            49: foreach($storage2 as $object)
        !            50: {
        !            51:        var_dump($object->test);
        !            52: }
        !            53: 
        !            54: var_dump($storage2);
        !            55: 
        !            56: ?>
        !            57: ===DONE===
        !            58: <?php exit(0); ?>
        !            59: --EXPECTF--
        !            60: int(2)
        !            61: int(1)
        !            62: int(2)
        !            63: object(MyStorage)#%d (2) {
        !            64:   ["bla"]=>
        !            65:   int(26)
        !            66:   ["storage":"SplObjectStorage":private]=>
        !            67:   array(2) {
        !            68:     ["%s"]=>
        !            69:     array(2) {
        !            70:       ["obj"]=>
        !            71:       object(TestClass)#%d (1) {
        !            72:         ["test"]=>
        !            73:         int(1)
        !            74:       }
        !            75:       ["inf"]=>
        !            76:       NULL
        !            77:     }
        !            78:     ["%s"]=>
        !            79:     array(2) {
        !            80:       ["obj"]=>
        !            81:       object(TestClass)#%d (1) {
        !            82:         ["test"]=>
        !            83:         int(2)
        !            84:       }
        !            85:       ["inf"]=>
        !            86:       NULL
        !            87:     }
        !            88:   }
        !            89: }
        !            90: string(%d) "%s"
        !            91: ===UNSERIALIZE===
        !            92: int(2)
        !            93: int(1)
        !            94: int(2)
        !            95: object(MyStorage)#%d (2) {
        !            96:   ["bla"]=>
        !            97:   int(26)
        !            98:   ["storage":"SplObjectStorage":private]=>
        !            99:   array(2) {
        !           100:     ["%s"]=>
        !           101:     array(2) {
        !           102:       ["obj"]=>
        !           103:       object(TestClass)#%d (1) {
        !           104:         ["test"]=>
        !           105:         int(1)
        !           106:       }
        !           107:       ["inf"]=>
        !           108:       NULL
        !           109:     }
        !           110:     ["%s"]=>
        !           111:     array(2) {
        !           112:       ["obj"]=>
        !           113:       object(TestClass)#%d (1) {
        !           114:         ["test"]=>
        !           115:         int(2)
        !           116:       }
        !           117:       ["inf"]=>
        !           118:       NULL
        !           119:     }
        !           120:   }
        !           121: }
        !           122: ===DONE===

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