[DomCrawler] Fixed a forgotten case of complex XPath queries

This commit is contained in:
Christophe Coevoet 2014-05-24 19:15:07 +02:00
parent 29341fab1b
commit a9de61e86d
2 changed files with 4 additions and 0 deletions

View File

@ -839,6 +839,8 @@ class Crawler extends \SplObjectStorage
$expression = $nonMatchingExpression;
} elseif (0 === strpos($expression, '//')) {
$expression = 'descendant-or-self::' . substr($expression, 2);
} elseif (0 === strpos($expression, './/')) {
$expression = 'descendant-or-self::' . substr($expression, 3);
} elseif (0 === strpos($expression, './')) {
$expression = 'self::' . substr($expression, 2);
} elseif ('/' === $expression[0]) {

View File

@ -376,6 +376,8 @@ EOF
$this->assertCount(0, $crawler->filterXPath('/body'));
$this->assertCount(1, $crawler->filterXPath('/_root/body'));
$this->assertCount(1, $crawler->filterXPath('./body'));
$this->assertCount(1, $crawler->filterXPath('.//body'));
$this->assertCount(5, $crawler->filterXPath('.//input'));
$this->assertCount(4, $crawler->filterXPath('//form')->filterXPath('//button | //input'));
$this->assertCount(1, $crawler->filterXPath('body'));
$this->assertCount(6, $crawler->filterXPath('//button | //input'));