1--TEST--
2CSS Selectors - Attribute
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8require __DIR__ . '/test_utils.inc';
9
10$dom = DOM\XMLDocument::createFromString(<<<XML
11<container>
12    <a title="http://example.com" lang="en-us"/>
13    <a title="http://example.be"/>
14    <a title="ftp://example.be" lang="nl-be" tokens="abc def ghi"/>
15    <a title="ftp://example.nl" lang="nl-be"/>
16</container>
17XML);
18
19echo "=== Case sensitive ===\n";
20
21test_helper($dom, 'a[title]');
22test_helper($dom, 'a[title="http://example.com"]');
23test_helper($dom, 'a[title="http://example."]');
24test_helper($dom, 'a[title*="example"]');
25test_helper($dom, 'a[title*=""]');
26test_helper($dom, 'a[title^="HTTP"]');
27test_helper($dom, 'a[title^="http"]');
28test_helper($dom, 'a[title^="http"][title$=".be"]');
29test_helper($dom, 'a[title$=".com"]');
30test_helper($dom, 'a[title$=".foo"]');
31test_helper($dom, 'a[lang|="nl"]');
32test_helper($dom, 'a[lang|="nl-be"]');
33test_helper($dom, 'a[tokens~="def"]');
34test_helper($dom, 'a[tokens~="de"]');
35test_helper($dom, 'a[tokens~="def ghi"]');
36
37echo "=== Case insensitive ===\n";
38
39test_helper($dom, 'a[title]');
40test_helper($dom, 'a[title="http://example.COM" i]');
41test_helper($dom, 'a[title="http://EXAMPLE." i]');
42test_helper($dom, 'a[title*="ExAmPlE" i]');
43test_helper($dom, 'a[title^="HTTP" i]');
44test_helper($dom, 'a[title^="HTTP" i][title$=".be"]');
45test_helper($dom, 'a[title$=".COM" i]');
46test_helper($dom, 'a[lang|="NL" i]');
47test_helper($dom, 'a[lang|="NL-BE" i]');
48test_helper($dom, 'a[tokens~="DE" i]');
49test_helper($dom, 'a[tokens~="DEF" i]');
50test_helper($dom, 'a[tokens~="DEF GHI" i]');
51
52?>
53--EXPECT--
54=== Case sensitive ===
55--- Selector: a[title] ---
56<a title="http://example.com" lang="en-us"/>
57<a title="http://example.be"/>
58<a title="ftp://example.be" lang="nl-be" tokens="abc def ghi"/>
59<a title="ftp://example.nl" lang="nl-be"/>
60--- Selector: a[title="http://example.com"] ---
61<a title="http://example.com" lang="en-us"/>
62--- Selector: a[title="http://example."] ---
63--- Selector: a[title*="example"] ---
64<a title="http://example.com" lang="en-us"/>
65<a title="http://example.be"/>
66<a title="ftp://example.be" lang="nl-be" tokens="abc def ghi"/>
67<a title="ftp://example.nl" lang="nl-be"/>
68--- Selector: a[title*=""] ---
69--- Selector: a[title^="HTTP"] ---
70--- Selector: a[title^="http"] ---
71<a title="http://example.com" lang="en-us"/>
72<a title="http://example.be"/>
73--- Selector: a[title^="http"][title$=".be"] ---
74<a title="http://example.be"/>
75--- Selector: a[title$=".com"] ---
76<a title="http://example.com" lang="en-us"/>
77--- Selector: a[title$=".foo"] ---
78--- Selector: a[lang|="nl"] ---
79<a title="ftp://example.be" lang="nl-be" tokens="abc def ghi"/>
80<a title="ftp://example.nl" lang="nl-be"/>
81--- Selector: a[lang|="nl-be"] ---
82<a title="ftp://example.be" lang="nl-be" tokens="abc def ghi"/>
83<a title="ftp://example.nl" lang="nl-be"/>
84--- Selector: a[tokens~="def"] ---
85<a title="ftp://example.be" lang="nl-be" tokens="abc def ghi"/>
86--- Selector: a[tokens~="de"] ---
87--- Selector: a[tokens~="def ghi"] ---
88=== Case insensitive ===
89--- Selector: a[title] ---
90<a title="http://example.com" lang="en-us"/>
91<a title="http://example.be"/>
92<a title="ftp://example.be" lang="nl-be" tokens="abc def ghi"/>
93<a title="ftp://example.nl" lang="nl-be"/>
94--- Selector: a[title="http://example.COM" i] ---
95<a title="http://example.com" lang="en-us"/>
96--- Selector: a[title="http://EXAMPLE." i] ---
97--- Selector: a[title*="ExAmPlE" i] ---
98<a title="http://example.com" lang="en-us"/>
99<a title="http://example.be"/>
100<a title="ftp://example.be" lang="nl-be" tokens="abc def ghi"/>
101<a title="ftp://example.nl" lang="nl-be"/>
102--- Selector: a[title^="HTTP" i] ---
103<a title="http://example.com" lang="en-us"/>
104<a title="http://example.be"/>
105--- Selector: a[title^="HTTP" i][title$=".be"] ---
106<a title="http://example.be"/>
107--- Selector: a[title$=".COM" i] ---
108<a title="http://example.com" lang="en-us"/>
109--- Selector: a[lang|="NL" i] ---
110<a title="ftp://example.be" lang="nl-be" tokens="abc def ghi"/>
111<a title="ftp://example.nl" lang="nl-be"/>
112--- Selector: a[lang|="NL-BE" i] ---
113<a title="ftp://example.be" lang="nl-be" tokens="abc def ghi"/>
114<a title="ftp://example.nl" lang="nl-be"/>
115--- Selector: a[tokens~="DE" i] ---
116--- Selector: a[tokens~="DEF" i] ---
117<a title="ftp://example.be" lang="nl-be" tokens="abc def ghi"/>
118--- Selector: a[tokens~="DEF GHI" i] ---
119