1--TEST--
2CSS Selectors - Namespaces
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8require __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>
21XML);
22
23$container = $dom->documentElement->firstElementChild;
24$container->setAttribute("foo:bar", "baz");
25$container->setAttributeNS("urn:a", "a:bar", "baz");
26
27test_helper($dom, 'container[align]');
28test_helper($dom, 'container[foo\\:bar]');
29test_helper($dom, 'container[a\\:bar]');
30test_helper($dom, 'container[bar]');
31
32test_helper($dom, 'a:first-of-type');
33test_helper($dom, 'a:last-of-type');
34
35test_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] ---
54Code 12 Invalid selector (Selectors. Unexpected token: *)
55