Annotation of embedaddon/php/ext/dom/tests/domchardata.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: CharData: DOMCharacterData and related functionality
                      3: --SKIPIF--
                      4: <?php require_once('skipif.inc'); ?>
                      5: --FILE--
                      6: <?php
                      7: require_once("dom_test.inc");
                      8: 
                      9: $dom = new DOMDocument;
                     10: $dom->loadXML($xmlstr);
                     11: if(!$dom) {
                     12:   echo "Error while parsing the document\n";
                     13:   exit;
                     14: }
                     15: 
                     16: $node = $dom->documentElement;
                     17: 
                     18: $charnode = $dom->createElement('charnode');
                     19: $node->appendChild($charnode);
                     20: 
                     21: /* DOMComment */
                     22: $comment = new DOMComment('Testing character data and extending nodes');
                     23: $charnode->appendChild($comment);
                     24: 
                     25: echo "Comment Length: ".$comment->length."\n";
                     26: 
                     27: $comment->data = 'Updated comment';
                     28: echo "New Comment Length: ".$comment->length."\n";
                     29: echo "New Comment Data: ".$comment->data."\n";
                     30: 
                     31: /* DOMCDataSection */
                     32: $cdata = new DOMCDataSection('Chars: <>&"');
                     33: $charnode->appendChild($cdata);
                     34: 
                     35: echo "Substring: ".$cdata->substringData(7, 4)."\n";
                     36: $cdata->replaceData(10, 1, "'");
                     37: echo "New Substring: ".$cdata->substringData(7, 4)."\n";
                     38: 
                     39: /* DOMCharacterData using DOMComment */
                     40: $comment = new DOMComment('instructions');
                     41: echo "Comment Value: ".$comment->data."\n";
                     42: $comment->data = 'some more instructions';
                     43: echo "New Comment Value: ".$comment->data."\n";
                     44: 
                     45: $comment->insertData(10, 'pi ');
                     46: $comment->replaceData(18, 5, 'i');
                     47: $comment->insertData(20, 'g');
                     48: $comment->deleteData(13, 2);
                     49: $comment->deleteData(10, 3);
                     50: $comment->insertData(10, 'comment ');
                     51: echo "Updated Comment Value: ".$comment->data."\n";
                     52: 
                     53: /* DOMText */
                     54: $text = new DOMText('some text characters');
                     55: 
                     56: echo "Whole Text: ".$text->wholeText."\n";
                     57: $text2 = $text->splitText(9);
                     58: 
                     59: echo "Split text: ".$text2->wholeText."\n";
                     60: $text3 = $text2->splitText(1);
                     61: 
                     62: echo "Is Whitespace?: ".($text2->isElementContentWhitespace()?'YES':'NO');
                     63: ?>
                     64: --EXPECT--
                     65: 
                     66: Comment Length: 42
                     67: New Comment Length: 15
                     68: New Comment Data: Updated comment
                     69: Substring: <>&"
                     70: New Substring: <>&'
                     71: Comment Value: instructions
                     72: New Comment Value: some more instructions
                     73: Updated Comment Value: some more comment strings
                     74: Whole Text: some text characters
                     75: Split text:  characters
                     76: Is Whitespace?: YES

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