Annotation of embedaddon/php/ext/dom/tests/dom_set_attr_node.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Test: setAttributeNode()
                      3: --SKIPIF--
                      4: <?php require_once('skipif.inc'); ?>
1.1.1.2 ! misho       5: --INI--
        !             6: error_reporting = E_ALL & ~E_WARNING
1.1       misho       7: --FILE--
                      8: <?php
                      9: 
                     10: $xml = <<<HERE
                     11: <?xml version="1.0" ?>
                     12: <root a="b" />
                     13: HERE;
                     14: 
                     15: $xml2 = <<<HERE
                     16: <?xml version="1.0" ?>
                     17: <doc2 />
                     18: HERE;
                     19: 
                     20: $dom = new DOMDocument();
                     21: $dom->loadXML($xml);
                     22: $root = $dom->documentElement;
                     23: $attr = $root->getAttributeNode('a');
                     24: 
                     25: $dom2 = new DOMDocument();
                     26: $dom2->loadXML($xml2);
                     27: $root2 = $dom2->documentElement;
                     28: try {
1.1.1.2 ! misho      29:        $root2->setAttributeNode($attr);
1.1       misho      30: } catch (domexception $e) {
1.1.1.2 ! misho      31: ob_start();
        !            32:        var_dump($e);
        !            33:        $contents = ob_get_contents();
        !            34:        ob_end_clean();
        !            35:        echo preg_replace('/object\(DOMAttr\).+\{.*?\}/s', 'DOMAttr', $contents);
1.1       misho      36: } 
                     37: 
                     38: ?>
                     39: --EXPECTF--
                     40: object(DOMException)#%d (7) {
                     41:   ["message":protected]=>
                     42:   string(20) "Wrong Document Error"
                     43:   ["string":"Exception":private]=>
                     44:   string(0) ""
                     45:   ["file":protected]=>
                     46:   string(%d) "%sdom_set_attr_node.php"
                     47:   ["line":protected]=>
                     48:   int(%d)
                     49:   ["trace":"Exception":private]=>
                     50:   array(1) {
                     51:     [0]=>
                     52:     array(6) {
                     53:       ["file"]=>
                     54:       string(%d) "%sdom_set_attr_node.php"
                     55:       ["line"]=>
                     56:       int(%d)
                     57:       ["function"]=>
                     58:       string(16) "setAttributeNode"
                     59:       ["class"]=>
                     60:       string(10) "DOMElement"
                     61:       ["type"]=>
                     62:       string(2) "->"
                     63:       ["args"]=>
                     64:       array(1) {
                     65:         [0]=>
1.1.1.2 ! misho      66:         DOMAttr
1.1       misho      67:       }
                     68:     }
                     69:   }
                     70:   ["previous":"Exception":private]=>
                     71:   NULL
                     72:   ["code"]=>
                     73:   int(4)
                     74: }

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