3
3
namespace Clue \Tests \React \SshProxy ;
4
4
5
5
use Clue \React \SshProxy \SshSocksConnector ;
6
- use React \EventLoop \Loop ;
7
6
8
7
class FunctionalSshSocksConnectorTest extends TestCase
9
8
{
@@ -30,7 +29,7 @@ public function setUpConnector()
30
29
public function tearDownSSHClientProcess ()
31
30
{
32
31
// 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 ));
34
33
}
35
34
36
35
public function testConnectInvalidProxyUriWillReturnRejectedPromise ()
@@ -40,15 +39,15 @@ public function testConnectInvalidProxyUriWillReturnRejectedPromise()
40
39
$ promise = $ this ->connector ->connect ('example.com:80 ' );
41
40
42
41
$ 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 ) );
44
43
}
45
44
46
45
public function testConnectInvalidTargetWillReturnRejectedPromise ()
47
46
{
48
47
$ promise = $ this ->connector ->connect ('example.invalid:80 ' );
49
48
50
49
$ 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 ) );
52
51
}
53
52
54
53
public function testCancelConnectWillReturnRejectedPromise ()
@@ -57,14 +56,14 @@ public function testCancelConnectWillReturnRejectedPromise()
57
56
$ promise ->cancel ();
58
57
59
58
$ 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 ) );
61
60
}
62
61
63
62
public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection ()
64
63
{
65
64
$ promise = $ this ->connector ->connect ('example.com:80 ' );
66
65
67
- $ connection = \Clue \ React \Block \await ($ promise , Loop:: get (), self ::TIMEOUT );
66
+ $ connection = \React \Async \await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
68
67
69
68
$ this ->assertInstanceOf ('React\Socket\ConnectionInterface ' , $ connection );
70
69
$ this ->assertTrue ($ connection ->isReadable ());
@@ -74,10 +73,10 @@ public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection
74
73
75
74
public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnectionForCustomBindAddress ()
76
75
{
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 ' );
78
77
$ promise = $ this ->connector ->connect ('example.com:80 ' );
79
78
80
- $ connection = \Clue \ React \Block \await ($ promise , Loop:: get (), self ::TIMEOUT );
79
+ $ connection = \React \Async \await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
81
80
82
81
$ this ->assertInstanceOf ('React\Socket\ConnectionInterface ' , $ connection );
83
82
$ this ->assertTrue ($ connection ->isReadable ());
0 commit comments