diff --git a/tests/Query/ExecutorTest.php b/tests/Query/ExecutorTest.php index 5ddba698..ff2d4d2f 100644 --- a/tests/Query/ExecutorTest.php +++ b/tests/Query/ExecutorTest.php @@ -29,7 +29,7 @@ public function setUp() /** @test */ public function queryShouldCreateUdpRequest() { - $timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock(); + $timer = $this->createTimerMock(); $this->loop ->expects($this->any()) ->method('addTimer') @@ -62,7 +62,7 @@ public function resolveShouldCloseConnectionWhenCancelled() $conn = $this->createConnectionMock(false); $conn->expects($this->once())->method('close'); - $timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock(); + $timer = $this->createTimerMock(); $this->loop ->expects($this->any()) ->method('addTimer') @@ -105,7 +105,7 @@ public function resolveShouldNotStartOrCancelTimerWhenCancelledWithTimeoutIsNull /** @test */ public function resolveShouldRejectIfResponseIsTruncated() { - $timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock(); + $timer = $this->createTimerMock(); $this->loop ->expects($this->any()) @@ -171,7 +171,7 @@ public function resolveShouldCancelTimerWhenFullResponseIsReceived() ->will($this->returnNewConnectionMock()); - $timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock(); + $timer = $this->createTimerMock(); $this->loop ->expects($this->once()) @@ -198,10 +198,11 @@ public function resolveShouldCloseConnectionOnTimeout() ->with('8.8.8.8:53', 'udp') ->will($this->returnNewConnectionMock(false)); - $timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock(); - $timer + $timer = $this->createTimerMock(); + + $this->loop ->expects($this->never()) - ->method('cancel'); + ->method('cancelTimer'); $this->loop ->expects($this->once()) @@ -290,6 +291,13 @@ private function createConnectionMock($emitData = true) return $conn; } + private function createTimerMock() + { + return $this->getMockBuilder( + interface_exists('React\EventLoop\TimerInterface') ? 'React\EventLoop\TimerInterface' : 'React\EventLoop\Timer\TimerInterface' + )->getMock(); + } + private function createExecutorMock() { return $this->getMockBuilder('React\Dns\Query\Executor')