You are here

public function CrawlerTest::testFilterXpathComplexQueries in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Tests/CrawlerTest.php \Symfony\Component\DomCrawler\Tests\CrawlerTest::testFilterXpathComplexQueries()

File

vendor/symfony/dom-crawler/Tests/CrawlerTest.php, line 410

Class

CrawlerTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testFilterXpathComplexQueries() {
  $crawler = $this
    ->createTestCrawler()
    ->filterXPath('//body');
  $this
    ->assertCount(0, $crawler
    ->filterXPath('/input'));
  $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'));
  $this
    ->assertCount(1, $crawler
    ->filterXPath('//body'));
  $this
    ->assertCount(1, $crawler
    ->filterXPath('descendant-or-self::body'));
  $this
    ->assertCount(1, $crawler
    ->filterXPath('//div[@id="parent"]')
    ->filterXPath('./div'), 'A child selection finds only the current div');
  $this
    ->assertCount(3, $crawler
    ->filterXPath('//div[@id="parent"]')
    ->filterXPath('descendant::div'), 'A descendant selector matches the current div and its child');
  $this
    ->assertCount(3, $crawler
    ->filterXPath('//div[@id="parent"]')
    ->filterXPath('//div'), 'A descendant selector matches the current div and its child');
  $this
    ->assertCount(5, $crawler
    ->filterXPath('(//a | //div)//img'));
  $this
    ->assertCount(7, $crawler
    ->filterXPath('((//a | //div)//img | //ul)'));
  $this
    ->assertCount(7, $crawler
    ->filterXPath('( ( //a | //div )//img | //ul )'));
}