Skip to content

Commit 21032c5

Browse files
OskarStarknicolas-grekas
authored andcommitted
Use createMock() and use import instead of FQCN
1 parent 2b078cc commit 21032c5

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
{
@@ -719,7 +722,7 @@ public function testSelectButtonWithDoubleQuotesInNameAttribute()
719722
public function testLink()
720723
{
721724
$crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo');
722-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Link::class, $crawler->link(), '->link() returns a Link instance');
725+
$this->assertInstanceOf(Link::class, $crawler->link(), '->link() returns a Link instance');
723726

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

@@ -753,7 +756,7 @@ public function testInvalidLinks()
753756
public function testImage()
754757
{
755758
$crawler = $this->createTestCrawler('http://example.com/bar/')->selectImage('Bar');
756-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Image::class, $crawler->image(), '->image() returns an Image instance');
759+
$this->assertInstanceOf(Image::class, $crawler->image(), '->image() returns an Image instance');
757760

758761
try {
759762
$this->createTestCrawler()->filterXPath('//ol')->image();
@@ -829,8 +832,8 @@ public function testForm()
829832
$testCrawler = $this->createTestCrawler('http://example.com/bar/');
830833
$crawler = $testCrawler->selectButton('FooValue');
831834
$crawler2 = $testCrawler->selectButton('FooBarValue');
832-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Form::class, $crawler->form(), '->form() returns a Form instance');
833-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Form::class, $crawler2->form(), '->form() returns a Form instance');
835+
$this->assertInstanceOf(Form::class, $crawler->form(), '->form() returns a Form instance');
836+
$this->assertInstanceOf(Form::class, $crawler2->form(), '->form() returns a Form instance');
834837

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

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)