8000 Add a few additional tests for the Crawler · symfony/symfony@528d3bd · GitHub
[go: up one dir, main page]

Skip to content

Commit 528d3bd

Browse files
committed
Add a few additional tests for the Crawler
1 parent 6acd43d commit 528d3bd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDif DDF5 f line numberDiff line change
@@ -340,6 +340,14 @@ public function testEach()
340340
$this->assertEquals(array('0-One', '1-Two', '2-Three'), $data, '->each() executes an anonymous function on each node of the list');
341341
}
342342

343+
public function testIteration()
344+
{
345+
$crawler = $this->createTestCrawler()->filterXPath('//li');
346+
347+
$this->assertInstanceOf('Traversable', $crawler);
348+
$this->assertContainsOnlyInstancesOf('DOMElement', iterator_to_array($crawler), 'Iterating a Crawler gives DOMElement instances');
349+
}
350+
343351
public function testSlice()
344352
{
345353
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
@@ -471,6 +479,12 @@ public function testFilterXPath()
471479
$this->assertCount(3, $crawler->filterXPath('//body')->filterXPath('//button')->parents(), '->filterXpath() preserves parents when chained');
472480
}
473481

482+
public function testFilterRemovesDuplicates()
483+
{
484+
$crawler = $this->createTestCrawler()->filter('html, body')->filter('li');
485+
$this->assertCount(6, $crawler, 'The crawler removes duplicates when filtering.');
486+
}
487+
474488
public function testFilterXPathWithDefaultNamespace()
475489
{
476490
$crawler = $this->createTestXmlCrawler()->filterXPath('//default:entry/default:id');

0 commit comments

Comments
 (0)
0