Annotation of embedaddon/php/ext/standard/tests/serialize/serialization_objects_011.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Object serialization / unserialization with inherited and hidden properties.
        !             3: --FILE--
        !             4: <?php
        !             5: /* Prototype  : proto string serialize(mixed variable)
        !             6:  * Description: Returns a string representation of variable (which can later be unserialized) 
        !             7:  * Source code: ext/standard/var.c
        !             8:  * Alias to functions: 
        !             9:  */
        !            10: /* Prototype  : proto mixed unserialize(string variable_representation)
        !            11:  * Description: Takes a string representation of variable and recreates it 
        !            12:  * Source code: ext/standard/var.c
        !            13:  * Alias to functions: 
        !            14:  */
        !            15: 
        !            16: Class A {
        !            17:        private $APriv = "A.APriv";
        !            18:        protected $AProt = "A.AProt";
        !            19:        public $APub = "A.APub";
        !            20:        
        !            21:        function audit() {
        !            22:                return isset($this->APriv, $this->AProt, $this->APub); 
        !            23:        }               
        !            24: }
        !            25: 
        !            26: Class B extends A {
        !            27:        private $BPriv = "B.BPriv";
        !            28:        protected $BProt = "B.BProt";
        !            29:        public $BPub = "B.BPub";
        !            30:        
        !            31:        function audit() {
        !            32:                return  parent::audit() && isset($this->AProt, $this->APub,
        !            33:                                         $this->BPriv, $this->BProt, $this->BPub); 
        !            34:        }       
        !            35: }
        !            36: 
        !            37: Class C extends B {
        !            38:        private $APriv = "C.APriv";
        !            39:        protected $AProt = "C.AProt";
        !            40:        public $APub = "C.APub";
        !            41:        
        !            42:        private $CPriv = "C.CPriv";
        !            43:        protected $CProt = "C.BProt";
        !            44:        public $CPub = "C.CPub";
        !            45:        
        !            46:        function audit() {
        !            47:                return parent::audit() && isset($this->APriv, $this->AProt, $this->APub, 
        !            48:                                         $this->BProt, $this->BPub, 
        !            49:                                         $this->CPriv, $this->CProt, $this->CPub); 
        !            50:        }
        !            51: }
        !            52: 
        !            53: function prettyPrint($obj) {
        !            54:        echo "\n\nBefore serialization:\n";
        !            55:        var_dump($obj);
        !            56: 
        !            57:        echo "Serialized form:\n";
        !            58:        $ser = serialize($obj);
        !            59:        $serPrintable = str_replace("\0", '\0', $ser);
        !            60:        var_dump($serPrintable);
        !            61:        
        !            62:        echo "Unserialized:\n";
        !            63:        $uobj = unserialize($ser);
        !            64:        var_dump($uobj);
        !            65:        
        !            66:        echo "Sanity check: ";
        !            67:        var_dump($uobj->audit());
        !            68: }
        !            69: 
        !            70: echo "-- Test instance of A --\n";
        !            71: prettyPrint(new A);
        !            72: echo "\n\n-- Test instance of B --\n";
        !            73: prettyPrint(new B);
        !            74: echo "\n\n-- Test instance of C --\n";
        !            75: prettyPrint(new C);
        !            76: 
        !            77: echo "Done";
        !            78: ?>
        !            79: --EXPECTF--
        !            80: -- Test instance of A --
        !            81: 
        !            82: 
        !            83: Before serialization:
        !            84: object(A)#%d (3) {
        !            85:   ["APriv":"A":private]=>
        !            86:   string(7) "A.APriv"
        !            87:   ["AProt":protected]=>
        !            88:   string(7) "A.AProt"
        !            89:   ["APub"]=>
        !            90:   string(6) "A.APub"
        !            91: }
        !            92: Serialized form:
        !            93: string(98) "O:1:"A":3:{s:8:"\0A\0APriv";s:7:"A.APriv";s:8:"\0*\0AProt";s:7:"A.AProt";s:4:"APub";s:6:"A.APub";}"
        !            94: Unserialized:
        !            95: object(A)#%d (3) {
        !            96:   ["APriv":"A":private]=>
        !            97:   string(7) "A.APriv"
        !            98:   ["AProt":protected]=>
        !            99:   string(7) "A.AProt"
        !           100:   ["APub"]=>
        !           101:   string(6) "A.APub"
        !           102: }
        !           103: Sanity check: bool(true)
        !           104: 
        !           105: 
        !           106: -- Test instance of B --
        !           107: 
        !           108: 
        !           109: Before serialization:
        !           110: object(B)#%d (6) {
        !           111:   ["BPriv":"B":private]=>
        !           112:   string(7) "B.BPriv"
        !           113:   ["BProt":protected]=>
        !           114:   string(7) "B.BProt"
        !           115:   ["BPub"]=>
        !           116:   string(6) "B.BPub"
        !           117:   ["APriv":"A":private]=>
        !           118:   string(7) "A.APriv"
        !           119:   ["AProt":protected]=>
        !           120:   string(7) "A.AProt"
        !           121:   ["APub"]=>
        !           122:   string(6) "A.APub"
        !           123: }
        !           124: Serialized form:
        !           125: string(184) "O:1:"B":6:{s:8:"\0B\0BPriv";s:7:"B.BPriv";s:8:"\0*\0BProt";s:7:"B.BProt";s:4:"BPub";s:6:"B.BPub";s:8:"\0A\0APriv";s:7:"A.APriv";s:8:"\0*\0AProt";s:7:"A.AProt";s:4:"APub";s:6:"A.APub";}"
        !           126: Unserialized:
        !           127: object(B)#%d (6) {
        !           128:   ["BPriv":"B":private]=>
        !           129:   string(7) "B.BPriv"
        !           130:   ["BProt":protected]=>
        !           131:   string(7) "B.BProt"
        !           132:   ["BPub"]=>
        !           133:   string(6) "B.BPub"
        !           134:   ["APriv":"A":private]=>
        !           135:   string(7) "A.APriv"
        !           136:   ["AProt":protected]=>
        !           137:   string(7) "A.AProt"
        !           138:   ["APub"]=>
        !           139:   string(6) "A.APub"
        !           140: }
        !           141: Sanity check: bool(true)
        !           142: 
        !           143: 
        !           144: -- Test instance of C --
        !           145: 
        !           146: 
        !           147: Before serialization:
        !           148: object(C)#%d (10) {
        !           149:   ["APriv":"C":private]=>
        !           150:   string(7) "C.APriv"
        !           151:   ["AProt":protected]=>
        !           152:   string(7) "C.AProt"
        !           153:   ["APub"]=>
        !           154:   string(6) "C.APub"
        !           155:   ["CPriv":"C":private]=>
        !           156:   string(7) "C.CPriv"
        !           157:   ["CProt":protected]=>
        !           158:   string(7) "C.BProt"
        !           159:   ["CPub"]=>
        !           160:   string(6) "C.CPub"
        !           161:   ["BPriv":"B":private]=>
        !           162:   string(7) "B.BPriv"
        !           163:   ["BProt":protected]=>
        !           164:   string(7) "B.BProt"
        !           165:   ["BPub"]=>
        !           166:   string(6) "B.BPub"
        !           167:   ["APriv":"A":private]=>
        !           168:   string(7) "A.APriv"
        !           169: }
        !           170: Serialized form:
        !           171: string(302) "O:1:"C":10:{s:8:"\0C\0APriv";s:7:"C.APriv";s:8:"\0*\0AProt";s:7:"C.AProt";s:4:"APub";s:6:"C.APub";s:8:"\0C\0CPriv";s:7:"C.CPriv";s:8:"\0*\0CProt";s:7:"C.BProt";s:4:"CPub";s:6:"C.CPub";s:8:"\0B\0BPriv";s:7:"B.BPriv";s:8:"\0*\0BProt";s:7:"B.BProt";s:4:"BPub";s:6:"B.BPub";s:8:"\0A\0APriv";s:7:"A.APriv";}"
        !           172: Unserialized:
        !           173: object(C)#%d (10) {
        !           174:   ["APriv":"C":private]=>
        !           175:   string(7) "C.APriv"
        !           176:   ["AProt":protected]=>
        !           177:   string(7) "C.AProt"
        !           178:   ["APub"]=>
        !           179:   string(6) "C.APub"
        !           180:   ["CPriv":"C":private]=>
        !           181:   string(7) "C.CPriv"
        !           182:   ["CProt":protected]=>
        !           183:   string(7) "C.BProt"
        !           184:   ["CPub"]=>
        !           185:   string(6) "C.CPub"
        !           186:   ["BPriv":"B":private]=>
        !           187:   string(7) "B.BPriv"
        !           188:   ["BProt":protected]=>
        !           189:   string(7) "B.BProt"
        !           190:   ["BPub"]=>
        !           191:   string(6) "B.BPub"
        !           192:   ["APriv":"A":private]=>
        !           193:   string(7) "A.APriv"
        !           194: }
        !           195: Sanity check: bool(true)
        !           196: Done

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