$crawler =
$this->
createTestCrawler()->
filterXPath('//ul[1]/li'
);
$this->
assertNotSame($crawler->
slice(),
$crawler, '->slice() returns a new instance of a crawler'
);
$this->
assertInstanceOf(Crawler::
class,
$crawler->
slice(), '->slice() returns a new instance of a crawler'
);
$this->
assertCount(3,
$crawler->
slice(), '->slice() does not slice the nodes in the list if any param is entered'
);
$this->
assertCount(1,
$crawler->
slice(1, 1
), '->slice() slices the nodes in the list'
);
} public function testReduce() { $crawler =
$this->
createTestCrawler()->
filterXPath('//ul[1]/li'
);
$nodes =
$crawler->
reduce(fn ($node,
$i) => 1 !==
$i);
$this->
assertNotSame($nodes,
$crawler, '->reduce() returns a new instance of a crawler'
);
$this->
assertInstanceOf(Crawler::
class,
$nodes, '->reduce() returns a new instance of a crawler'
);
$this->
assertCount(2,
$nodes, '->reduce() filters the nodes in the list'
);
} public function testAttr() { $this->
assertEquals('first',
$this->
createTestCrawler()->
filterXPath('//li'
)->
attr('class'
), '->attr() returns the attribute of the first element of the node list'
);
try {