Skip to content

Commit a4ae64d

Browse files
Merge branch '5.2' into 5.x
* 5.2: Use createMock() and use import instead of FQCN
2 parents a94f321 + 5d89ceb commit a4ae64d

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
@@ -14,6 +14,9 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1616
use Symfony\Component\DomCrawler\Crawler;
17+
use Symfony\Component\DomCrawler\Form;
18+
use Symfony\Component\DomCrawler\Image;
19+
use Symfony\Component\DomCrawler\Link;
1720

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

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

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

752755
try {
753756
$this->createTestCrawler()->filterXPath('//ol')->image();
@@ -823,8 +826,8 @@ public function testForm()
823826
$testCrawler = $this->createTestCrawler('http://example.com/bar/');
824827
$crawler = $testCrawler->selectButton('FooValue');
825828
$crawler2 = $testCrawler->selectButton('FooBarValue');
826-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Form::class, $crawler->form(), '->form() returns a Form instance');
827-
$this->assertInstanceOf(\Symfony\Component\DomCrawler\Form::class, $crawler2->form(), '->form() returns a Form instance');
829+
$this->assertInstanceOf(Form::class, $crawler->form(), '->form() returns a Form instance');
830+
$this->assertInstanceOf(Form::class, $crawler2->form(), '->form() returns a Form instance');
828831

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

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)