Skip to content

Commit 9d38e3c

Browse files
authored
Merge pull request #85 from carusogabriel/phpunit
Forward compatibility with PHPUnit 6
2 parents e7f8f5b + b0b76d6 commit 9d38e3c

9 files changed

Lines changed: 35 additions & 9 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/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: 20 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
{
@@ -39,4 +41,21 @@ protected function createCallableMock()
3941
{
4042
return $this->getMockBuilder('React\Tests\Dns\CallableStub')->getMock();
4143
}
44+
45+
public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
46+
{
47+
if (method_exists($this, 'expectException')) {
48+
// PHPUnit 5
49+
$this->expectException($exception);
50+
if ($exceptionMessage !== '') {
51+
$this->expectExceptionMessage($exceptionMessage);
52+
}
53+
if ($exceptionCode !== null) {
54+
$this->expectExceptionCode($exceptionCode);
55+
}
56+
} else {
57+
// legacy PHPUnit 4
58+
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
59+
}
60+
}
4261
}

0 commit comments

Comments
 (0)