1--TEST--
2DOMNode::parentElement and DOMNameSpaceNode::parentElement
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = new DOMDocument();
9$dom->loadXML(<<<XML
10<!DOCTYPE HTML>
11<html>
12    <body/>
13</html>
14XML);
15
16echo "--- body test ---\n";
17
18$body = $dom->documentElement->firstElementChild;
19var_dump($body->parentNode->localName);
20var_dump($body->parentElement->localName);
21
22echo "--- document test ---\n";
23
24var_dump(get_class($dom->documentElement->parentNode));
25var_dump($dom->documentElement->parentElement);
26
27var_dump(get_class($dom->doctype->parentNode));
28var_dump($dom->doctype->parentElement);
29
30echo "--- fragment test ---\n";
31
32$fragment = $dom->createDocumentFragment();
33$p = $fragment->appendChild($dom->createElement('p'));
34
35var_dump(get_class($p->parentNode));
36var_dump($p->parentElement);
37
38$body->appendChild($fragment);
39
40var_dump($p->parentNode->localName);
41var_dump($p->parentElement->localName);
42
43?>
44--EXPECT--
45--- body test ---
46string(4) "html"
47string(4) "html"
48--- document test ---
49string(11) "DOMDocument"
50NULL
51string(11) "DOMDocument"
52NULL
53--- fragment test ---
54string(19) "DOMDocumentFragment"
55NULL
56string(4) "body"
57string(4) "body"
58