Annotation of embedaddon/php/ext/spl/tests/arrayObject___construct_basic5.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: SPL: ArrayObject::__construct basic usage with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS. Currently fails on php.net due to bug 45622.
                      3: --FILE--
                      4: <?php
                      5: class C {
                      6:        public $prop = 'C::prop.orig';
                      7: }
                      8: 
                      9: class MyArrayObject extends ArrayObject {
                     10:        public $prop = 'MyArrayObject::prop.orig';
                     11: }      
                     12: 
                     13: echo "\n--> Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS:\n";
                     14: $c = new C;
                     15: $ao = new ArrayObject($c, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS);
                     16: testAccess($c, $ao);
                     17: 
                     18: echo "\n--> Access prop on instance of MyArrayObject with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS:\n";
                     19: $c = new C;
                     20: $ao = new MyArrayObject($c, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS);
                     21: testAccess($c, $ao);
                     22: 
                     23: function testAccess($c, $ao) {
                     24:        echo "  - Iteration:\n";
                     25:        foreach ($ao as $key=>$value) {
                     26:                echo "      $key=>$value\n";
                     27:        }
                     28: 
                     29:        echo "  - Read:\n";
                     30:        @var_dump($ao->prop, $ao['prop']);
                     31:        
                     32:        echo "  - Write:\n";
                     33:        $ao->prop = 'changed1';
                     34:        $ao['prop'] = 'changed2';
                     35:        var_dump($ao->prop, $ao['prop']);
                     36:        
                     37:        echo "  - Isset:\n";
                     38:        var_dump(isset($ao->prop), isset($ao['prop']));
                     39:        
                     40:        echo "  - Unset:\n";
                     41:        unset($ao->prop);
                     42:        unset($ao['prop']);
                     43:        var_dump($ao->prop, $ao['prop']);
                     44:        
                     45:        echo "  - After:\n";
                     46:        var_dump($ao, $c);
                     47: }
                     48: ?>
                     49: --EXPECTF--
                     50: --> Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS:
                     51:   - Iteration:
                     52:       prop=>C::prop.orig
                     53:   - Read:
                     54: string(12) "C::prop.orig"
                     55: string(12) "C::prop.orig"
                     56:   - Write:
                     57: string(8) "changed2"
                     58: string(8) "changed2"
                     59:   - Isset:
                     60: bool(true)
                     61: bool(true)
                     62:   - Unset:
                     63: 
1.1.1.2 ! misho      64: Notice: Undefined index: prop in %s on line 39
1.1       misho      65: 
1.1.1.2 ! misho      66: Notice: Undefined index: prop in %s on line 40
1.1       misho      67: 
1.1.1.2 ! misho      68: Notice: Undefined index: prop in %s on line 40
1.1       misho      69: NULL
                     70: NULL
                     71:   - After:
                     72: object(ArrayObject)#2 (1) {
                     73:   ["storage":"ArrayObject":private]=>
                     74:   object(C)#1 (0) {
                     75:   }
                     76: }
                     77: object(C)#1 (0) {
                     78: }
                     79: 
                     80: --> Access prop on instance of MyArrayObject with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS:
                     81:   - Iteration:
                     82:       prop=>C::prop.orig
                     83:   - Read:
                     84: string(24) "MyArrayObject::prop.orig"
                     85: string(12) "C::prop.orig"
                     86:   - Write:
                     87: string(8) "changed1"
                     88: string(8) "changed2"
                     89:   - Isset:
                     90: bool(true)
                     91: bool(true)
                     92:   - Unset:
                     93: 
1.1.1.2 ! misho      94: Notice: Undefined index: prop in %s on line 40
1.1       misho      95: 
1.1.1.2 ! misho      96: Notice: Undefined index: prop in %s on line 40
1.1       misho      97: NULL
                     98: NULL
                     99:   - After:
                    100: object(MyArrayObject)#3 (1) {
                    101:   ["storage":"ArrayObject":private]=>
                    102:   object(C)#4 (0) {
                    103:   }
                    104: }
                    105: object(C)#4 (0) {
                    106: }

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