You are here

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

File

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

Class

CrawlerTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testEach() {
  $data = $this
    ->createTestCrawler()
    ->filterXPath('//ul[1]/li')
    ->each(function ($node, $i) {
    return $i . '-' . $node
      ->text();
  });
  $this
    ->assertEquals(array(
    '0-One',
    '1-Two',
    '2-Three',
  ), $data, '->each() executes an anonymous function on each node of the list');
}