@@ -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