Skip to content

Commit 8c63b16

Browse files
authored
Merge pull request #88 from clue-labs/loop
Fix test suite forward compatibility with upcoming EventLoop releases
2 parents e05175d + df031c3 commit 8c63b16

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

tests/Query/ExecutorTest.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function setUp()
2929
/** @test */
3030
public function queryShouldCreateUdpRequest()
3131
{
32-
$timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock();
32+
$timer = $this->createTimerMock();
3333
$this->loop
3434
->expects($this->any())
3535
->method('addTimer')
@@ -62,7 +62,7 @@ public function resolveShouldCloseConnectionWhenCancelled()
6262
$conn = $this->createConnectionMock(false);
6363
$conn->expects($this->once())->method('close');
6464

65-
$timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock();
65+
$timer = $this->createTimerMock();
6666
$this->loop
6767
->expects($this->any())
6868
->method('addTimer')
@@ -105,7 +105,7 @@ public function resolveShouldNotStartOrCancelTimerWhenCancelledWithTimeoutIsNull
105105
/** @test */
106106
public function resolveShouldRejectIfResponseIsTruncated()
107107
{
108-
$timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock();
108+
$timer = $this->createTimerMock();
109109

110110
$this->loop
111111
->expects($this->any())
@@ -171,7 +171,7 @@ public function resolveShouldCancelTimerWhenFullResponseIsReceived()
171171
->will($this->returnNewConnectionMock());
172172

173173

174-
$timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock();
174+
$timer = $this->createTimerMock();
175175

176176
$this->loop
177177
->expects($this->once())
@@ -198,10 +198,11 @@ public function resolveShouldCloseConnectionOnTimeout()
198198
->with('8.8.8.8:53', 'udp')
199199
->will($this->returnNewConnectionMock(false));
200200

201-
$timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock();
202-
$timer
201+
$timer = $this->createTimerMock();
202+
203+
$this->loop
203204
->expects($this->never())
204-
->method('cancel');
205+
->method('cancelTimer');
205206

206207
$this->loop
207208
->expects($this->once())
@@ -290,6 +291,13 @@ private function createConnectionMock($emitData = true)
290291
return $conn;
291292
}
292293

294+
private function createTimerMock()
295+
{
296+
return $this->getMockBuilder(
297+
interface_exists('React\EventLoop\TimerInterface') ? 'React\EventLoop\TimerInterface' : 'React\EventLoop\Timer\TimerInterface'
298+
)->getMock();
299+
}
300+
293301
private function createExecutorMock()
294302
{
295303
return $this->getMockBuilder('React\Dns\Query\Executor')

0 commit comments

Comments
 (0)