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

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');
                     21: var_dump($root);
                     22: print $root->testit()."\n";
                     23: $attr = $root->getAttributeNode('a');
                     24: var_dump($attr);
                     25: print $attr->testit()."\n";
                     26: unset($attr);
                     27: $doc->registerNodeClass('DOMAttr', NULL);
                     28: $attr = $root->getAttributeNode('a');
                     29: var_dump($attr);
                     30: print $attr->testit()."\n";
                     31: ?>
                     32: --EXPECTF--
                     33: 
                     34: object(myElement)#%d (0) {
                     35: }
                     36: HELLO Element
                     37: object(myAttribute)#%d (0) {
                     38: }
                     39: HELLO Attribute
                     40: object(DOMAttr)#%d (0) {
                     41: }
                     42: 
                     43: Fatal error: Call to undefined method DOMAttr::testit() in %s on line 25

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