1--TEST--
2DOM\Element::getDescendantNamespaces()
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8function dump($dom, $name) {
9    echo "\n=== $name ===\n";
10    $list = $dom->getElementsByTagName($name)[0]->getDescendantNamespaces();
11    foreach ($list as $entry) {
12        echo "prefix: ";
13        var_dump($entry->prefix);
14        echo "namespaceURI: ";
15        var_dump($entry->namespaceURI);
16        echo "element->nodeName: ";
17        var_dump($entry->element->nodeName);
18        echo "---\n";
19    }
20}
21
22$dom = DOM\XMLDocument::createFromString(<<<XML
23<root xmlns="urn:a">
24    <child xmlns="">
25        <c:child xmlns:c="urn:c"/>
26    </child>
27    <b:sibling xmlns:b="urn:b" xmlns:d="urn:d" d:foo="bar">
28        <d:child xmlns:d="urn:d2"/>
29    </b:sibling>
30</root>
31XML);
32
33dump($dom, 'c:child');
34dump($dom, 'child');
35dump($dom, 'b:sibling');
36dump($dom, 'd:child');
37dump($dom, 'root');
38
39?>
40--EXPECT--
41=== c:child ===
42prefix: string(1) "c"
43namespaceURI: string(5) "urn:c"
44element->nodeName: string(7) "c:child"
45---
46
47=== child ===
48prefix: string(1) "c"
49namespaceURI: string(5) "urn:c"
50element->nodeName: string(7) "c:child"
51---
52
53=== b:sibling ===
54prefix: NULL
55namespaceURI: string(5) "urn:a"
56element->nodeName: string(9) "b:sibling"
57---
58prefix: string(1) "b"
59namespaceURI: string(5) "urn:b"
60element->nodeName: string(9) "b:sibling"
61---
62prefix: string(1) "d"
63namespaceURI: string(5) "urn:d"
64element->nodeName: string(9) "b:sibling"
65---
66prefix: NULL
67namespaceURI: string(5) "urn:a"
68element->nodeName: string(7) "d:child"
69---
70prefix: string(1) "b"
71namespaceURI: string(5) "urn:b"
72element->nodeName: string(7) "d:child"
73---
74prefix: string(1) "d"
75namespaceURI: string(6) "urn:d2"
76element->nodeName: string(7) "d:child"
77---
78
79=== d:child ===
80prefix: NULL
81namespaceURI: string(5) "urn:a"
82element->nodeName: string(7) "d:child"
83---
84prefix: string(1) "b"
85namespaceURI: string(5) "urn:b"
86element->nodeName: string(7) "d:child"
87---
88prefix: string(1) "d"
89namespaceURI: string(6) "urn:d2"
90element->nodeName: string(7) "d:child"
91---
92
93=== root ===
94prefix: NULL
95namespaceURI: string(5) "urn:a"
96element->nodeName: string(4) "root"
97---
98prefix: string(1) "c"
99namespaceURI: string(5) "urn:c"
100element->nodeName: string(7) "c:child"
101---
102prefix: NULL
103namespaceURI: string(5) "urn:a"
104element->nodeName: string(9) "b:sibling"
105---
106prefix: string(1) "b"
107namespaceURI: string(5) "urn:b"
108element->nodeName: string(9) "b:sibling"
109---
110prefix: string(1) "d"
111namespaceURI: string(5) "urn:d"
112element->nodeName: string(9) "b:sibling"
113---
114prefix: NULL
115namespaceURI: string(5) "urn:a"
116element->nodeName: string(7) "d:child"
117---
118prefix: string(1) "b"
119namespaceURI: string(5) "urn:b"
120element->nodeName: string(7) "d:child"
121---
122prefix: string(1) "d"
123namespaceURI: string(6) "urn:d2"
124element->nodeName: string(7) "d:child"
125---
126