Skip to content

Commit 58db19a

Browse files
committed
Use PHPUnit\Framework\TestCase instead of PHPUnit_Framework_TestCase
1 parent e7f8f5b commit 58db19a

10 files changed

Lines changed: 43 additions & 19 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"require-dev": {
1616
"clue/block-react": "^1.2",
17-
"phpunit/phpunit": "^5.0 || ^4.8.10"
17+
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
1818
},
1919
"autoload": {
2020
"psr-4": { "React\\Dns\\": "src" }

tests/Config/FilesystemFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace React\Test\Dns\Config;
44

5+
use PHPUnit\Framework\TestCase;
56
use React\Dns\Config\FilesystemFactory;
67

7-
class FilesystemFactoryTest extends \PHPUnit_Framework_TestCase
8+
class FilesystemFactoryTest extends TestCase
89
{
910
/** @test */
1011
public function parseEtcResolvConfShouldParseCorrectly()

tests/Model/MessageTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace React\Tests\Dns\Model;
44

5+
use PHPUnit\Framework\TestCase;
56
use React\Dns\Query\Query;
67
use React\Dns\Model\Message;
78

8-
class MessageTest extends \PHPUnit_Framework_TestCase
9+
class MessageTest extends TestCase
910
{
1011
public function testCreateRequestDesiresRecusion()
1112
{

tests/Protocol/BinaryDumperTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace React\Tests\Dns\Protocol;
44

5+
use PHPUnit\Framework\TestCase;
56
use React\Dns\Protocol\BinaryDumper;
67
use React\Dns\Model\Message;
78

8-
class BinaryDumperTest extends \PHPUnit_Framework_TestCase
9+
class BinaryDumperTest extends TestCase
910
{
1011
public function testRequestToBinary()
1112
{

tests/Protocol/ParserTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace React\Tests\Dns\Protocol;
44

5+
use PHPUnit\Framework\TestCase;
56
use React\Dns\Protocol\Parser;
67
use React\Dns\Model\Message;
78

8-
class ParserTest extends \PHPUnit_Framework_TestCase
9+
class ParserTest extends TestCase
910
{
1011
public function setUp()
1112
{

tests/Query/ExecutorTest.php

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,24 @@ public function queryShouldCreateUdpRequest()
4646
$this->executor->query('8.8.8.8:53', $query);
4747
}
4848

49-
/** @test */
49+
/**
50+
* @test
51+
* @expectedException RuntimeException
52+
*/
5053
public function resolveShouldRejectIfRequestIsLargerThan512Bytes()
5154
{
5255
$query = new Query(str_repeat('a', 512).'.igor.io', Message::TYPE_A, Message::CLASS_IN, 1345656451);
5356
$promise = $this->executor->query('8.8.8.8:53', $query);
5457

55-
$this->setExpectedException('RuntimeException', 'DNS query for ' . $query->name . ' failed: Requested transport "tcp" not available, only UDP is supported in this version');
58+
$this->expectExceptionMessage('DNS query for ' . $query->name . ' failed: Requested transport "tcp" not available, only UDP is supported in this version');
5659
Block\await($promise, $this->loop);
5760
}
5861

59-
/** @test */
62+
/**
63+
* @test
64+
* @expectedException React\Dns\Query\CancellationException
65+
* @expectedExceptionMessage DNS query for igor.io has been cancelled
66+
*/
6067
public function resolveShouldCloseConnectionWhenCancelled()
6168
{
6269
$conn = $this->createConnectionMock(false);
@@ -80,11 +87,14 @@ public function resolveShouldCloseConnectionWhenCancelled()
8087

8188
$promise->cancel();
8289

83-
$this->setExpectedException('React\Dns\Query\CancellationException', 'DNS query for igor.io has been cancelled');
8490
Block\await($promise, $this->loop);
8591
}
8692

87-
/** @test */
93+
/**
94+
* @test
95+
* @expectedException React\Dns\Query\CancellationException
96+
* @expectedExceptionMessage DNS query for igor.io has been cancelled
97+
*/
8898
public function resolveShouldNotStartOrCancelTimerWhenCancelledWithTimeoutIsNull()
8999
{
90100
$this->loop
@@ -98,7 +108,6 @@ public function resolveShouldNotStartOrCancelTimerWhenCancelledWithTimeoutIsNull
98108

99109
$promise->cancel();
100110

101-
$this->setExpectedException('React\Dns\Query\CancellationException', 'DNS query for igor.io has been cancelled');
102111
Block\await($promise, $this->loop);
103112
}
104113

@@ -128,7 +137,11 @@ public function resolveShouldRejectIfResponseIsTruncated()
128137
$this->executor->query('8.8.8.8:53', $query);
129138
}
130139

131-
/** @test */
140+
/**
141+
* @test
142+
* @expectedException RuntimeException
143+
* @expectedExceptionMessage DNS query for igor.io failed: Nope
144+
*/
132145
public function resolveShouldFailIfUdpThrow()
133146
{
134147
$this->loop
@@ -149,7 +162,6 @@ public function resolveShouldFailIfUdpThrow()
149162
$query = new Query('igor.io', Message::TYPE_A, Message::CLASS_IN, 1345656451);
150163
$promise = $this->executor->query('8.8.8.8:53', $query);
151164

152-
$this->setExpectedException('RuntimeException', 'DNS query for igor.io failed: Nope');
153165
Block\await($promise, $this->loop);
154166
}
155167

@@ -188,7 +200,11 @@ public function resolveShouldCancelTimerWhenFullResponseIsReceived()
188200
$this->executor->query('8.8.8.8:53', $query);
189201
}
190202

191-
/** @test */
203+
/**
204+
* @test
205+
* @expectedException React\Dns\Query\TimeoutException
206+
* @expectedExceptionMessage DNS query for igor.io timed out
207+
*/
192208
public function resolveShouldCloseConnectionOnTimeout()
193209
{
194210
$this->executor = $this->createExecutorMock();
@@ -218,7 +234,6 @@ public function resolveShouldCloseConnectionOnTimeout()
218234
$this->assertNotNull($timerCallback);
219235
$timerCallback();
220236

221-
$this->setExpectedException('React\Dns\Query\TimeoutException', 'DNS query for igor.io timed out');
222237
Block\await($promise, $this->loop);
223238
}
224239

tests/Query/RecordBagTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
namespace React\Tests\Dns\Query;
44

5+
use PHPUnit\Framework\TestCase;
56
use React\Dns\Query\RecordBag;
67
use React\Dns\Model\Message;
78
use React\Dns\Model\Record;
89

9-
class RecordBagTest extends \PHPUnit_Framework_TestCase
10+
class RecordBagTest extends TestCase
1011
{
1112
/**
1213
* @covers React\Dns\Query\RecordBag

tests/Query/RecordCacheTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace React\Tests\Dns\Query;
44

5+
use PHPUnit\Framework\TestCase;
56
use React\Cache\ArrayCache;
67
use React\Dns\Model\Message;
78
use React\Dns\Model\Record;
89
use React\Dns\Query\RecordCache;
910
use React\Dns\Query\Query;
1011
use React\Promise\PromiseInterface;
1112

12-
class RecordCacheTest extends \PHPUnit_Framework_TestCase
13+
class RecordCacheTest extends TestCase
1314
{
1415
/**
1516
* @covers React\Dns\Query\RecordCache

tests/Resolver/ResolveAliasesTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
namespace React\Tests\Dns\Resolver;
44

5+
use PHPUnit\Framework\TestCase;
56
use React\Dns\Resolver\Resolver;
67
use React\Dns\Query\Query;
78
use React\Dns\Model\Message;
89
use React\Dns\Model\Record;
910

10-
class ResolveAliasesTest extends \PHPUnit_Framework_TestCase
11+
class ResolveAliasesTest extends TestCase
1112
{
1213
/**
1314
* @covers React\Dns\Resolver\Resolver::resolveAliases

tests/TestCase.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace React\Tests\Dns;
44

5-
abstract class TestCase extends \PHPUnit_Framework_TestCase
5+
use PHPUnit\Framework\TestCase as BaseTestCase;
6+
7+
abstract class TestCase extends BaseTestCase
68
{
79
protected function expectCallableOnce()
810
{

0 commit comments

Comments
 (0)