Annotation of embedaddon/php/tests/classes/ctor_dtor_inheritance.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: ZE2 A derived class can use the inherited constructor/destructor
        !             3: --SKIPIF--
        !             4: <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
        !             5: --FILE--
        !             6: <?php
        !             7: 
        !             8: // This test checks for:
        !             9: // - inherited constructors/destructors are not called automatically
        !            10: // - base classes know about derived properties in constructor/destructor
        !            11: // - base class constructors/destructors know the instanciated class name
        !            12: 
        !            13: class base {
        !            14:        public $name;
        !            15: 
        !            16:        function __construct() {
        !            17:                echo __CLASS__ . "::" . __FUNCTION__ . "\n";
        !            18:                $this->name = 'base';
        !            19:                print_r($this);
        !            20:        }
        !            21:        
        !            22:        function __destruct() {
        !            23:                echo __CLASS__ . "::" . __FUNCTION__ . "\n";
        !            24:                print_r($this);
        !            25:        }
        !            26: }
        !            27: 
        !            28: class derived extends base {
        !            29:        public $other;
        !            30: 
        !            31:        function __construct() {
        !            32:                $this->name = 'init';
        !            33:                $this->other = 'other';
        !            34:                print_r($this);
        !            35:                parent::__construct();
        !            36:                echo __CLASS__ . "::" . __FUNCTION__ . "\n";
        !            37:                $this->name = 'derived';
        !            38:                print_r($this);
        !            39:        }
        !            40: 
        !            41:        function __destruct() {
        !            42:                parent::__destruct();
        !            43:                echo __CLASS__ . "::" . __FUNCTION__ . "\n";
        !            44:                print_r($this);
        !            45:        }
        !            46: }
        !            47: 
        !            48: echo "Testing class base\n";
        !            49: $t = new base();
        !            50: unset($t);
        !            51: echo "Testing class derived\n";
        !            52: $t = new derived();
        !            53: unset($t);
        !            54: 
        !            55: echo "Done\n";
        !            56: ?>
        !            57: --EXPECTF--
        !            58: Testing class base
        !            59: base::__construct
        !            60: base Object
        !            61: (
        !            62:     [name] => base
        !            63: )
        !            64: base::__destruct
        !            65: base Object
        !            66: (
        !            67:     [name] => base
        !            68: )
        !            69: Testing class derived
        !            70: derived Object
        !            71: (
        !            72:     [other] => other
        !            73:     [name] => init
        !            74: )
        !            75: base::__construct
        !            76: derived Object
        !            77: (
        !            78:     [other] => other
        !            79:     [name] => base
        !            80: )
        !            81: derived::__construct
        !            82: derived Object
        !            83: (
        !            84:     [other] => other
        !            85:     [name] => derived
        !            86: )
        !            87: base::__destruct
        !            88: derived Object
        !            89: (
        !            90:     [other] => other
        !            91:     [name] => derived
        !            92: )
        !            93: derived::__destruct
        !            94: derived Object
        !            95: (
        !            96:     [other] => other
        !            97:     [name] => derived
        !            98: )
        !            99: Done

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