Annotation of embedaddon/php/ext/standard/tests/serialize/serialization_objects_003.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test serialize() & unserialize() functions: objects (abstract classes)
                      3: --INI--
                      4: serialize_precision=100
                      5: --FILE--
                      6: <?php 
                      7: /* Prototype  : proto string serialize(mixed variable)
                      8:  * Description: Returns a string representation of variable (which can later be unserialized) 
                      9:  * Source code: ext/standard/var.c
                     10:  * Alias to functions: 
                     11:  */
                     12: /* Prototype  : proto mixed unserialize(string variable_representation)
                     13:  * Description: Takes a string representation of variable and recreates it 
                     14:  * Source code: ext/standard/var.c
                     15:  * Alias to functions: 
                     16:  */
                     17: 
                     18: echo "\n--- Testing Abstract Class ---\n";
                     19: // abstract class
                     20: abstract class Name 
                     21: {
                     22:   public function Name() {
                     23:     $this->a = 10;
                     24:     $this->b = 12.222;
                     25:     $this->c = "string";
                     26:   }
                     27:   abstract protected function getClassName();
                     28:   public function printClassName () {
                     29:     return $this->getClassName();
                     30:   } 
                     31: }
                     32: // implement abstract class
                     33: class extendName extends Name 
                     34: {
                     35:   var $a, $b, $c;
                     36: 
                     37:   protected function getClassName() {
                     38:     return "extendName";
                     39:   }
                     40: }
                     41: 
                     42: $obj_extendName = new extendName();
                     43: $serialize_data = serialize($obj_extendName);
                     44: var_dump( $serialize_data );
                     45: $unserialize_data = unserialize($serialize_data);
                     46: var_dump( $unserialize_data );
                     47: 
                     48: $serialize_data = serialize($obj_extendName->printClassName());
                     49: var_dump( $serialize_data );
                     50: $unserialize_data = unserialize($serialize_data);
                     51: var_dump( $unserialize_data );
                     52: 
                     53: echo "\nDone";
                     54: ?>
                     55: --EXPECTF--
                     56: --- Testing Abstract Class ---
                     57: string(119) "O:10:"extendName":3:{s:1:"a";i:10;s:1:"b";d:12.2219999999999995310417943983338773250579833984375;s:1:"c";s:6:"string";}"
                     58: object(extendName)#%d (3) {
                     59:   ["a"]=>
                     60:   int(10)
                     61:   ["b"]=>
                     62:   float(12.222)
                     63:   ["c"]=>
                     64:   string(6) "string"
                     65: }
                     66: string(18) "s:10:"extendName";"
                     67: string(10) "extendName"
                     68: 
                     69: Done

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