2
2
3
3
namespace Clue \Tests \React \SshProxy ;
4
4
5
- use React \EventLoop \Factory ;
6
5
use Clue \React \SshProxy \SshSocksConnector ;
6
+ use React \EventLoop \Loop ;
7
7
8
8
class FunctionalSshSocksConnectorTest extends TestCase
9
9
{
10
10
const TIMEOUT = 10.0 ;
11
11
12
- private $ loop ;
13
12
private $ connector ;
14
13
15
14
/**
@@ -22,8 +21,7 @@ public function setUpConnector()
22
21
$ this ->markTestSkipped ('No SSH_PROXY env set ' );
23
22
}
24
23
25
- $ this ->loop = Factory::create ();
26
- $ this ->connector = new SshSocksConnector ($ url , $ this ->loop );
24
+ $ this ->connector = new SshSocksConnector ($ url );
27
25
}
28
26
29
27
/**
@@ -32,25 +30,25 @@ public function setUpConnector()
32
30
public function tearDownSSHClientProcess ()
33
31
{
34
32
// run loop in order to shut down SSH client process again
35
- \Clue \React \Block \sleep (0.001 , $ this -> loop );
33
+ \Clue \React \Block \sleep (0.001 , Loop:: get () );
36
34
}
37
35
38
36
public function testConnectInvalidProxyUriWillReturnRejectedPromise ()
39
37
{
40
- $ this ->connector = new SshSocksConnector (getenv ('SSH_PROXY ' ) . '.invalid ' , $ this -> loop );
38
+ $ this ->connector = new SshSocksConnector (getenv ('SSH_PROXY ' ) . '.invalid ' );
41
39
42
40
$ promise = $ this ->connector ->connect ('example.com:80 ' );
43
41
44
42
$ this ->setExpectedException ('RuntimeException ' , 'Connection to example.com:80 failed because SSH client process died ' );
45
- \Clue \React \Block \await ($ promise , $ this -> loop , self ::TIMEOUT );
43
+ \Clue \React \Block \await ($ promise , Loop:: get () , self ::TIMEOUT );
46
44
}
47
45
48
46
public function testConnectInvalidTargetWillReturnRejectedPromise ()
49
47
{
50
48
$ promise = $ this ->connector ->connect ('example.invalid:80 ' );
51
49
52
50
$ this ->setExpectedException ('RuntimeException ' , 'Connection to tcp://example.invalid:80 failed because connection to proxy was lost ' );
53
- \Clue \React \Block \await ($ promise , $ this -> loop , self ::TIMEOUT );
51
+ \Clue \React \Block \await ($ promise , Loop:: get () , self ::TIMEOUT );
54
52
}
55
53
56
54
public function testCancelConnectWillReturnRejectedPromise ()
@@ -59,14 +57,14 @@ public function testCancelConnectWillReturnRejectedPromise()
59
57
$ promise ->cancel ();
60
58
61
59
$ this ->setExpectedException ('RuntimeException ' , 'Connection to example.com:80 cancelled while waiting for SSH client ' );
62
- \Clue \React \Block \await ($ promise , $ this -> loop , 0 );
60
+ \Clue \React \Block \await ($ promise , Loop:: get () , 0 );
63
61
}
64
62
65
63
public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection ()
66
64
{
67
65
$ promise = $ this ->connector ->connect ('example.com:80 ' );
68
66
69
- $ connection = \Clue \React \Block \await ($ promise , $ this -> loop , self ::TIMEOUT );
67
+ $ connection = \Clue \React \Block \await ($ promise , Loop:: get () , self ::TIMEOUT );
70
68
71
69
$ this ->assertInstanceOf ('React\Socket\ConnectionInterface ' , $ connection );
72
70
$ this ->assertTrue ($ connection ->isReadable ());
@@ -76,10 +74,10 @@ public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection
76
74
77
75
public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnectionForCustomBindAddress ()
78
76
{
79
- $ this ->connector = new SshSocksConnector (getenv ('SSH_PROXY ' ) . '?bind=127.0.0.1:1081 ' , $ this -> loop );
77
+ $ this ->connector = new SshSocksConnector (getenv ('SSH_PROXY ' ) . '?bind=127.0.0.1:1081 ' , Loop:: get () );
80
78
$ promise = $ this ->connector ->connect ('example.com:80 ' );
81
79
82
- $ connection = \Clue \React \Block \await ($ promise , $ this -> loop , self ::TIMEOUT );
80
+ $ connection = \Clue \React \Block \await ($ promise , Loop:: get () , self ::TIMEOUT );
83
81
84
82
$ this ->assertInstanceOf ('React\Socket\ConnectionInterface ' , $ connection );
85
83
$ this ->assertTrue ($ connection ->isReadable ());
0 commit comments