Skip to content

Commit 6b97970

Browse files
committed
Forward compatibility with PHPUnit 7 and PHPUnit 6
1 parent 563cf67 commit 6b97970

4 files changed

Lines changed: 24 additions & 8 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
},
3030
"require-dev": {
3131
"clue/block-react": "~1.0",
32-
"phpunit/phpunit": "^5.0 || ^4.8"
32+
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35"
3333
}
3434
}

tests/FactoryTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public function testCreateClientLocalhostWithDefaultResolver()
6464
$promise = $this->factory->createClient('localhost:12345');
6565

6666
$capturedClient = Block\await($promise, $this->loop);
67+
$this->assertInstanceOf('React\Datagram\SocketInterface', $capturedClient);
68+
6769
$capturedClient->close();
6870
}
6971

@@ -131,11 +133,13 @@ public function testCreateClientWithHostnameWillUseResolver()
131133
$client->close();
132134
}
133135

136+
/**
137+
* @expectedException RuntimeException
138+
*/
134139
public function testCreateClientWithHostnameWillRejectIfResolverRejects()
135140
{
136141
$this->resolver->expects($this->once())->method('resolve')->with('example.com')->willReturn(Promise\reject(new \RuntimeException('test')));
137142

138-
$this->setExpectedException('RuntimeException');
139143
Block\await($this->factory->createClient('example.com:0'), $this->loop);
140144
}
141145

@@ -157,6 +161,9 @@ public function testCreateServerWithInvalidHostnameWillReject()
157161
Block\await($this->factory->createServer('/////'), $this->loop);
158162
}
159163

164+
/**
165+
* @expectedException RuntimeException
166+
*/
160167
public function testCancelCreateClientWithCancellableHostnameResolver()
161168
{
162169
$promise = new Promise\Promise(function () { }, $this->expectCallableOnce());
@@ -165,10 +172,12 @@ public function testCancelCreateClientWithCancellableHostnameResolver()
165172
$promise = $this->factory->createClient('example.com:0');
166173
$promise->cancel();
167174

168-
$this->setExpectedException('RuntimeException');
169175
Block\await($promise, $this->loop);
170176
}
171177

178+
/**
179+
* @expectedException RuntimeException
180+
*/
172181
public function testCancelCreateClientWithUncancellableHostnameResolver()
173182
{
174183
$promise = $this->getMockBuilder('React\Promise\PromiseInterface')->getMock();
@@ -177,7 +186,6 @@ public function testCancelCreateClientWithUncancellableHostnameResolver()
177186
$promise = $this->factory->createClient('example.com:0');
178187
$promise->cancel();
179188

180-
$this->setExpectedException('RuntimeException');
181189
Block\await($promise, $this->loop);
182190
}
183191
}

tests/SocketTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public function setUp()
1616
$this->factory = new \React\Datagram\Factory($this->loop, $this->createResolverMock());
1717
}
1818

19+
/**
20+
* @doesNotPerformAssertions
21+
*/
1922
public function testCreateClientCloseWillNotBlock()
2023
{
2124
$promise = $this->factory->createClient('127.0.0.1:12345');
@@ -30,7 +33,7 @@ public function testCreateClientCloseWillNotBlock()
3033
}
3134

3235
/**
33-
*
36+
* @doesNotPerformAssertions
3437
* @param Socket $client
3538
* @depends testCreateClientCloseWillNotBlock
3639
*/
@@ -40,6 +43,9 @@ public function testClientCloseAgainWillNotBlock(Socket $client)
4043
$this->loop->run();
4144
}
4245

46+
/**
47+
* @doesNotPerformAssertions
48+
*/
4349
public function testCreateClientEndWillNotBlock()
4450
{
4551
$promise = $this->factory->createClient('127.0.0.1:12345');
@@ -54,7 +60,7 @@ public function testCreateClientEndWillNotBlock()
5460
}
5561

5662
/**
57-
*
63+
* @doesNotPerformAssertions
5864
* @param Socket $client
5965
* @depends testCreateClientEndWillNotBlock
6066
*/
@@ -67,7 +73,7 @@ public function testClientEndAgainWillNotBlock(Socket $client)
6773
}
6874

6975
/**
70-
*
76+
* @doesNotPerformAssertions
7177
* @param Socket $client
7278
* @depends testClientEndAgainWillNotBlock
7379
*/

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\Datagram;
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)