summaryrefslogtreecommitdiff
path: root/ext/dom/tests/regsiter_node_class.phpt
blob: 5444cc4b9ea8275213b13f826e87dad3b5e34827 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--TEST--
Test: registerNodeClass()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
class myAttribute extends DOMAttr {
   function testit() { return "HELLO Attribute"; }
}

class myElement extends DOMElement {
   function testit() { return "HELLO Element"; }
}

$doc = new DOMDocument();
$doc->registerNodeClass('DOMAttr', 'myAttribute');
$doc->registerNodeClass('DOMElement', 'myElement');
$doc->appendChild(new DOMElement('root'));
$root = $doc->documentElement;
$root->setAttribute('a', 'a1');
var_dump($root);
print $root->testit()."\n";
$attr = $root->getAttributeNode('a');
var_dump($attr);
print $attr->testit()."\n";
unset($attr);
$doc->registerNodeClass('DOMAttr', NULL);
$attr = $root->getAttributeNode('a');
var_dump($attr);
print $attr->testit()."\n";
?>
--EXPECTF--

object(myElement)#%d (0) {
}
HELLO Element
object(myAttribute)#%d (0) {
}
HELLO Attribute
object(DOMAttr)#%d (0) {
}

Fatal error: Call to undefined method DOMAttr::testit() in %s on line 25