Skip to content

Commit c0112fc

Browse files
committed
Fix deprecated phpunit annotation
1 parent 7152b55 commit c0112fc

File tree

4 files changed

+27
-48
lines changed

4 files changed

+27
-48
lines changed

Tests/CrawlerTest.php

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,17 @@ public function testAdd()
7272
$this->assertEquals('Foo', $crawler->filterXPath('//body')->text(), '->add() adds nodes from a string');
7373
}
7474

75-
/**
76-
* @expectedException \InvalidArgumentException
77-
*/
7875
public function testAddInvalidType()
7976
{
77+
$this->expectException('InvalidArgumentException');
8078
$crawler = new Crawler();
8179
$crawler->add(1);
8280
}
8381

84-
/**
85-
* @expectedException \InvalidArgumentException
86-
* @expectedExceptionMessage Attaching DOM nodes from multiple documents in the same crawler is forbidden.
87-
*/
8882
public function testAddMultipleDocumentNode()
8983
{
84+
$this->expectException('InvalidArgumentException');
85+
$this->expectExceptionMessage('Attaching DOM nodes from multiple documents in the same crawler is forbidden.');
9086
$crawler = $this->createTestCrawler();
9187
$crawler->addHtmlContent('<html><div class="foo"></html>', 'UTF-8');
9288
}
@@ -772,22 +768,18 @@ public function testLink()
772768
}
773769
}
774770

775-
/**
776-
* @expectedException \InvalidArgumentException
777-
* @expectedExceptionMessage The selected node should be instance of DOMElement
778-
*/
779771
public function testInvalidLink()
780772
{
773+
$this->expectException('InvalidArgumentException');
774+
$this->expectExceptionMessage('The selected node should be instance of DOMElement');
781775
$crawler = $this->createTestCrawler('http://example.com/bar/');
782776
$crawler->filterXPath('//li/text()')->link();
783777
}
784778

785-
/**
786-
* @expectedException \InvalidArgumentException
787-
* @expectedExceptionMessage The selected node should be instance of DOMElement
788-
*/
789779
public function testInvalidLinks()
790780
{
781+
$this->expectException('InvalidArgumentException');
782+
$this->expectExceptionMessage('The selected node should be instance of DOMElement');
791783
$crawler = $this->createTestCrawler('http://example.com/bar/');
792784
$crawler->filterXPath('//li/text()')->link();
793785
}
@@ -889,12 +881,10 @@ public function testForm()
889881
}
890882
}
891883

892-
/**
893-
* @expectedException \InvalidArgumentException
894-
* @expectedExceptionMessage The selected node should be instance of DOMElement
895-
*/
896884
public function testInvalidForm()
897885
{
886+
$this->expectException('InvalidArgumentException');
887+
$this->expectExceptionMessage('The selected node should be instance of DOMElement');
898888
$crawler = $this->createTestCrawler('http://example.com/bar/');
899889
$crawler->filterXPath('//li/text()')->form();
900890
}
@@ -1002,7 +992,7 @@ public function testChildren()
1002992
$this->assertTrue(true, '->children() does not trigger a notice if the node has no children');
1003993
} catch (\PHPUnit\Framework\Error\Notice $e) {
1004994
$this->fail('->children() does not trigger a notice if the node has no children');
1005-
} catch (\PHPUnit_Framework_Error_Notice $e) {
995+
} catch (\PHPUnit\Framework\Error\Notice $e) {
1006996
$this->fail('->children() does not trigger a notice if the node has no children');
1007997
}
1008998
}
@@ -1112,11 +1102,9 @@ public function testEvaluateReturnsACrawlerIfXPathExpressionEvaluatesToANode()
11121102
$this->assertSame('input', $crawler->first()->nodeName());
11131103
}
11141104

1115-
/**
1116-
* @expectedException \LogicException
1117-
*/
11181105
public function testEvaluateThrowsAnExceptionIfDocumentIsEmpty()
11191106
{
1107+
$this->expectException('LogicException');
11201108
(new Crawler())->evaluate('//form/input[1]');
11211109
}
11221110

