22
33namespace  Clue \Tests \React \SshProxy ;
44
5- use  React \EventLoop \Factory ;
65use  Clue \React \SshProxy \SshSocksConnector ;
6+ use  React \EventLoop \Loop ;
77
88class  FunctionalSshSocksConnectorTest extends  TestCase
99{
1010    const  TIMEOUT  = 10.0 ;
1111
12-     private  $ loop
1312    private  $ connector
1413
1514    /** 
@@ -22,8 +21,7 @@ public function setUpConnector()
2221            $ this markTestSkipped ('No SSH_PROXY env set ' );
2322        }
2423
25-         $ this loop  = Factory::create ();
26-         $ this connector  = new  SshSocksConnector ($ url$ this loop );
24+         $ this connector  = new  SshSocksConnector ($ url
2725    }
2826
2927    /** 
@@ -32,25 +30,25 @@ public function setUpConnector()
3230    public  function  tearDownSSHClientProcess ()
3331    {
3432        // 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 () );
3634    }
3735
3836    public  function  testConnectInvalidProxyUriWillReturnRejectedPromise ()
3937    {
40-         $ this connector  = new  SshSocksConnector (getenv ('SSH_PROXY ' ) . '.invalid ' ,  $ this -> loop );
38+         $ this connector  = new  SshSocksConnector (getenv ('SSH_PROXY ' ) . '.invalid ' );
4139
4240        $ promise$ this connector ->connect ('example.com:80 ' );
4341
4442        $ 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 ($ promiseLoop:: get () , self ::TIMEOUT );
4644    }
4745
4846    public  function  testConnectInvalidTargetWillReturnRejectedPromise ()
4947    {
5048        $ promise$ this connector ->connect ('example.invalid:80 ' );
5149
5250        $ 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 ($ promiseLoop:: get () , self ::TIMEOUT );
5452    }
5553
5654    public  function  testCancelConnectWillReturnRejectedPromise ()
@@ -59,14 +57,14 @@ public function testCancelConnectWillReturnRejectedPromise()
5957        $ promisecancel ();
6058
6159        $ 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 ($ promiseLoop:: get () , 0 );
6361    }
6462
6563    public  function  testConnectValidTargetWillReturnPromiseWhichResolvesToConnection ()
6664    {
6765        $ promise$ this connector ->connect ('example.com:80 ' );
6866
69-         $ connection\Clue \React \Block \await ($ promise$ this -> loop , self ::TIMEOUT );
67+         $ connection\Clue \React \Block \await ($ promiseLoop:: get () , self ::TIMEOUT );
7068
7169        $ this assertInstanceOf ('React\Socket\ConnectionInterface ' , $ connection
7270        $ this assertTrue ($ connectionisReadable ());
@@ -76,10 +74,10 @@ public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection
7674
7775    public  function  testConnectValidTargetWillReturnPromiseWhichResolvesToConnectionForCustomBindAddress ()
7876    {
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 () );
8078        $ promise$ this connector ->connect ('example.com:80 ' );
8179
82-         $ connection\Clue \React \Block \await ($ promise$ this -> loop , self ::TIMEOUT );
80+         $ connection\Clue \React \Block \await ($ promiseLoop:: get () , self ::TIMEOUT );
8381
8482        $ this assertInstanceOf ('React\Socket\ConnectionInterface ' , $ connection
8583        $ this assertTrue ($ connectionisReadable ());
0 commit comments