Skip to content

Commit da92c10

Browse 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

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 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy