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 da92c10

Browse filesBrowse files
committed
minor #16093 Add a few additional tests for the Crawler (stof)
This PR was merged into the 2.8 branch. Discussion ---------- Add a few additional tests for the Crawler | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a While looking at the update of the Crawler in #16075, I spotted a few mistakes. But these were cases not covered by the testsuite. This is adding tests for these cases in the 2.8 branch (they could be added in 2.3 eventually though). Commits ------- 528d3bd Add a few additional tests for the Crawler
2 parents 6acd43d + 528d3bd commit da92c10
Copy full SHA for da92c10

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.