Tests/FormTest.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ public function testConstructorThrowsExceptionIfTheNodeHasNoFormAncestor()
6767

6868
/**
6969
* __construct() should throw \\LogicException if the form attribute is invalid.
70-
*
71-
* @expectedException \LogicException
7270
*/
7371
public function testConstructorThrowsExceptionIfNoRelatedForm()
7472
{
73+
$this->expectException('LogicException');
7574
$dom = new \DOMDocument();
7675
$dom->loadHTML('
7776
<html>
@@ -717,20 +716,16 @@ public function testFormFieldRegistryAcceptAnyNames()
717716
$registry->remove('[t:dbt%3adate;]data_daterange_enddate_value');
718717
}
719718

720-
/**
721-
* @expectedException \InvalidArgumentException
722-
*/
723719
public function testFormFieldRegistryGetThrowAnExceptionWhenTheFieldDoesNotExist()
724720
{
721+
$this->expectException('InvalidArgumentException');
725722
$registry = new FormFieldRegistry();
726723
$registry->get('foo');
727724
}
728725

729-
/**
730-
* @expectedException \InvalidArgumentException
731-
*/
732726
public function testFormFieldRegistrySetThrowAnExceptionWhenTheFieldDoesNotExist()
733727
{
728+
$this->expectException('InvalidArgumentException');
734729
$registry = new FormFieldRegistry();
735730
$registry->set('foo', null);
736731
}
@@ -807,24 +802,20 @@ public function testFormRegistrySetValues()
807802
]);
808803
}
809804

810-
/**
811-
* @expectedException \InvalidArgumentException
812-
* @expectedExceptionMessage Cannot set value on a compound field "foo[bar]".
813-
*/
814805
public function testFormRegistrySetValueOnCompoundField()
815806
{
807+
$this->expectException('InvalidArgumentException');
808+
$this->expectExceptionMessage('Cannot set value on a compound field "foo[bar]".');
816809
$registry = new FormFieldRegistry();
817810
$registry->add($this->getFormFieldMock('foo[bar][baz]'));
818811

819812
$registry->set('foo[bar]', 'fbb');
820813
}
821814

822-
/**
823-
* @expectedException \InvalidArgumentException
824-
* @expectedExceptionMessage Unreachable field "0"
825-
*/
826815
public function testFormRegistrySetArrayOnNotCompoundField()
827816
{
817+
$this->expectException('InvalidArgumentException');
818+
$this->expectExceptionMessage('Unreachable field "0"');
828819
$registry = new FormFieldRegistry();
829820
$registry->add($this->getFormFieldMock('bar'));
830821

Tests/ImageTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\DomCrawler\Image;
1617

1718
class ImageTest extends TestCase
1819
{
19-
/**
20-
* @expectedException \LogicException
21-
*/
20+
use ForwardCompatTestTrait;
21+
2222
public function testConstructorWithANonImgTag()
2323
{
24+
$this->expectException('LogicException');
2425
$dom = new \DOMDocument();
2526
$dom->loadHTML('<html><div><div></html>');
2627

Tests/LinkTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\DomCrawler\Link;
1617

1718
class LinkTest extends TestCase
1819
{
19-
/**
20-
* @expectedException \LogicException
21-
*/
20+
use ForwardCompatTestTrait;
21+
2222
public function testConstructorWithANonATag()
2323
{
24+
$this->expectException('LogicException');
2425
$dom = new \DOMDocument();
2526
$dom->loadHTML('<html><div><div></html>');
2627

2728
new Link($dom->getElementsByTagName('div')->item(0), 'http://www.example.com/');
2829
}
2930

30-
/**
31-
* @expectedException \InvalidArgumentException
32-
*/
3331
public function testConstructorWithAnInvalidCurrentUri()
3432
{
33+
$this->expectException('InvalidArgumentException');
3534
$dom = new \DOMDocument();
3635
$dom->loadHTML('<html><a href="/foo">foo</a></html>');
3736

0 commit comments

Comments
 (0)