Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 426bf96

Browse files
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 ------- 1d0c916 fix tests to run assertions on returned Crawler instances
2 parents e8d5d29 + 1d0c916 commit 426bf96

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public function testEq()
247247
{
248248
$crawler = $this->createTestCrawler()->filterXPath('//li');
249249
$this->assertNotSame($crawler, $crawler->eq(0), '->eq() returns a new instance of a crawler');
250-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->eq() returns a new instance of a crawler');
250+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->eq(0), '->eq() returns a new instance of a crawler');
251251

252252
$this->assertEquals('Two', $crawler->eq(1)->text(), '->eq() returns the nth node of the list');
253253
$this->assertCount(0, $crawler->eq(100), '->eq() returns an empty crawler if the nth node does not exist');
@@ -412,7 +412,7 @@ public function testFilterXPath()
412412
{
413413
$crawler = $this->createTestCrawler();
414414
$this->assertNotSame($crawler, $crawler->filterXPath('//li'), '->filterXPath() returns a new instance of a crawler');
415-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filterXPath() returns a new instance of a crawler');
415+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->filterXPath('//li'), '->filterXPath() returns a new instance of a crawler');
416416

417417
$crawler = $this->createTestCrawler()->filterXPath('//ul');
418418
$this->assertCount(6, $crawler->filterXPath('//li'), '->filterXPath() filters the node list with the XPath expression');
@@ -579,7 +579,7 @@ public function testFilter()
579579
{
580580
$crawler = $this->createTestCrawler();
581581
$this->assertNotSame($crawler, $crawler->filter('li'), '->filter() returns a new instance of a crawler');
582-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filter() returns a new instance of a crawler');
582+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->filter('li'), '->filter() returns a new instance of a crawler');
583583

584584
$crawler = $this->createTestCrawler()->filter('ul');
585585

@@ -632,7 +632,7 @@ public function testSelectLink()
632632
{
633633
$crawler = $this->createTestCrawler();
634634
$this->assertNotSame($crawler, $crawler->selectLink('Foo'), '->selectLink() returns a new instance of a crawler');
635-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectLink() returns a new instance of a crawler');
635+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectLink('Foo'), '->selectLink() returns a new instance of a crawler');
636636

637637
$this->assertCount(1, $crawler->selectLink('Fabien\'s Foo'), '->selectLink() selects links by the node values');
638638
$this->assertCount(1, $crawler->selectLink('Fabien\'s Bar'), '->selectLink() selects links by the alt attribute of a clickable image');
@@ -651,7 +651,7 @@ public function testSelectImage()
651651
{
652652
$crawler = $this->createTestCrawler();
653653
$this->assertNotSame($crawler, $crawler->selectImage('Bar'), '->selectImage() returns a new instance of a crawler');
654-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectImage() returns a new instance of a crawler');
654+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectImage('Bar'), '->selectImage() returns a new instance of a crawler');
655655

656656
$this->assertCount(1, $crawler->selectImage('Fabien\'s Bar'), '->selectImage() selects images by alt attribute');
657657
$this->assertCount(2, $crawler->selectImage('Fabien"s Bar'), '->selectImage() selects images by alt attribute');
@@ -662,7 +662,7 @@ public function testSelectButton()
662662
{
663663
$crawler = $this->createTestCrawler();
664664
$this->assertNotSame($crawler, $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler');
665-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectButton() returns a new instance of a crawler');
665+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler');
666666

667667
$this->assertEquals(1, $crawler->selectButton('FooValue')->count(), '->selectButton() selects buttons');
668668
$this->assertEquals(1, $crawler->selectButton('FooName')->count(), '->selectButton() selects buttons');
@@ -807,7 +807,7 @@ public function testLinks()
807807

808808
$this->assertCount(4, $crawler->links(), '->links() returns an array');
809809
$links = $crawler->links();
810-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Link', $links[0], '->links() returns an array of Link instances');
810+
$this->assertContainsOnlyInstancesOf('Symfony\\Component\\DomCrawler\\Link', $links, '->links() returns an array of Link instances');
811811

812812
$this->assertEquals([], $this->createTestCrawler()->filterXPath('//ol')->links(), '->links() returns an empty array if the node selection is empty');
813813
}
@@ -819,7 +819,7 @@ public function testImages()
819819

820820
$this->assertCount(4, $crawler->images(), '->images() returns an array');
821821
$images = $crawler->images();
822-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Image', $images[0], '->images() returns an array of Image instances');
822+
$this->assertContainsOnlyInstancesOf('Symfony\\Component\\DomCrawler\\Image', $images, '->images() returns an array of Image instances');
823823

824824
$this->assertEquals([], $this->createTestCrawler()->filterXPath('//ol')->links(), '->links() returns an empty array if the node selection is empty');
825825
}
@@ -858,7 +858,7 @@ public function testLast()
858858
{
859859
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
860860
$this->assertNotSame($crawler, $crawler->last(), '->last() returns a new instance of a crawler');
861-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->last() returns a new instance of a crawler');
861+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->last(), '->last() returns a new instance of a crawler');
862862

