You are here

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

File

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

Class

CrawlerTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testReduce() {
  $crawler = $this
    ->createTestCrawler()
    ->filterXPath('//ul[1]/li');
  $nodes = $crawler
    ->reduce(function ($node, $i) {
    return $i !== 1;
  });
  $this
    ->assertNotSame($nodes, $crawler, '->reduce() returns a new instance of a crawler');
  $this
    ->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $nodes, '->reduce() returns a new instance of a crawler');
  $this
    ->assertCount(2, $nodes, '->reduce() filters the nodes in the list');
}