diff --git a/composer.json b/composer.json index 22f07d97..1adf0562 100644 --- a/composer.json +++ b/composer.json @@ -33,8 +33,8 @@ "react/promise-timer": "^1.9" }, "require-dev": { - "clue/block-react": "^1.2", - "phpunit/phpunit": "^9.3 || ^4.8.35" + "phpunit/phpunit": "^9.3 || ^4.8.35", + "react/async": "^4 || ^3 || ^2" }, "autoload": { "psr-4": { "React\\Dns\\": "src" } diff --git a/tests/Query/TcpTransportExecutorTest.php b/tests/Query/TcpTransportExecutorTest.php index 583c5ce0..202fdbce 100644 --- a/tests/Query/TcpTransportExecutorTest.php +++ b/tests/Query/TcpTransportExecutorTest.php @@ -266,9 +266,9 @@ function ($e) use (&$exception) { } ); - \Clue\React\Block\sleep(0.01); + \React\Async\await(\React\Promise\Timer\sleep(0.01)); if ($exception === null) { - \Clue\React\Block\sleep(0.2); + \React\Async\await(\React\Promise\Timer\sleep(0.2)); } /** @var \RuntimeException $exception */ @@ -437,9 +437,9 @@ function ($e) use (&$exception) { } ); - \Clue\React\Block\sleep(0.01); + \React\Async\await(\React\Promise\Timer\sleep(0.01)); if ($exception === null) { - \Clue\React\Block\sleep(0.2); + \React\Async\await(\React\Promise\Timer\sleep(0.2)); } /** @var \RuntimeException $exception */ @@ -476,7 +476,7 @@ function ($e) use (&$wait) { } ); - \Clue\React\Block\sleep(0.2); + \React\Async\await(\React\Promise\Timer\sleep(0.2)); $this->assertTrue($wait); $this->assertNotNull($client); @@ -513,7 +513,7 @@ function ($e) use (&$wait) { } ); - \Clue\React\Block\sleep(0.2); + \React\Async\await(\React\Promise\Timer\sleep(0.2)); $this->assertTrue($wait); $this->assertNotNull($client); @@ -548,9 +548,9 @@ function ($e) use (&$exception) { } ); - \Clue\React\Block\sleep(0.01); + \React\Async\await(\React\Promise\Timer\sleep(0.01)); if ($exception === null) { - \Clue\React\Block\sleep(0.2); + \React\Async\await(\React\Promise\Timer\sleep(0.2)); } /** @var \RuntimeException $exception */ @@ -600,9 +600,9 @@ function ($e) use (&$exception) { } ); - \Clue\React\Block\sleep(0.01); + \React\Async\await(\React\Promise\Timer\sleep(0.01)); if ($exception === null) { - \Clue\React\Block\sleep(0.2); + \React\Async\await(\React\Promise\Timer\sleep(0.2)); } /** @var \RuntimeException $exception */ @@ -652,9 +652,9 @@ function ($e) use (&$exception) { } ); - \Clue\React\Block\sleep(0.01); + \React\Async\await(\React\Promise\Timer\sleep(0.01)); if ($exception === null) { - \Clue\React\Block\sleep(0.2); + \React\Async\await(\React\Promise\Timer\sleep(0.2)); } /** @var \RuntimeException $exception */ @@ -687,7 +687,7 @@ public function testQueryResolvesIfServerSendsValidResponse() $query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN); $promise = $executor->query($query); - $response = \Clue\React\Block\await($promise, null, 0.2); + $response = \React\Async\await(\React\Promise\Timer\timeout($promise, 0.2)); $this->assertInstanceOf('React\Dns\Model\Message', $response); } diff --git a/tests/Query/TimeoutExecutorTest.php b/tests/Query/TimeoutExecutorTest.php index f413f331..bab6d616 100644 --- a/tests/Query/TimeoutExecutorTest.php +++ b/tests/Query/TimeoutExecutorTest.php @@ -113,7 +113,8 @@ public function testWrappedWillBeCancelledOnTimeout() $this->assertEquals(0, $cancelled); try { - \Clue\React\Block\await($promise); + \React\Async\await(\React\Promise\Timer\sleep(0)); + \React\Async\await($promise); $this->fail(); } catch (TimeoutException $exception) { $this->assertEquals('DNS query for igor.io (A) timed out' , $exception->getMessage()); diff --git a/tests/Query/UdpTransportExecutorTest.php b/tests/Query/UdpTransportExecutorTest.php index 066bfcf6..81cf9497 100644 --- a/tests/Query/UdpTransportExecutorTest.php +++ b/tests/Query/UdpTransportExecutorTest.php @@ -273,7 +273,7 @@ function ($e) use (&$wait) { } ); - \Clue\React\Block\sleep(0.2); + \React\Async\await(\React\Promise\Timer\sleep(0.2)); $this->assertTrue($wait); $promise->cancel(); @@ -311,7 +311,7 @@ function ($e) use (&$wait) { } ); - \Clue\React\Block\sleep(0.2); + \React\Async\await(\React\Promise\Timer\sleep(0.2)); $this->assertTrue($wait); $promise->cancel(); @@ -347,7 +347,7 @@ public function testQueryRejectsIfServerSendsTruncatedResponse() 'DNS query for google.com (A) failed: The DNS server udp://' . $address . ' returned a truncated result for a UDP query', defined('SOCKET_EMSGSIZE') ? SOCKET_EMSGSIZE : 90 ); - \Clue\React\Block\await($promise, null, 0.1); + \React\Async\await(\React\Promise\Timer\timeout($promise, 0.1)); } public function testQueryResolvesIfServerSendsValidResponse() @@ -373,7 +373,7 @@ public function testQueryResolvesIfServerSendsValidResponse() $query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN); $promise = $executor->query($query); - $response = \Clue\React\Block\await($promise, null, 0.2); + $response = \React\Async\await(\React\Promise\Timer\timeout($promise, 0.2)); $this->assertInstanceOf('React\Dns\Model\Message', $response); }