You are here

public function CrawlerTest::testExtract 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::testExtract()

File

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

Class

CrawlerTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testExtract() {
  $crawler = $this
    ->createTestCrawler()
    ->filterXPath('//ul[1]/li');
  $this
    ->assertEquals(array(
    'One',
    'Two',
    'Three',
  ), $crawler
    ->extract('_text'), '->extract() returns an array of extracted data from the node list');
  $this
    ->assertEquals(array(
    array(
      'One',
      'first',
    ),
    array(
      'Two',
      '',
    ),
    array(
      'Three',
      '',
    ),
  ), $crawler
    ->extract(array(
    '_text',
    'class',
  )), '->extract() returns an array of extracted data from the node list');
  $this
    ->assertEquals(array(), $this
    ->createTestCrawler()
    ->filterXPath('//ol')
    ->extract('_text'), '->extract() returns an empty array if the node list is empty');
}