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

1.1     ! misho       1: --TEST--
        !             2: DOMNode::normalize()
        !             3: --SKIPIF--
        !             4: <?php
        !             5: include('skipif.inc');
        !             6: ?>
        !             7: --FILE--
        !             8: <?php
        !             9: 
        !            10: /* Create an XML document
        !            11:  * with structure
        !            12:  * <book>
        !            13:  *  <author></author>
        !            14:  *  <title>This is the title</title>
        !            15:  * </book>
        !            16:  * Calculate the number of title text nodes (1).
        !            17:  * Add another text node to title. Calculate the number of title text nodes (2).
        !            18:  * Normalize author. Calculate the number of title text nodes (2).
        !            19:  * Normalize title. Calculate the number of title text nodes (1).
        !            20: */
        !            21: 
        !            22: $doc = new DOMDocument();
        !            23: 
        !            24: $root = $doc->createElement('book');
        !            25: $doc->appendChild($root);
        !            26: 
        !            27: $title = $doc->createElement('title');
        !            28: $root->appendChild($title);
        !            29: 
        !            30: $author = $doc->createElement('author');
        !            31: $root->appendChild($author);
        !            32: 
        !            33: $text = $doc->createTextNode('This is the first title');
        !            34: $title->appendChild($text);
        !            35: 
        !            36: echo "Number of child nodes of title = ";
        !            37: var_dump($title->childNodes->length);
        !            38: 
        !            39: // add a second text node to title
        !            40: $text = $doc->createTextNode('This is the second title');
        !            41: $title->appendChild($text);
        !            42: 
        !            43: echo "Number of child nodes of title after adding second title = ";
        !            44: var_dump($title->childNodes->length);
        !            45: 
        !            46: // should do nothing
        !            47: $author->normalize();
        !            48: 
        !            49: echo "Number of child nodes of title after normalizing author = ";
        !            50: var_dump($title->childNodes->length);
        !            51: 
        !            52: 
        !            53: // should concatenate first and second title text nodes
        !            54: $title->normalize();
        !            55: 
        !            56: echo "Number of child nodes of title after normalizing title = ";
        !            57: var_dump($title->childNodes->length);
        !            58: 
        !            59: ?>
        !            60: --EXPECTF--
        !            61: Number of child nodes of title = int(1)
        !            62: Number of child nodes of title after adding second title = int(2)
        !            63: Number of child nodes of title after normalizing author = int(2)
        !            64: Number of child nodes of title after normalizing title = int(1)

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