Skip to content

Commit 7328b3a

Browse files
committed
Update to use new reactphp/async package instead of clue/reactphp-block
1 parent a33a624 commit 7328b3a

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"react/stream": "^1.2"
2121
},
2222
"require-dev": {
23-
"clue/block-react": "^1.5",
2423
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.36",
24+
"react/async": "^4 || ^3 || ^2",
2525
"react/http": "^1.5",
2626
"react/mysql": "^0.5.5"
2727
},

tests/FunctionalSshProcessConnectorTest.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Clue\Tests\React\SshProxy;
44

55
use Clue\React\SshProxy\SshProcessConnector;
6-
use React\EventLoop\Loop;
76

87
class FunctionalSshProcessConnectorTest extends TestCase
98
{
@@ -30,15 +29,15 @@ public function testConnectInvalidProxyUriWillReturnRejectedPromise()
3029
$promise = $this->connector->connect('example.com:80');
3130

3231
$this->setExpectedException('RuntimeException', 'Connection to example.com:80 failed because SSH client died');
33-
\Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT);
32+
\React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT));
3433
}
3534

3635
public function testConnectInvalidTargetWillReturnRejectedPromise()
3736
{
3837
$promise = $this->connector->connect('example.invalid:80');
3938

4039
$this->setExpectedException('RuntimeException', 'Connection to example.invalid:80 rejected:');
41-
\Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT);
40+
\React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT));
4241
}
4342

4443
public function testCancelConnectWillReturnRejectedPromise()
@@ -47,14 +46,14 @@ public function testCancelConnectWillReturnRejectedPromise()
4746
$promise->cancel();
4847

4948
$this->setExpectedException('RuntimeException', 'Connection to example.com:80 cancelled while waiting for SSH client');
50-
\Clue\React\Block\await($promise, Loop::get(), 0);
49+
\React\Async\await(\React\Promise\Timer\timeout($promise, 0));
5150
}
5251

5352
public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection()
5453
{
5554
$promise = $this->connector->connect('example.com:80');
5655

57-
$connection = \Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT);
56+
$connection = \React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT));
5857

5958
$this->assertInstanceOf('React\Socket\ConnectionInterface', $connection);
6059
$this->assertTrue($connection->isReadable());

tests/FunctionalSshSocksConnectorTest.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Clue\Tests\React\SshProxy;
44

55
use Clue\React\SshProxy\SshSocksConnector;
6-
use React\EventLoop\Loop;
76

87
class FunctionalSshSocksConnectorTest extends TestCase
98
{
@@ -30,7 +29,7 @@ public function setUpConnector()
3029
public function tearDownSSHClientProcess()
3130
{
3231
// run loop in order to shut down SSH client process again
33-
\Clue\React\Block\sleep(0.001, Loop::get());
32+
\React\Async\await(\React\Promise\Timer\sleep(0.001));
3433
}
3534

3635
public function testConnectInvalidProxyUriWillReturnRejectedPromise()
@@ -40,15 +39,15 @@ public function testConnectInvalidProxyUriWillReturnRejectedPromise()
4039
$promise = $this->connector->connect('example.com:80');
4140

4241
$this->setExpectedException('RuntimeException', 'Connection to example.com:80 failed because SSH client process died');
43-
\Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT);
42+
\React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT));
4443
}
4544

4645
public function testConnectInvalidTargetWillReturnRejectedPromise()
4746
{
4847
$promise = $this->connector->connect('example.invalid:80');
4948

5049
$this->setExpectedException('RuntimeException', 'Connection to tcp://example.invalid:80 failed because connection to proxy was lost');
51-
\Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT);
50+
\React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT));
5251
}
5352

5453
public function testCancelConnectWillReturnRejectedPromise()
@@ -57,14 +56,14 @@ public function testCancelConnectWillReturnRejectedPromise()
5756
$promise->cancel();
5857

5958
$this->setExpectedException('RuntimeException', 'Connection to example.com:80 cancelled while waiting for SSH client');
60-
\Clue\React\Block\await($promise, Loop::get(), 0);
59+
\React\Async\await(\React\Promise\Timer\timeout($promise, 0));
6160
}
6261

6362
public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection()
6463
{
6564
$promise = $this->connector->connect('example.com:80');
6665

67-
$connection = \Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT);
66+
$connection = \React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT));
6867

6968
$this->assertInstanceOf('React\Socket\ConnectionInterface', $connection);
7069
$this->assertTrue($connection->isReadable());
@@ -74,10 +73,10 @@ public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection
7473

7574
public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnectionForCustomBindAddress()
7675
{
77-
$this->connector = new SshSocksConnector(getenv('SSH_PROXY') . '?bind=127.0.0.1:1081', Loop::get());
76+
$this->connector = new SshSocksConnector(getenv('SSH_PROXY') . '?bind=127.0.0.1:1081');
7877
$promise = $this->connector->connect('example.com:80');
7978

80-
$connection = \Clue\React\Block\await($promise, Loop::get(), self::TIMEOUT);
79+
$connection = \React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT));
8180

8281
$this->assertInstanceOf('React\Socket\ConnectionInterface', $connection);
8382
$this->assertTrue($connection->isReadable());

0 commit comments

Comments
 (0)