Skip to content

Commit 5d89ceb

Browse files
Merge branch '4.4' into 5.1
* 4.4: Use createMock() and use import instead of FQCN
2 parents a9dab73 + 21032c5 commit 5d89ceb

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

Tests/AbstractCrawlerTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DomCrawler\Crawler;
16+
use Symfony\Component\DomCrawler\Form;
17+
use Symfony\Component\DomCrawler\Image;
18+
use Symfony\Component\DomCrawler\Link;
1619

1720
abstract class AbstractCrawlerTest extends TestCase
1821
{
@@ -710,7 +713,7 @@ public function testSelectButtonWithDoubleQuotesInNameAttribute()
710713
public function testLink()
711714
{
712715
$crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo');
713-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Link::class, $crawler->link(), '->link() returns a Link instance');
716+
$this->assertInstanceOf(Link::class, $crawler->link(), '->link() returns a Link instance');
714717

715718
$this->assertEquals('POST', $crawler->link('post')->getMethod(), '->link() takes a method as its argument');
716719

@@ -744,7 +747,7 @@ public function testInvalidLinks()
744747
public function testImage()
745748
{
746749
$crawler = $this->createTestCrawler('http://example.com/bar/')->selectImage('Bar');
747-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Image::class, $crawler->image(), '->image() returns an Image instance');
750+
$this->assertInstanceOf(Image::class, $crawler->image(), '->image() returns an Image instance');
748751

749752
try {
750753
$this->createTestCrawler()->filterXPath('//ol')->image();
@@ -820,8 +823,8 @@ public function testForm()
820823
$testCrawler = $this->createTestCrawler('http://example.com/bar/');
821824
$crawler = $testCrawler->selectButton('FooValue');
822825
$crawler2 = $testCrawler->selectButton('FooBarValue');
823-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Form::class, $crawler->form(), '->form() returns a Form instance');
824-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Form::class, $crawler2->form(), '->form() returns a Form instance');
826+
$this->assertInstanceOf(Form::class, $crawler->form(), '->form() returns a Form instance');
827+
$this->assertInstanceOf(Form::class, $crawler2->form(), '->form() returns a Form instance');
825828

826829
$this->assertEquals($crawler->form()->getFormNode()->getAttribute('id'), $crawler2->form()->getFormNode()->getAttribute('id'), '->form() works on elements with form attribute');
827830

Tests/FormTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
namespace Symfony\Component\DomCrawler\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\DomCrawler\Field\ChoiceFormField;
16+
use Symfony\Component\DomCrawler\Field\FormField;
17+
use Symfony\Component\DomCrawler\Field\InputFormField;
1518
use Symfony\Component\DomCrawler\Field\TextareaFormField;
1619
use Symfony\Component\DomCrawler\Form;
1720
use Symfony\Component\DomCrawler\FormFieldRegistry;
@@ -682,7 +685,7 @@ public function testGet()
682685
{
683686
$form = $this->createForm('<form method="post"><input type="text" name="bar" value="bar" /><input type="submit" /></form>');
684687

685-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Field\InputFormField::class, $form->get('bar'), '->get() returns the field object associated with the given name');
688+
$this->assertInstanceOf(InputFormField::class, $form->get('bar'), '->get() returns the field object associated with the given name');
686689

687690
try {
688691
$form->get('foo');
@@ -698,7 +701,7 @@ public function testAll()
698701

699702
$fields = $form->all();
700703
$this->assertCount(1, $fields, '->all() return an array of form field objects');
701-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Field\InputFormField::class, $fields['bar'], '->all() return an array of form field objects');
704+
$this->assertInstanceOf(InputFormField::class, $fields['bar'], '->all() return an array of form field objects');
702705
}
703706

704707
public function testSubmitWithoutAFormButton()
@@ -864,13 +867,13 @@ public function testDifferentFieldTypesWithSameName()
864867
');
865868
$form = new Form($dom->getElementsByTagName('form')->item(0), 'http://example.com');
866869

867-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Field\ChoiceFormField::class, $form->get('option'));
870+
$this->assertInstanceOf(ChoiceFormField::class, $form->get('option'));
868871
}
869872

870873
protected function getFormFieldMock($name, $value = null)
871874
{
872875
$field = $this
873-
->getMockBuilder(\Symfony\Component\DomCrawler\Field\FormField::class)
876+
->getMockBuilder(FormField::class)
874877
->setMethods(['getName', 'getValue', 'setValue', 'initialize'])
875878
->disableOriginalConstructor()
876879
->getMock()

0 commit comments

Comments
 (0)