@@ -8,73 +8,73 @@ use Tester\DomQuery;
8
8
require __DIR__ . '/../bootstrap.php ' ;
9
9
10
10
test ('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 ' ));
13
13
});
14
14
15
15
16
16
test ('#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 ' ));
19
19
});
20
20
21
21
22
22
test ('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 ' ));
26
26
});
27
27
28
28
29
29
test ('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[]"] ' ));
42
42
});
43
43
44
44
45
45
test ('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 ' ));
49
49
});
50
50
51
51
52
52
test ('descendant combinator ' , function () {
53
53
Assert::same (
54
- "//div[@id='foo']//*[contains(concat(' ', normalize-space(@class), ' '), ' bar ')] " ,
54
+ ". //div[@id='foo']//*[contains(concat(' ', normalize-space(@class), ' '), ' bar ')] " ,
55
55
DomQuery::css2xpath ('div#foo .bar ' ),
56
56
);
57
57
Assert::same (
58
- '//div//*//p ' ,
58
+ '. //div//*//p ' ,
59
59
DomQuery::css2xpath ('div * p ' ),
60
60
);
61
61
});
62
62
63
63
64
64
test ('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 ' ));
67
67
});
68
68
69
69
70
70
test ('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 ' ));
72
72
});
73
73
74
74
75
75
test ('complex ' , function () {
76
76
Assert::same (
77
- "//div[@id='foo']//span[contains(concat(' ', normalize-space(@class), ' '), ' bar ')] "
77
+ ". //div[@id='foo']//span[contains(concat(' ', normalize-space(@class), ' '), ' bar ')] "
78
78
. "|//*[@id='bar']//li[contains(concat(' ', normalize-space(@class), ' '), ' baz ')]//a " ,
79
79
DomQuery::css2xpath ('div#foo span.bar, #bar li.baz a ' ),
80
80
);
0 commit comments