Annotation of embedaddon/php/ext/simplexml/tests/033.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: SimpleXML: casting instances
                      3: --SKIPIF--
                      4: <?php if (!extension_loaded("simplexml")) print "skip"; ?>
                      5: --FILE--
                      6: <?php
                      7: 
                      8: $xml =<<<EOF
                      9: <people>
                     10: test
                     11:   <person name="Joe"/>
                     12:   <person name="John">
                     13:     <children>
                     14:       <person name="Joe"/>
                     15:     </children>
                     16:   </person>
                     17:   <person name="Jane"/>
                     18: </people>
                     19: EOF;
                     20: 
                     21: $foo = simplexml_load_string( "<foo />" );
                     22: $people = simplexml_load_string($xml);
                     23: 
                     24: var_dump((bool)$foo);
                     25: var_dump((bool)$people);
                     26: var_dump((int)$foo);
                     27: var_dump((int)$people);
                     28: var_dump((double)$foo);
                     29: var_dump((double)$people);
                     30: var_dump((string)$foo);
                     31: var_dump((string)$people);
                     32: var_dump((array)$foo);
                     33: var_dump((array)$people);
                     34: var_dump((object)$foo);
                     35: var_dump((object)$people);
                     36: 
                     37: ?>
                     38: ===DONE===
                     39: --EXPECTF--
                     40: bool(false)
                     41: bool(true)
                     42: int(0)
                     43: int(0)
                     44: float(0)
                     45: float(0)
                     46: string(0) ""
                     47: string(15) "
                     48: test
                     49:   
                     50:   
                     51:   
                     52: "
                     53: array(0) {
                     54: }
                     55: array(1) {
                     56:   ["person"]=>
                     57:   array(3) {
                     58:     [0]=>
                     59:     object(SimpleXMLElement)#%d (1) {
                     60:       ["@attributes"]=>
                     61:       array(1) {
                     62:         ["name"]=>
                     63:         string(3) "Joe"
                     64:       }
                     65:     }
                     66:     [1]=>
                     67:     object(SimpleXMLElement)#%d (2) {
                     68:       ["@attributes"]=>
                     69:       array(1) {
                     70:         ["name"]=>
                     71:         string(4) "John"
                     72:       }
                     73:       ["children"]=>
                     74:       object(SimpleXMLElement)#%d (1) {
                     75:         ["person"]=>
                     76:         object(SimpleXMLElement)#%d (1) {
                     77:           ["@attributes"]=>
                     78:           array(1) {
                     79:             ["name"]=>
                     80:             string(3) "Joe"
                     81:           }
                     82:         }
                     83:       }
                     84:     }
                     85:     [2]=>
                     86:     object(SimpleXMLElement)#%d (1) {
                     87:       ["@attributes"]=>
                     88:       array(1) {
                     89:         ["name"]=>
                     90:         string(4) "Jane"
                     91:       }
                     92:     }
                     93:   }
                     94: }
                     95: object(SimpleXMLElement)#%d (0) {
                     96: }
                     97: object(SimpleXMLElement)#%d (1) {
                     98:   ["person"]=>
                     99:   array(3) {
                    100:     [0]=>
                    101:     object(SimpleXMLElement)#%d (1) {
                    102:       ["@attributes"]=>
                    103:       array(1) {
                    104:         ["name"]=>
                    105:         string(3) "Joe"
                    106:       }
                    107:     }
                    108:     [1]=>
                    109:     object(SimpleXMLElement)#%d (2) {
                    110:       ["@attributes"]=>
                    111:       array(1) {
                    112:         ["name"]=>
                    113:         string(4) "John"
                    114:       }
                    115:       ["children"]=>
                    116:       object(SimpleXMLElement)#%d (1) {
                    117:         ["person"]=>
                    118:         object(SimpleXMLElement)#%d (1) {
                    119:           ["@attributes"]=>
                    120:           array(1) {
                    121:             ["name"]=>
                    122:             string(3) "Joe"
                    123:           }
                    124:         }
                    125:       }
                    126:     }
                    127:     [2]=>
                    128:     object(SimpleXMLElement)#%d (1) {
                    129:       ["@attributes"]=>
                    130:       array(1) {
                    131:         ["name"]=>
                    132:         string(4) "Jane"
                    133:       }
                    134:     }
                    135:   }
                    136: }
                    137: ===DONE===

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