Skip to content

Commit 0b0a5bf

Browse files
committed
Test namespaces
1 parent 5a7cebc commit 0b0a5bf

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
--TEST--
2+
CSS Selectors - Namespaces
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
require __DIR__ . '/test_utils.inc';
9+
10+
$dom = DOM\XMLDocument::createFromString(<<<XML
11+
<root>
12+
<container align="left"/>
13+
<only>
14+
<a xmlns="urn:a"/>
15+
<a xmlns="urn:a"/>
16+
<a xmlns="urn:b"/>
17+
<a xmlns=""/>
18+
<a/>
19+
</only>
20+
</root>
21+
XML);
22+
23+
$container = $dom->documentElement->firstElementChild;
24+
$container->setAttribute("foo:bar", "baz");
25+
$container->setAttributeNS("urn:a", "a:bar", "baz");
26+
27+
test_helper($dom, 'container[align]');
28+
test_helper($dom, 'container[foo\\:bar]');
29+
test_helper($dom, 'container[a\\:bar]');
30+
test_helper($dom, 'container[bar]');
31+
32+
test_helper($dom, 'a:first-of-type');
33+
test_helper($dom, 'a:last-of-type');
34+
35+
test_failure($dom, 'container[* | bar]');
36+
37+
?>
38+
--EXPECT--
39+
--- Selector: container[align] ---
40+
<container align="left" foo:bar="baz" xmlns:a="urn:a" a:bar="baz"/>
41+
--- Selector: container[foo\:bar] ---
42+
<container align="left" foo:bar="baz" xmlns:a="urn:a" a:bar="baz"/>
43+
--- Selector: container[a\:bar] ---
44+
--- Selector: container[bar] ---
45+
--- Selector: a:first-of-type ---
46+
<a xmlns="urn:a"/>
47+
<a xmlns="urn:b"/>
48+
<a xmlns=""/>
49+
--- Selector: a:last-of-type ---
50+
<a xmlns="urn:a"/>
51+
<a xmlns="urn:b"/>
52+
<a/>
53+
--- Selector: container[* | bar] ---
54+
Code 12 Invalid selector (Selectors. Unexpected token: *)

0 commit comments

Comments
 (0)