Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions tests/Query/ExecutorTest.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -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')
Expand DownExpand Up@@ -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')
Expand DownExpand Up@@ -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())
Expand DownExpand Up@@ -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())
Expand All@@ -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())
Expand DownExpand Up@@ -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')
Expand Down