Annotation of embedaddon/php/ext/dom/tests/DOMNode_replaceChild_basic.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Replacing a child node
        !             3: --SKIPIF--
        !             4: <?php require_once('skipif.inc'); ?>
        !             5: --CREDITS--
        !             6: Matt Raines <matt@raines.me.uk>
        !             7: #London TestFest 2008
        !             8: --FILE--
        !             9: <?php
        !            10: $document = new DOMDocument();
        !            11: $document->loadXML('<?xml version="1.0" encoding="utf-8"?>
        !            12: <root><foo><bar/><baz/></foo><spam><eggs/><eggs/></spam></root>');
        !            13: 
        !            14: // Replaces the child node oldChild with newChild in the list of children, and
        !            15: // returns the oldChild node.
        !            16: $parent = $document->getElementsByTagName('foo')->item(0);
        !            17: $new_child = $document->createElement('qux');
        !            18: $old_child = $parent->replaceChild($new_child, $parent->firstChild);
        !            19: echo "New child replaces old child:\n" . $document->saveXML();
        !            20: echo "Old child is returned:\n" . $old_child->tagName . "\n";
        !            21: 
        !            22: // If the newChild is already in the tree, it is first removed.
        !            23: $parent = $document->getElementsByTagName('spam')->item(0);
        !            24: $parent->replaceChild($new_child, $parent->firstChild);
        !            25: echo "Existing child is removed from tree:\n" . $document->saveXML();
        !            26: 
        !            27: // Children are inserted in the correct order.
        !            28: $new_child = $document->getElementsByTagName('spam')->item(0);
        !            29: $parent = $document->getElementsByTagName('foo')->item(0);
        !            30: $parent->replaceChild($new_child, $parent->firstChild);
        !            31: echo "Children are inserted in order:\n" . $document->saveXML();
        !            32: ?>
        !            33: --EXPECT--
        !            34: New child replaces old child:
        !            35: <?xml version="1.0" encoding="utf-8"?>
        !            36: <root><foo><qux/><baz/></foo><spam><eggs/><eggs/></spam></root>
        !            37: Old child is returned:
        !            38: bar
        !            39: Existing child is removed from tree:
        !            40: <?xml version="1.0" encoding="utf-8"?>
        !            41: <root><foo><baz/></foo><spam><qux/><eggs/></spam></root>
        !            42: Children are inserted in order:
        !            43: <?xml version="1.0" encoding="utf-8"?>
        !            44: <root><foo><spam><qux/><eggs/></spam></foo></root>

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