Skip to content

Add a few additional tests for the Crawler #16093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ public function testEach()
$this->assertEquals(array('0-One', '1-Two', '2-Three'), $data, '->each() executes an anonymous function on each node of the list');
}

public function testIteration()
{
$crawler = $this->createTestCrawler()->filterXPath('//li');

$this->assertInstanceOf('Traversable', $crawler);
$this->assertContainsOnlyInstancesOf('DOMElement', iterator_to_array($crawler), 'Iterating a Crawler gives DOMElement instances');
}

public function testSlice()
{
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
Expand Down Expand Up @@ -471,6 +479,12 @@ public function testFilterXPath()
$this->assertCount(3, $crawler->filterXPath('//body')->filterXPath('//button')->parents(), '->filterXpath() preserves parents when chained');
}

public function testFilterRemovesDuplicates()
{
$crawler = $this->createTestCrawler()->filter('html, body')->filter('li');
$this->assertCount(6, $crawler, 'The crawler removes duplicates when filtering.');
}

public function testFilterXPathWithDefaultNamespace()
{
$crawler = $this->createTestXmlCrawler()->filterXPath('//default:entry/default:id');
Expand Down