863863
$this->assertEquals('Three', $crawler->last()->text());
864864
}
@@ -867,7 +867,7 @@ public function testFirst()
867867
{
868868
$crawler = $this->createTestCrawler()->filterXPath('//li');
869869
$this->assertNotSame($crawler, $crawler->first(), '->first() returns a new instance of a crawler');
870-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->first() returns a new instance of a crawler');
870+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->first(), '->first() returns a new instance of a crawler');
871871

872872
$this->assertEquals('One', $crawler->first()->text());
873873
}
@@ -876,7 +876,7 @@ public function testSiblings()
876876
{
877877
$crawler = $this->createTestCrawler()->filterXPath('//li')->eq(1);
878878
$this->assertNotSame($crawler, $crawler->siblings(), '->siblings() returns a new instance of a crawler');
879-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->siblings() returns a new instance of a crawler');
879+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->siblings(), '->siblings() returns a new instance of a crawler');
880880

881881
$nodes = $crawler->siblings();
882882
$this->assertEquals(2, $nodes->count());
@@ -999,7 +999,7 @@ public function testNextAll()
999999
{
10001000
$crawler = $this->createTestCrawler()->filterXPath('//li')->eq(1);
10011001
$this->assertNotSame($crawler, $crawler->nextAll(), '->nextAll() returns a new instance of a crawler');
1002-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->nextAll() returns a new instance of a crawler');
1002+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->nextAll(), '->nextAll() returns a new instance of a crawler');
10031003

10041004
$nodes = $crawler->nextAll();
10051005
$this->assertEquals(1, $nodes->count());
@@ -1017,7 +1017,7 @@ public function testPreviousAll()
10171017
{
10181018
$crawler = $this->createTestCrawler()->filterXPath('//li')->eq(2);
10191019
$this->assertNotSame($crawler, $crawler->previousAll(), '->previousAll() returns a new instance of a crawler');
1020-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->previousAll() returns a new instance of a crawler');
1020+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->previousAll(), '->previousAll() returns a new instance of a crawler');
10211021

10221022
$nodes = $crawler->previousAll();
10231023
$this->assertEquals(2, $nodes->count());
@@ -1035,7 +1035,7 @@ public function testChildren()
10351035
{
10361036
$crawler = $this->createTestCrawler()->filterXPath('//ul');
10371037
$this->assertNotSame($crawler, $crawler->children(), '->children() returns a new instance of a crawler');
1038-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->children() returns a new instance of a crawler');
1038+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->children(), '->children() returns a new instance of a crawler');
10391039

10401040
$nodes = $crawler->children();
10411041
$this->assertEquals(3, $nodes->count());
@@ -1095,7 +1095,7 @@ public function testParents()
10951095
{
10961096
$crawler = $this->createTestCrawler()->filterXPath('//li[1]');
10971097
$this->assertNotSame($crawler, $crawler->parents(), '->parents() returns a new instance of a crawler');
1098-
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->parents() returns a new instance of a crawler');
1098+
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->parents(), '->parents() returns a new instance of a crawler');
10991099

11001100
$nodes = $crawler->parents();
11011101
$this->assertEquals(3, $nodes->count());

0 commit comments

Comments
 (0)