$doc =
new \
DOMDocument();
$node =
$doc->
createElement('test'
);
$crawler =
$this->
createCrawler($node);
$crawler->
clear();
$this->
assertCount(0,
$crawler, '->clear() removes all the nodes from the crawler'
);
} public function testEq() { $crawler =
$this->
createTestCrawler()->
filterXPath('//li'
);
$this->
assertNotSame($crawler,
$crawler->
eq(0
), '->eq() returns a new instance of a crawler'
);
$this->
assertInstanceOf(Crawler::
class,
$crawler->
eq(0
), '->eq() returns a new instance of a crawler'
);
$this->
assertEquals('Two',
$crawler->
eq(1
)->
text(), '->eq() returns the nth node of the list'
);
$this->
assertCount(0,
$crawler->
eq(100
), '->eq() returns an empty crawler if the nth node does not exist'
);
} public function testNormalizeWhiteSpace() { $crawler =
$this->
createTestCrawler()->
filterXPath('//p'
);
$this->
assertSame('Elsa <3',
$crawler->
text(null, true
), '->text(null, true) returns the text with normalized whitespace'
);
$this->
assertNotSame('Elsa <3',
$crawler->
text(null, false
));
}