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

1.1       misho       1: --TEST--
                      2: Test: registerNodeClass()
                      3: --SKIPIF--
                      4: <?php require_once('skipif.inc'); ?>
                      5: --FILE--
                      6: <?php
                      7: class myAttribute extends DOMAttr {
                      8:    function testit() { return "HELLO Attribute"; }
                      9: }
                     10: 
                     11: class myElement extends DOMElement {
                     12:    function testit() { return "HELLO Element"; }
                     13: }
                     14: 
                     15: $doc = new DOMDocument();
                     16: $doc->registerNodeClass('DOMAttr', 'myAttribute');
                     17: $doc->registerNodeClass('DOMElement', 'myElement');
                     18: $doc->appendChild(new DOMElement('root'));
                     19: $root = $doc->documentElement;
                     20: $root->setAttribute('a', 'a1');
1.1.1.2 ! misho      21: echo get_class($root), "\n";
1.1       misho      22: print $root->testit()."\n";
                     23: $attr = $root->getAttributeNode('a');
1.1.1.2 ! misho      24: echo get_class($attr), "\n";
1.1       misho      25: print $attr->testit()."\n";
                     26: unset($attr);
                     27: $doc->registerNodeClass('DOMAttr', NULL);
                     28: $attr = $root->getAttributeNode('a');
1.1.1.2 ! misho      29: echo get_class($attr), "\n";
1.1       misho      30: print $attr->testit()."\n";
                     31: ?>
                     32: --EXPECTF--
                     33: 
1.1.1.2 ! misho      34: myElement
1.1       misho      35: HELLO Element
1.1.1.2 ! misho      36: myAttribute
1.1       misho      37: HELLO Attribute
1.1.1.2 ! misho      38: DOMAttr
1.1       misho      39: 
                     40: Fatal error: Call to undefined method DOMAttr::testit() in %s on line 25

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