Skip to content

Commit dafa8b4

Browse files
committed
Update to PHPUnit 6
1 parent 1b39fa0 commit dafa8b4

15 files changed

+59
-50
lines changed

tests/CollectionTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
use PHPHtmlParser\Dom\HtmlNode;
55
use PHPHtmlParser\Dom\Tag;
66
use PHPHtmlParser\Dom\Collection;
7+
use PHPUnit\Framework\TestCase;
78

8-
class CollectionTest extends PHPUnit_Framework_TestCase {
9+
class CollectionTest extends TestCase {
910

1011
public function testEach()
1112
{
@@ -29,10 +30,10 @@ public function testEach()
2930
}
3031

3132
/**
32-
* @expectedException PHPHtmlParser\Exceptions\EmptyCollectionException
3333
*/
3434
public function testCallNoNodes()
3535
{
36+
$this->expectException('PHPHtmlParser\Exceptions\EmptyCollectionException');
3637
$collection = new Collection();
3738
$collection->innerHtml();
3839
}
@@ -70,10 +71,10 @@ public function testGetMagic()
7071
}
7172

7273
/**
73-
* @expectedException PHPHtmlParser\Exceptions\EmptyCollectionException
7474
*/
7575
public function testGetNoNodes()
7676
{
77+
$this->expectException('PHPHtmlParser\Exceptions\EmptyCollectionException');
7778
$collection = new Collection();
7879
$collection->innerHtml;
7980
}

tests/ContentTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
use PHPHtmlParser\Content;
4+
use PHPUnit\Framework\TestCase;
45

5-
class ContentTest extends PHPUnit_Framework_TestCase {
6+
class ContentTest extends TestCase {
67

78
public function testChar()
89
{

tests/DomTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
22

33
use PHPHtmlParser\Dom;
4+
use PHPHtmlParser\Exceptions\NotLoadedException;
5+
use PHPUnit\Framework\TestCase;
46

5-
class DomTest extends PHPUnit_Framework_TestCase {
7+
class DomTest extends TestCase {
68

79
public function tearDown()
810
{
@@ -17,11 +19,9 @@ public function testLoad()
1719
$this->assertEquals('<div class="all"><p>Hey bro, <a href="google.com">click here</a><br /> :)</p></div>', $div->outerHtml);
1820
}
1921

20-
/**
21-
* @expectedException PHPHtmlParser\Exceptions\NotLoadedException
22-
*/
2322
public function testNotLoaded()
2423
{
24+
$this->expectException(NotLoadedException::class);
2525
$dom = new Dom;
2626
$div = $dom->find('div', 0);
2727
}

tests/Node/ChildrenTest.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<?php
22

33
use PHPHtmlParser\Dom\MockNode as Node;
4+
use PHPHtmlParser\Exceptions\ChildNotFoundException;
5+
use PHPHtmlParser\Exceptions\ParentNotFoundException;
6+
use PHPUnit\Framework\TestCase;
47

5-
class NodeChildTest extends PHPUnit_Framework_TestCase {
8+
class NodeChildTest extends TestCase {
69

710
public function testGetParent()
811
{
@@ -32,22 +35,20 @@ public function testNextSibling()
3235
$this->assertEquals($child2->id(), $child->nextSibling()->id());
3336
}
3437

35-
/**
36-
* @expectedException PHPHtmlParser\Exceptions\ChildNotFoundException
37-
*/
3838
public function testNextSiblingNotFound()
3939
{
40+
$this->expectException(ChildNotFoundException::class);
41+
4042
$parent = new Node;
4143
$child = new Node;
4244
$child->setParent($parent);
4345
$child->nextSibling();
4446
}
4547

46-
/**
47-
* @expectedException PHPHtmlParser\Exceptions\ParentNotFoundException
48-
*/
4948
public function testNextSiblingNoParent()
5049
{
50+
$this->expectException(ParentNotFoundException::class);
51+
5152
$child = new Node;
5253
$child->nextSibling();
5354
}
@@ -62,22 +63,20 @@ public function testPreviousSibling()
6263
$this->assertEquals($child->id(), $child2->previousSibling()->id());
6364
}
6465

65-
/**
66-
* @expectedException PHPHtmlParser\Exceptions\ChildNotFoundException
67-
*/
6866
public function testPreviousSiblingNotFound()
6967
{
68+
$this->expectException(ChildNotFoundException::class);
69+
7070
$parent = new Node;
7171
$node = new Node;
7272
$node->setParent($parent);
7373
$node->previousSibling();
7474
}
7575

76-
/**
77-
* @expectedException PHPHtmlParser\Exceptions\ParentNotFoundException
78-
*/
7976
public function testPreviousSiblingNoParent()
8077
{
78+
$this->expectException(ParentNotFoundException::class);
79+
8180
$child = new Node;
8281
$child->previousSibling();
8382
}

tests/Node/HtmlTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
use PHPHtmlParser\Dom\TextNode;
66
use PHPHtmlParser\Dom\MockNode;
77
use PHPHtmlParser\Dom\Tag;
8+
use PHPHtmlParser\Exceptions\ParentNotFoundException;
9+
use PHPHtmlParser\Exceptions\UnknownChildTypeException;
10+
use PHPUnit\Framework\TestCase;
811

9-
class NodeHtmlTest extends PHPUnit_Framework_TestCase {
12+
class NodeHtmlTest extends TestCase {
1013

1114
public function testInnerHtml()
1215
{
@@ -65,11 +68,10 @@ public function testInnerHtmlTwice()
6568
$this->assertEquals($inner, $parent->innerHtml());
6669
}
6770

68-
/**
69-
* @expectedException PHPHtmlParser\Exceptions\UnknownChildTypeException
70-
*/
7171
public function testInnerHtmlUnkownChild()
7272
{
73+
$this->expectException(UnknownChildTypeException::class);
74+
7375
$div = new Tag('div');
7476
$div->setAttributes([
7577
'class' => [
@@ -447,11 +449,10 @@ public function testIterator()
447449
$this->assertEquals(2, $children);
448450
}
449451

450-
/**
451-
* @expectedException PHPHtmlParser\Exceptions\ParentNotFoundException
452-
*/
453452
public function testAncestorByTagFailure()
454453
{
454+
$this->expectException(ParentNotFoundException::class);
455+
455456
$a = new Tag('a');
456457
$node = new HtmlNode($a);
457458
$node->ancestorByTag('div');

tests/Node/ParentTest.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
22

33
use PHPHtmlParser\Dom\MockNode as Node;
4+
use PHPHtmlParser\Exceptions\CircularException;
5+
use PHPUnit\Framework\TestCase;
46

5-
class NodeParentTest extends PHPUnit_Framework_TestCase {
7+
class NodeParentTest extends TestCase {
68

79
public function testHasChild()
810
{
@@ -150,33 +152,30 @@ public function testReplaceChild()
150152
$this->assertFalse($parent->isChild($child->id()));
151153
}
152154

153-
/**
154-
* @expectedException PHPHtmlParser\Exceptions\CircularException
155-
*/
156155
public function testSetParentDescendantException()
157156
{
157+
$this->expectException(CircularException::class);
158+
158159
$parent = new Node;
159160
$child = new Node;
160161
$parent->addChild($child);
161162
$parent->setParent($child);
162163
}
163164

164-
/**
165-
* @expectedException PHPHtmlParser\Exceptions\CircularException
166-
*/
167165
public function testAddChildAncestorException()
168166
{
167+
$this->expectException(CircularException::class);
168+
169169
$parent = new Node;
170170
$child = new Node;
171171
$parent->addChild($child);
172172
$child->addChild($parent);
173173
}
174174

175-
/**
176-
* @expectedException PHPHtmlParser\Exceptions\CircularException
177-
*/
178175
public function testAddItselfAsChild()
179176
{
177+
$this->expectException(CircularException::class);
178+
180179
$parent = new Node;
181180
$parent->addChild($parent);
182181
}

tests/Node/TagTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
use PHPHtmlParser\Dom\Tag;
4+
use PHPUnit\Framework\TestCase;
45

5-
class NodeTagTest extends PHPUnit_Framework_TestCase {
6+
class NodeTagTest extends TestCase {
67

78
public function testSelfClosing()
89
{

tests/Node/TextTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
use PHPHtmlParser\Dom\TextNode;
4+
use PHPUnit\Framework\TestCase;
45

5-
class NodeTextTest extends PHPUnit_Framework_TestCase {
6+
class NodeTextTest extends TestCase {
67

78
public function testText()
89
{

tests/Options/CleanupTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
use PHPHtmlParser\Dom;
4+
use PHPUnit\Framework\TestCase;
45

5-
class CleanupTest extends PHPUnit_Framework_TestCase {
6+
class CleanupTest extends TestCase {
67

78
public function testCleanupInputTrue()
89
{

tests/Options/PreserveLineBreaks.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
use PHPHtmlParser\Dom;
4+
use PHPUnit\Framework\TestCase;
45

5-
class PreserveLineBreaks extends PHPUnit_Framework_TestCase {
6+
class PreserveLineBreaks extends TestCase {
67

78
public function testPreserveLineBreakTrue()
89
{

0 commit comments

Comments
 (0)