1--TEST--
2Tests with direction construction
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7function node_alike_test($test) {
8    try {
9        var_dump($test->parentNode);
10        var_dump($test->nodeValue);
11    } catch (Throwable $e) {
12        echo $e->getMessage(), "\n";
13    }
14    try {
15        var_dump($test->appendChild($test));
16    } catch (Throwable $e) {
17        echo $e->getMessage(), "\n";
18    }
19}
20
21echo "-- Test DOMCharacterData --\n";
22$test = new DOMCharacterData("test");
23try {
24    var_dump($test->textContent);
25} catch (Throwable $e) {
26    echo $e->getMessage(), "\n";
27}
28try {
29    var_dump($test->appendData('test'));
30} catch (Throwable $e) {
31    echo $e->getMessage(), "\n";
32}
33
34echo "-- Test DOMCdataSection --\n";
35$test = new DOMCdataSection("test");
36var_dump($test->textContent);
37var_dump($test->appendData('test'));
38
39echo "-- Test DOMText --\n";
40$test = new DOMText("test");
41try {
42    var_dump($test->wholeText);
43    var_dump($test->parentNode);
44} catch (Throwable $e) {
45    echo $e->getMessage(), "\n";
46}
47try {
48    var_dump($test->isWhitespaceInElementContent());
49} catch (Throwable $e) {
50    echo $e->getMessage(), "\n";
51}
52
53echo "-- Test DOMComment --\n";
54$test = new DOMComment("my comment");
55var_dump($test->textContent);
56var_dump($test->parentNode);
57var_dump($test->getLineNo());
58
59echo "-- Test DOMElement --\n";
60$test = new DOMElement("qualifiedName", "test");
61var_dump($test->textContent);
62var_dump($test->parentNode);
63try {
64    var_dump($test->appendChild($test));
65} catch (Throwable $e) {
66    echo $e->getMessage(), "\n";
67}
68
69echo "-- Test DOMNode --\n";
70node_alike_test(new DOMNode());
71
72echo "-- Test DOMNotation --\n";
73node_alike_test(new DOMNotation());
74
75echo "-- Test DOMProcessingInstruction --\n";
76node_alike_test(new DOMProcessingInstruction("name", "value"));
77
78echo "-- Test DOMEntity --\n";
79$test = new DOMEntity();
80try {
81    var_dump($test->nodeValue);
82    var_dump($test->parentNode);
83} catch (Throwable $e) {
84    echo $e->getMessage(), "\n";
85}
86try {
87    var_dump($test->appendChild($test));
88} catch (Throwable $e) {
89    echo $e->getMessage(), "\n";
90}
91
92echo "-- Test DOMAttr --\n";
93$test = new DOMAttr("attr", "value");
94var_dump($test->nodeValue);
95var_dump($test->parentNode);
96try {
97    var_dump($test->appendChild($test));
98} catch (Throwable $e) {
99    echo $e->getMessage(), "\n";
100}
101?>
102--EXPECT--
103-- Test DOMCharacterData --
104Invalid State Error
105Couldn't fetch DOMCharacterData
106-- Test DOMCdataSection --
107string(4) "test"
108bool(true)
109-- Test DOMText --
110string(4) "test"
111NULL
112bool(false)
113-- Test DOMComment --
114string(10) "my comment"
115NULL
116int(0)
117-- Test DOMElement --
118string(4) "test"
119NULL
120No Modification Allowed Error
121-- Test DOMNode --
122Invalid State Error
123Couldn't fetch DOMNode
124-- Test DOMNotation --
125Invalid State Error
126Couldn't fetch DOMNotation
127-- Test DOMProcessingInstruction --
128NULL
129string(5) "value"
130bool(false)
131-- Test DOMEntity --
132Invalid State Error
133Couldn't fetch DOMEntity
134-- Test DOMAttr --
135string(5) "value"
136NULL
137No Modification Allowed Error
138