public function CrawlerTest::testChildren in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dom-crawler/Tests/CrawlerTest.php \Symfony\Component\DomCrawler\Tests\CrawlerTest::testChildren()
File
- vendor/
symfony/ dom-crawler/ Tests/ CrawlerTest.php, line 905
Class
Namespace
Symfony\Component\DomCrawler\TestsCode
public function testChildren() {
$crawler = $this
->createTestCrawler()
->filterXPath('//ul');
$this
->assertNotSame($crawler, $crawler
->children(), '->children() returns a new instance of a crawler');
$this
->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->children() returns a new instance of a crawler');
$nodes = $crawler
->children();
$this
->assertEquals(3, $nodes
->count());
$this
->assertEquals('One', $nodes
->eq(0)
->text());
$this
->assertEquals('Two', $nodes
->eq(1)
->text());
$this
->assertEquals('Three', $nodes
->eq(2)
->text());
try {
$this
->createTestCrawler()
->filterXPath('//ol')
->children();
$this
->fail('->children() throws an \\InvalidArgumentException if the node list is empty');
} catch (\InvalidArgumentException $e) {
$this
->assertTrue(true, '->children() throws an \\InvalidArgumentException if the node list is empty');
}
try {
$crawler = new Crawler('<p></p>');
$crawler
->filter('p')
->children();
$this
->assertTrue(true, '->children() does not trigger a notice if the node has no children');
} catch (\PHPUnit_Framework_Error_Notice $e) {
$this
->fail('->children() does not trigger a notice if the node has no children');
}
}