@@ -8,73 +8,73 @@ use Tester\DomQuery;
88require __DIR__ . '/../bootstrap.php ' ;
99
1010test ('type selectors ' , function () {
11- Assert::same ('.// * ' , DomQuery::css2xpath ('* ' ));
12- Assert::same ('.// foo ' , DomQuery::css2xpath ('foo ' ));
11+ Assert::same ('* ' , DomQuery::css2xpath ('* ' ));
12+ Assert::same ('foo ' , DomQuery::css2xpath ('foo ' ));
1313});
1414
1515
1616test ('#ID ' , function () {
17- Assert::same (".// *[@id='foo'] " , DomQuery::css2xpath ('#foo ' ));
18- Assert::same (".// *[@id='id'] " , DomQuery::css2xpath ('*#id ' ));
17+ Assert::same ("*[@id='foo'] " , DomQuery::css2xpath ('#foo ' ));
18+ Assert::same ("*[@id='id'] " , DomQuery::css2xpath ('*#id ' ));
1919});
2020
2121
2222test ('class ' , function () {
23- Assert::same (".// *[contains(concat(' ', normalize-space(@class), ' '), ' foo ')] " , DomQuery::css2xpath ('.foo ' ));
24- Assert::same (".// *[contains(concat(' ', normalize-space(@class), ' '), ' foo ')] " , DomQuery::css2xpath ('*.foo ' ));
25- Assert::same (".// *[contains(concat(' ', normalize-space(@class), ' '), ' foo ')][contains(concat(' ', normalize-space(@class), ' '), ' bar ')] " , DomQuery::css2xpath ('.foo.bar ' ));
23+ Assert::same ("*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')] " , DomQuery::css2xpath ('.foo ' ));
24+ Assert::same ("*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')] " , DomQuery::css2xpath ('*.foo ' ));
25+ Assert::same ("*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')][contains(concat(' ', normalize-space(@class), ' '), ' bar ')] " , DomQuery::css2xpath ('.foo.bar ' ));
2626});
2727
2828
2929test ('attribute selectors ' , function () {
30- Assert::same ('.// div[@foo] ' , DomQuery::css2xpath ('div[foo] ' ));
31- Assert::same (".// div[@foo='bar'] " , DomQuery::css2xpath ('div[foo=bar] ' ));
32- Assert::same (".// *[@foo='bar'] " , DomQuery::css2xpath ('[foo="bar"] ' ));
33- Assert::same (".// div[@foo='bar'] " , DomQuery::css2xpath ('div[foo="bar"] ' ));
34- Assert::same (".// div[@foo='bar'] " , DomQuery::css2xpath ("div[foo='bar'] " ));
35- Assert::same (".// div[@foo='bar'] " , DomQuery::css2xpath ('div[Foo="bar"] ' ));
36- Assert::same (".// div[contains(concat(' ', normalize-space(@foo), ' '), ' bar ')] " , DomQuery::css2xpath ('div[foo~="bar"] ' ));
37- Assert::same (".// div[contains(@foo, 'bar')] " , DomQuery::css2xpath ('div[foo*="bar"] ' ));
38- Assert::same (".// div[starts-with(@foo, 'bar')] " , DomQuery::css2xpath ('div[foo^="bar"] ' ));
39- Assert::same (".// div[substring(@foo, string-length(@foo)-0)='bar'] " , DomQuery::css2xpath ('div[foo$="bar"] ' ));
40- Assert::same (".// div[@foo='bar[]'] " , DomQuery::css2xpath ("div[foo='bar[]'] " ));
41- Assert::same (".// div[@foo='bar[]'] " , DomQuery::css2xpath ('div[foo="bar[]"] ' ));
30+ Assert::same ('div[@foo] ' , DomQuery::css2xpath ('div[foo] ' ));
31+ Assert::same ("div[@foo='bar'] " , DomQuery::css2xpath ('div[foo=bar] ' ));
32+ Assert::same ("*[@foo='bar'] " , DomQuery::css2xpath ('[foo="bar"] ' ));
33+ Assert::same ("div[@foo='bar'] " , DomQuery::css2xpath ('div[foo="bar"] ' ));
34+ Assert::same ("div[@foo='bar'] " , DomQuery::css2xpath ("div[foo='bar'] " ));
35+ Assert::same ("div[@foo='bar'] " , DomQuery::css2xpath ('div[Foo="bar"] ' ));
36+ Assert::same ("div[contains(concat(' ', normalize-space(@foo), ' '), ' bar ')] " , DomQuery::css2xpath ('div[foo~="bar"] ' ));
37+ Assert::same ("div[contains(@foo, 'bar')] " , DomQuery::css2xpath ('div[foo*="bar"] ' ));
38+ Assert::same ("div[starts-with(@foo, 'bar')] " , DomQuery::css2xpath ('div[foo^="bar"] ' ));
39+ Assert::same ("div[substring(@foo, string-length(@foo)-0)='bar'] " , DomQuery::css2xpath ('div[foo$="bar"] ' ));
40+ Assert::same ("div[@foo='bar[]'] " , DomQuery::css2xpath ("div[foo='bar[]'] " ));
41+ Assert::same ("div[@foo='bar[]'] " , DomQuery::css2xpath ('div[foo="bar[]"] ' ));
4242});
4343
4444
4545test ('variants ' , function () {
46- Assert::same (".// *[@id='foo']|//*[@id='bar'] " , DomQuery::css2xpath ('#foo, #bar ' ));
47- Assert::same (".// *[@id='foo']|//*[@id='bar'] " , DomQuery::css2xpath ('#foo,#bar ' ));
48- Assert::same (".// *[@id='foo']|//*[@id='bar'] " , DomQuery::css2xpath ('#foo ,#bar ' ));
46+ Assert::same ("*[@id='foo']|//*[@id='bar'] " , DomQuery::css2xpath ('#foo, #bar ' ));
47+ Assert::same ("*[@id='foo']|//*[@id='bar'] " , DomQuery::css2xpath ('#foo,#bar ' ));
48+ Assert::same ("*[@id='foo']|//*[@id='bar'] " , DomQuery::css2xpath ('#foo ,#bar ' ));
4949});
5050
5151
5252test ('descendant combinator ' , function () {
5353 Assert::same (
54- ".// div[@id='foo']//*[contains(concat(' ', normalize-space(@class), ' '), ' bar ')] " ,
54+ "div[@id='foo']//*[contains(concat(' ', normalize-space(@class), ' '), ' bar ')] " ,
5555 DomQuery::css2xpath ('div#foo .bar ' ),
5656 );
5757 Assert::same (
58- '.// div//*//p ' ,
58+ 'div//*//p ' ,
5959 DomQuery::css2xpath ('div * p ' ),
6060 );
6161});
6262
6363
6464test ('child combinator ' , function () {
65- Assert::same (".// div[@id='foo']/span " , DomQuery::css2xpath ('div#foo>span ' ));
66- Assert::same (".// div[@id='foo']/span " , DomQuery::css2xpath ('div#foo > span ' ));
65+ Assert::same ("div[@id='foo']/span " , DomQuery::css2xpath ('div#foo>span ' ));
66+ Assert::same ("div[@id='foo']/span " , DomQuery::css2xpath ('div#foo > span ' ));
6767});
6868
6969
7070test ('general sibling combinator ' , function () {
71- Assert::same ('.// div/following-sibling::span ' , DomQuery::css2xpath ('div ~ span ' ));
71+ Assert::same ('div/following-sibling::span ' , DomQuery::css2xpath ('div ~ span ' ));
7272});
7373
7474
7575test ('complex ' , function () {
7676 Assert::same (
77- ".// div[@id='foo']//span[contains(concat(' ', normalize-space(@class), ' '), ' bar ')] "
77+ "div[@id='foo']//span[contains(concat(' ', normalize-space(@class), ' '), ' bar ')] "
7878 . "|//*[@id='bar']//li[contains(concat(' ', normalize-space(@class), ' '), ' baz ')]//a " ,
7979 DomQuery::css2xpath ('div#foo span.bar, #bar li.baz a ' ),
8080 );
0 commit comments