Skip to content

Commit 0c7fcf4

Browse files
committed
Add interaction test with getElementsByTagName(NS)
1 parent 45addac commit 0c7fcf4

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
--TEST--
2+
Test DOM\HTMLDocument::getElementsByTagName(NS)
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
$dom = DOM\HTMLDocument::createFromString(<<<HTML
9+
<!DOCTYPE html>
10+
<html>
11+
<head>
12+
<title>Test</title>
13+
</head>
14+
<body>
15+
<h1>Test</h1>
16+
<p>Test</p>
17+
<svg width="100" height="100">
18+
<circle cx="0" cy="0" r="10"/>
19+
</svg>
20+
<math>
21+
<mtable id="table"></mtable>
22+
</math>
23+
</body>
24+
</html>
25+
HTML);
26+
27+
echo "--- getElementsByTagName ---\n";
28+
29+
var_dump($dom->getElementsByTagName("p")[0]?->nodeName);
30+
var_dump($dom->getElementsByTagName("math")[0]?->nodeName);
31+
var_dump($dom->getElementsByTagName("mtable")[0]?->nodeName);
32+
var_dump($dom->getElementsByTagName("svg")[0]?->nodeName);
33+
var_dump($dom->getElementsByTagName("circle")[0]?->nodeName);
34+
35+
echo "--- getElementsByTagNameNS (*) ---\n";
36+
37+
var_dump($dom->getElementsByTagNameNS("*", "p")[0]?->nodeName);
38+
var_dump($dom->getElementsByTagNameNS("*", "math")[0]?->nodeName);
39+
var_dump($dom->getElementsByTagNameNS("*", "mtable")[0]?->nodeName);
40+
var_dump($dom->getElementsByTagNameNS("*", "svg")[0]?->nodeName);
41+
var_dump($dom->getElementsByTagNameNS("*", "circle")[0]?->nodeName);
42+
43+
echo "--- getElementsByTagNameNS (xhtml) ---\n";
44+
45+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p")[0]?->nodeName);
46+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "math")[0]?->nodeName);
47+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "mtable")[0]?->nodeName);
48+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "svg")[0]?->nodeName);
49+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "circle")[0]?->nodeName);
50+
51+
echo "--- getElementsByTagNameNS (svg) ---\n";
52+
53+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/2000/svg", "p")[0]?->nodeName);
54+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/2000/svg", "math")[0]?->nodeName);
55+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/2000/svg", "mtable")[0]?->nodeName);
56+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/2000/svg", "svg")[0]?->nodeName);
57+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/2000/svg", "circle")[0]?->nodeName);
58+
59+
echo "--- getElementsByTagNameNS (math) ---\n";
60+
61+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/1998/Math/MathML", "p")[0]?->nodeName);
62+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/1998/Math/MathML", "math")[0]?->nodeName);
63+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/1998/Math/MathML", "mtable")[0]?->nodeName);
64+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/1998/Math/MathML", "svg")[0]?->nodeName);
65+
var_dump($dom->getElementsByTagNameNS("http://www.w3.org/1998/Math/MathML", "circle")[0]?->nodeName);
66+
67+
?>
68+
--EXPECT--
69+
--- getElementsByTagName ---
70+
string(1) "p"
71+
string(4) "math"
72+
string(6) "mtable"
73+
string(3) "svg"
74+
string(6) "circle"
75+
--- getElementsByTagNameNS (*) ---
76+
string(1) "p"
77+
string(4) "math"
78+
string(6) "mtable"
79+
string(3) "svg"
80+
string(6) "circle"
81+
--- getElementsByTagNameNS (xhtml) ---
82+
string(1) "p"
83+
NULL
84+
NULL
85+
NULL
86+
NULL
87+
--- getElementsByTagNameNS (svg) ---
88+
NULL
89+
NULL
90+
NULL
91+
string(3) "svg"
92+
string(6) "circle"
93+
--- getElementsByTagNameNS (math) ---
94+
NULL
95+
string(4) "math"
96+
string(6) "mtable"
97+
NULL
98+
NULL

0 commit comments

Comments
 (0)