Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 528d3bd

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

File tree

1 file changed

+14
-0
lines changed
Filter options

1 file changed

+14
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.