Skip to content

Commit 5a7cebc

Browse files
committed
Test attribute
1 parent 5753dce commit 5a7cebc

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
--TEST--
2+
CSS Selectors - Attribute
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
require __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>
17+
XML);
18+
19+
echo "=== Case sensitive ===\n";
20+
21+
test_helper($dom, 'a[title]');
22+
test_helper($dom, 'a[title="http://example.com"]');
23+
test_helper($dom, 'a[title="http://example."]');
24+
test_helper($dom, 'a[title*="example"]');
25+
test_helper($dom, 'a[title*=""]');
26+
test_helper($dom, 'a[title^="HTTP"]');
27+
test_helper($dom, 'a[title^="http"]');
28+
test_helper($dom, 'a[title^="http"][title$=".be"]');
29+
test_helper($dom, 'a[title$=".com"]');
30+
test_helper($dom, 'a[title$=".foo"]');
31+
test_helper($dom, 'a[lang|="nl"]');
32+
test_helper($dom, 'a[lang|="nl-be"]');
33+
test_helper($dom, 'a[tokens~="def"]');
34+
test_helper($dom, 'a[tokens~="de"]');
35+
test_helper($dom, 'a[tokens~="def ghi"]');
36+
37+
echo "=== Case insensitive ===\n";
38+
39+
test_helper($dom, 'a[title]');
40+
test_helper($dom, 'a[title="http://example.COM" i]');
41+
test_helper($dom, 'a[title="http://EXAMPLE." i]');
42+
test_helper($dom, 'a[title*="ExAmPlE" i]');
43+
test_helper($dom, 'a[title^="HTTP" i]');
44+
test_helper($dom, 'a[title^="HTTP" i][title$=".be"]');
45+
test_helper($dom, 'a[title$=".COM" i]');
46+
test_helper($dom, 'a[lang|="NL" i]');
47+
test_helper($dom, 'a[lang|="NL-BE" i]');
48+
test_helper($dom, 'a[tokens~="DE" i]');
49+
test_helper($dom, 'a[tokens~="DEF" i]');
50+
test_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] ---

0 commit comments

Comments
 (0)