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
This commit is contained in:
Fabien Potencier 2015-10-03 08:20:57 +02:00
commit da92c1087d

View File

@ -340,6 +340,14 @@ EOF
$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');
@ -471,6 +479,12 @@ EOF
$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');