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