diff --git a/composer.json b/composer.json index b732b01..e441cb6 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,8 @@ "react/stream": "^1.2" }, "require-dev": { - "clue/block-react": "^1.5", "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.36", + "react/async": "^4 || ^3 || ^2", "react/http": "^1.5", "react/mysql": "^0.5.5" }, diff --git a/tests/FunctionalSshProcessConnectorTest.php b/tests/FunctionalSshProcessConnectorTest.php index 1558630..1aaae23 100644 --- a/tests/FunctionalSshProcessConnectorTest.php +++ b/tests/FunctionalSshProcessConnectorTest.php @@ -3,7 +3,6 @@ namespace Clue\Tests\React\SshProxy; use Clue\React\SshProxy\SshProcessConnector; -use React\EventLoop\Loop; class FunctionalSshProcessConnectorTest extends TestCase { @@ -30,7 +29,7 @@ public function testConnectInvalidProxyUriWillReturnRejectedPromise() $promise = $this->connector->connect('example.com:80'); $this->setExpectedException('RuntimeException', 'Connection to example.com:80 failed because SSH client died'); - \Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT); + \React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT)); } public function testConnectInvalidTargetWillReturnRejectedPromise() @@ -38,7 +37,7 @@ public function testConnectInvalidTargetWillReturnRejectedPromise() $promise = $this->connector->connect('example.invalid:80'); $this->setExpectedException('RuntimeException', 'Connection to example.invalid:80 rejected:'); - \Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT); + \React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT)); } public function testCancelConnectWillReturnRejectedPromise() @@ -47,14 +46,14 @@ public function testCancelConnectWillReturnRejectedPromise() $promise->cancel(); $this->setExpectedException('RuntimeException', 'Connection to example.com:80 cancelled while waiting for SSH client'); - \Clue\React\Block\await($promise, Loop::get(), 0); + \React\Async\await(\React\Promise\Timer\timeout($promise, 0)); } public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection() { $promise = $this->connector->connect('example.com:80'); - $connection = \Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT); + $connection = \React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT)); $this->assertInstanceOf('React\Socket\ConnectionInterface', $connection); $this->assertTrue($connection->isReadable()); diff --git a/tests/FunctionalSshSocksConnectorTest.php b/tests/FunctionalSshSocksConnectorTest.php index a305361..57ec2a1 100644 --- a/tests/FunctionalSshSocksConnectorTest.php +++ b/tests/FunctionalSshSocksConnectorTest.php @@ -3,7 +3,6 @@ namespace Clue\Tests\React\SshProxy; use Clue\React\SshProxy\SshSocksConnector; -use React\EventLoop\Loop; class FunctionalSshSocksConnectorTest extends TestCase { @@ -30,7 +29,7 @@ public function setUpConnector() public function tearDownSSHClientProcess() { // run loop in order to shut down SSH client process again - \Clue\React\Block\sleep(0.001, Loop::get()); + \React\Async\await(\React\Promise\Timer\sleep(0.001)); } public function testConnectInvalidProxyUriWillReturnRejectedPromise() @@ -40,7 +39,7 @@ public function testConnectInvalidProxyUriWillReturnRejectedPromise() $promise = $this->connector->connect('example.com:80'); $this->setExpectedException('RuntimeException', 'Connection to example.com:80 failed because SSH client process died'); - \Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT); + \React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT)); } public function testConnectInvalidTargetWillReturnRejectedPromise() @@ -48,7 +47,7 @@ public function testConnectInvalidTargetWillReturnRejectedPromise() $promise = $this->connector->connect('example.invalid:80'); $this->setExpectedException('RuntimeException', 'Connection to tcp://example.invalid:80 failed because connection to proxy was lost'); - \Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT); + \React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT)); } public function testCancelConnectWillReturnRejectedPromise() @@ -57,14 +56,14 @@ public function testCancelConnectWillReturnRejectedPromise() $promise->cancel(); $this->setExpectedException('RuntimeException', 'Connection to example.com:80 cancelled while waiting for SSH client'); - \Clue\React\Block\await($promise, Loop::get(), 0); + \React\Async\await(\React\Promise\Timer\timeout($promise, 0)); } public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection() { $promise = $this->connector->connect('example.com:80'); - $connection = \Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT); + $connection = \React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT)); $this->assertInstanceOf('React\Socket\ConnectionInterface', $connection); $this->assertTrue($connection->isReadable()); @@ -74,10 +73,10 @@ public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnectionForCustomBindAddress() { - $this->connector = new SshSocksConnector(getenv('SSH_PROXY') . '?bind=127.0.0.1:1081', Loop::get()); + $this->connector = new SshSocksConnector(getenv('SSH_PROXY') . '?bind=127.0.0.1:1081'); $promise = $this->connector->connect('example.com:80'); - $connection = \Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT); + $connection = \React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT)); $this->assertInstanceOf('React\Socket\ConnectionInterface', $connection); $this->assertTrue($connection->isReadable());