minor #39691 [DomCrawler] fix tests to run assertions on returned Crawler instances (xabbuh)
This PR was merged into the 4.4 branch.
Discussion
----------
[DomCrawler] fix tests to run assertions on returned Crawler instances
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
Commits
-------
1d0c91629a
fix tests to run assertions on returned Crawler instances
This commit is contained in:
commit
426bf9640a
@ -247,7 +247,7 @@ abstract class AbstractCrawlerTest extends TestCase
|
||||
{
|
||||
$crawler = $this->createTestCrawler()->filterXPath('//li');
|
||||
$this->assertNotSame($crawler, $crawler->eq(0), '->eq() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->eq() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->eq(0), '->eq() returns a new instance of a crawler');
|
||||
|
||||
$this->assertEquals('Two', $crawler->eq(1)->text(), '->eq() returns the nth node of the list');
|
||||
$this->assertCount(0, $crawler->eq(100), '->eq() returns an empty crawler if the nth node does not exist');
|
||||
@ -412,7 +412,7 @@ abstract class AbstractCrawlerTest extends TestCase
|
||||
{
|
||||
$crawler = $this->createTestCrawler();
|
||||
$this->assertNotSame($crawler, $crawler->filterXPath('//li'), '->filterXPath() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filterXPath() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->filterXPath('//li'), '->filterXPath() returns a new instance of a crawler');
|
||||
|
||||
$crawler = $this->createTestCrawler()->filterXPath('//ul');
|
||||
$this->assertCount(6, $crawler->filterXPath('//li'), '->filterXPath() filters the node list with the XPath expression');
|
||||
@ -579,7 +579,7 @@ abstract class AbstractCrawlerTest extends TestCase
|
||||
{
|
||||
$crawler = $this->createTestCrawler();
|
||||
$this->assertNotSame($crawler, $crawler->filter('li'), '->filter() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filter() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->filter('li'), '->filter() returns a new instance of a crawler');
|
||||
|
||||
$crawler = $this->createTestCrawler()->filter('ul');
|
||||
|
||||
@ -632,7 +632,7 @@ abstract class AbstractCrawlerTest extends TestCase
|
||||
{
|
||||
$crawler = $this->createTestCrawler();
|
||||
$this->assertNotSame($crawler, $crawler->selectLink('Foo'), '->selectLink() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectLink() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectLink('Foo'), '->selectLink() returns a new instance of a crawler');
|
||||
|
||||
$this->assertCount(1, $crawler->selectLink('Fabien\'s Foo'), '->selectLink() selects links by the node values');
|
||||
$this->assertCount(1, $crawler->selectLink('Fabien\'s Bar'), '->selectLink() selects links by the alt attribute of a clickable image');
|
||||
@ -651,7 +651,7 @@ abstract class AbstractCrawlerTest extends TestCase
|
||||
{
|
||||
$crawler = $this->createTestCrawler();
|
||||
$this->assertNotSame($crawler, $crawler->selectImage('Bar'), '->selectImage() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectImage() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectImage('Bar'), '->selectImage() returns a new instance of a crawler');
|
||||
|
||||
$this->assertCount(1, $crawler->selectImage('Fabien\'s Bar'), '->selectImage() selects images by alt attribute');
|
||||
$this->assertCount(2, $crawler->selectImage('Fabien"s Bar'), '->selectImage() selects images by alt attribute');
|
||||
@ -662,7 +662,7 @@ abstract class AbstractCrawlerTest extends TestCase
|
||||
{
|
||||
$crawler = $this->createTestCrawler();
|
||||
$this->assertNotSame($crawler, $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectButton() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler');
|
||||
|
||||
$this->assertEquals(1, $crawler->selectButton('FooValue')->count(), '->selectButton() selects buttons');
|
||||
$this->assertEquals(1, $crawler->selectButton('FooName')->count(), '->selectButton() selects buttons');
|
||||
@ -807,7 +807,7 @@ HTML;
|
||||
|
||||
$this->assertCount(4, $crawler->links(), '->links() returns an array');
|
||||
$links = $crawler->links();
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Link', $links[0], '->links() returns an array of Link instances');
|
||||
$this->assertContainsOnlyInstancesOf('Symfony\\Component\\DomCrawler\\Link', $links, '->links() returns an array of Link instances');
|
||||
|
||||
$this->assertEquals([], $this->createTestCrawler()->filterXPath('//ol')->links(), '->links() returns an empty array if the node selection is empty');
|
||||
}
|
||||
@ -819,7 +819,7 @@ HTML;
|
||||
|
||||
$this->assertCount(4, $crawler->images(), '->images() returns an array');
|
||||
$images = $crawler->images();
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Image', $images[0], '->images() returns an array of Image instances');
|
||||
$this->assertContainsOnlyInstancesOf('Symfony\\Component\\DomCrawler\\Image', $images, '->images() returns an array of Image instances');
|
||||
|
||||
$this->assertEquals([], $this->createTestCrawler()->filterXPath('//ol')->links(), '->links() returns an empty array if the node selection is empty');
|
||||
}
|
||||
@ -858,7 +858,7 @@ HTML;
|
||||
{
|
||||
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
|
||||
$this->assertNotSame($crawler, $crawler->last(), '->last() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->last() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->last(), '->last() returns a new instance of a crawler');
|
||||
|
||||
$this->assertEquals('Three', $crawler->last()->text());
|
||||
}
|
||||
@ -867,7 +867,7 @@ HTML;
|
||||
{
|
||||
$crawler = $this->createTestCrawler()->filterXPath('//li');
|
||||
$this->assertNotSame($crawler, $crawler->first(), '->first() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->first() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->first(), '->first() returns a new instance of a crawler');
|
||||
|
||||
$this->assertEquals('One', $crawler->first()->text());
|
||||
}
|
||||
@ -876,7 +876,7 @@ HTML;
|
||||
{
|
||||
$crawler = $this->createTestCrawler()->filterXPath('//li')->eq(1);
|
||||
$this->assertNotSame($crawler, $crawler->siblings(), '->siblings() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->siblings() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->siblings(), '->siblings() returns a new instance of a crawler');
|
||||
|
||||
$nodes = $crawler->siblings();
|
||||
$this->assertEquals(2, $nodes->count());
|
||||
@ -999,7 +999,7 @@ HTML;
|
||||
{
|
||||
$crawler = $this->createTestCrawler()->filterXPath('//li')->eq(1);
|
||||
$this->assertNotSame($crawler, $crawler->nextAll(), '->nextAll() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->nextAll() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->nextAll(), '->nextAll() returns a new instance of a crawler');
|
||||
|
||||
$nodes = $crawler->nextAll();
|
||||
$this->assertEquals(1, $nodes->count());
|
||||
@ -1017,7 +1017,7 @@ HTML;
|
||||
{
|
||||
$crawler = $this->createTestCrawler()->filterXPath('//li')->eq(2);
|
||||
$this->assertNotSame($crawler, $crawler->previousAll(), '->previousAll() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->previousAll() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->previousAll(), '->previousAll() returns a new instance of a crawler');
|
||||
|
||||
$nodes = $crawler->previousAll();
|
||||
$this->assertEquals(2, $nodes->count());
|
||||
@ -1035,7 +1035,7 @@ HTML;
|
||||
{
|
||||
$crawler = $this->createTestCrawler()->filterXPath('//ul');
|
||||
$this->assertNotSame($crawler, $crawler->children(), '->children() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->children() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->children(), '->children() returns a new instance of a crawler');
|
||||
|
||||
$nodes = $crawler->children();
|
||||
$this->assertEquals(3, $nodes->count());
|
||||
@ -1095,7 +1095,7 @@ HTML;
|
||||
{
|
||||
$crawler = $this->createTestCrawler()->filterXPath('//li[1]');
|
||||
$this->assertNotSame($crawler, $crawler->parents(), '->parents() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->parents() returns a new instance of a crawler');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->parents(), '->parents() returns a new instance of a crawler');
|
||||
|
||||
$nodes = $crawler->parents();
|
||||
$this->assertEquals(3, $nodes->count());
|
||||
|
Reference in New Issue
Block a user