1--TEST--
2Document::getElementsByTagNameNS
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8require __DIR__ . '/create_element_util.inc';
9
10$dom = Dom\HTMLDocument::createFromString(<<<HTML
11<!DOCTYPE html>
12<html>
13<head>
14    <title>Test</title>
15</head>
16<body>
17    <p>Hello World</p>
18</body>
19</html>
20HTML);
21
22$body = $dom->getElementsByTagName('body')->item(0);
23$body->appendChild(createElementNS($dom, NULL, "p", "content 1"));
24$body->appendChild(createElementNS($dom, "", "p", "content 2"));
25$body->appendChild(createElementNS($dom, "http://www.w3.org/2000/svg", "svg:svg", "content 3"));
26
27function dump($dom, $uri, $local) {
28    $list = $dom->getElementsByTagNameNS($uri, $local);
29
30    $uri_readable = is_null($uri) ? "NULL" : "\"$uri\"";
31    echo "--- ($uri_readable, \"$local\"): {$list->length} ---\n";
32
33    var_dump($list->length);
34    foreach ($list as $item) {
35        var_dump($item->textContent);
36    }
37}
38
39dump($dom, 'http://www.w3.org/1999/xhtml', 'p');
40dump($dom, '*', 'p');
41dump($dom, '*', '*');
42dump($dom, '', '*');
43dump($dom, NULL, '*');
44dump($dom, '*', 'svg');
45dump($dom, '*', 'svg:svg');
46
47?>
48--EXPECT--
49--- ("http://www.w3.org/1999/xhtml", "p"): 1 ---
50int(1)
51string(11) "Hello World"
52--- ("*", "p"): 3 ---
53int(3)
54string(11) "Hello World"
55string(9) "content 1"
56string(9) "content 2"
57--- ("*", "*"): 8 ---
58int(8)
59string(56) "
60    Test
61
62
63    Hello World
64
65content 1content 2content 3"
66string(10) "
67    Test
68"
69string(4) "Test"
70string(45) "
71    Hello World
72
73content 1content 2content 3"
74string(11) "Hello World"
75string(9) "content 1"
76string(9) "content 2"
77string(9) "content 3"
78--- ("", "*"): 2 ---
79int(2)
80string(9) "content 1"
81string(9) "content 2"
82--- (NULL, "*"): 2 ---
83int(2)
84string(9) "content 1"
85string(9) "content 2"
86--- ("*", "svg"): 1 ---
87int(1)
88string(9) "content 3"
89--- ("*", "svg:svg"): 0 ---
90int(0)
91