2
2
3
3
namespace Clue \Tests \React \SshProxy ;
4
4
5
- use PHPUnit \Framework \TestCase ;
6
5
use React \EventLoop \Factory ;
7
6
use Clue \React \SshProxy \SshSocksConnector ;
8
7
@@ -13,7 +12,10 @@ class FunctionalSshSocksConnectorTest extends TestCase
13
12
private $ loop ;
14
13
private $ connector ;
15
14
16
- public function setUp ()
15
+ /**
16
+ * @before
17
+ */
18
+ public function setUpConnector ()
17
19
{
18
20
$ url = getenv ('SSH_PROXY ' );
19
21
if ($ url === false ) {
@@ -24,45 +26,39 @@ public function setUp()
24
26
$ this ->connector = new SshSocksConnector ($ url , $ this ->loop );
25
27
}
26
28
27
- public function tearDown ()
29
+ /**
30
+ * @after
31
+ */
32
+ public function tearDownSSHClientProcess ()
28
33
{
29
34
// run loop in order to shut down SSH client process again
30
35
\Clue \React \Block \sleep (0.001 , $ this ->loop );
31
36
}
32
37
33
- /**
34
- * @expectedException RuntimeException
35
- * @expectedExceptionMessage Connection to example.com:80 failed because SSH client process died
36
- */
37
38
public function testConnectInvalidProxyUriWillReturnRejectedPromise ()
38
39
{
39
40
$ this ->connector = new SshSocksConnector (getenv ('SSH_PROXY ' ) . '.invalid ' , $ this ->loop );
40
41
41
42
$ promise = $ this ->connector ->connect ('example.com:80 ' );
42
43
44
+ $ this ->setExpectedException ('RuntimeException ' , 'Connection to example.com:80 failed because SSH client process died ' );
43
45
\Clue \React \Block \await ($ promise , $ this ->loop , self ::TIMEOUT );
44
46
}
45
47
46
- /**
47
- * @expectedException RuntimeException
48
- * @expectedExceptionMessage Connection to tcp://example.invalid:80 failed because connection to proxy was lost
49
- */
50
48
public function testConnectInvalidTargetWillReturnRejectedPromise ()
51
49
{
52
50
$ promise = $ this ->connector ->connect ('example.invalid:80 ' );
53
51
52
+ $ this ->setExpectedException ('RuntimeException ' , 'Connection to tcp://example.invalid:80 failed because connection to proxy was lost ' );
54
53
\Clue \React \Block \await ($ promise , $ this ->loop , self ::TIMEOUT );
55
54
}
56
55
57
- /**
58
- * @expectedException RuntimeException
59
- * @expectedExceptionMessage Connection to example.com:80 cancelled while waiting for SSH client
60
- */
61
56
public function testCancelConnectWillReturnRejectedPromise ()
62
57
{
63
58
$ promise = $ this ->connector ->connect ('example.com:80 ' );
64
59
$ promise ->cancel ();
65
60
61
+ $ this ->setExpectedException ('RuntimeException ' , 'Connection to example.com:80 cancelled while waiting for SSH client ' );
66
62
\Clue \React \Block \await ($ promise , $ this ->loop , 0 );
67
63
}
68
64
0 commit comments