@@ -28,12 +28,28 @@ public function setUpConnector()
28
28
*/
29
29
public function tearDownSSHClientProcess ()
30
30
{
31
+ // Skip timer-based teardown for PHP 5.3 where React\Promise\Timer is not available
32
+ if (!class_exists ('React \\Promise \\Timer \\TimeoutException ' )) {
33
+ return ;
34
+ }
35
+
31
36
// run loop in order to shut down SSH client process again
32
37
\React \Async \await (\React \Promise \Timer \sleep (0.001 ));
33
38
}
34
39
40
+ // Helper method to check if Timer functions are available
41
+ private function hasTimerSupport ()
42
+ {
43
+ return class_exists ('React \\Promise \\Timer \\TimeoutException ' );
44
+ }
45
+
35
46
public function testConnectInvalidProxyUriWillReturnRejectedPromise ()
36
47
{
48
+ if (!$ this ->hasTimerSupport ()) {
49
+ $ this ->markTestSkipped ('No Timer support available ' );
50
+ return ;
51
+ }
52
+
37
53
$ this ->connector = new SshSocksConnector (getenv ('SSH_PROXY ' ) . '.invalid ' );
38
54
39
55
$ promise = $ this ->connector ->connect ('example.com:80 ' );
@@ -44,6 +60,11 @@ public function testConnectInvalidProxyUriWillReturnRejectedPromise()
44
60
45
61
public function testConnectInvalidTargetWillReturnRejectedPromise ()
46
62
{
63
+ if (!$ this ->hasTimerSupport ()) {
64
+ $ this ->markTestSkipped ('No Timer support available ' );
65
+ return ;
66
+ }
67
+
47
68
$ promise = $ this ->connector ->connect ('example.invalid:80 ' );
48
69
49
70
$ this ->setExpectedException ('RuntimeException ' , 'Connection to tcp://example.invalid:80 failed because connection to proxy was lost ' );
@@ -52,6 +73,11 @@ public function testConnectInvalidTargetWillReturnRejectedPromise()
52
73
53
74
public function testCancelConnectWillReturnRejectedPromise ()
54
75
{
76
+ if (!$ this ->hasTimerSupport ()) {
77
+ $ this ->markTestSkipped ('No Timer support available ' );
78
+ return ;
79
+ }
80
+
55
81
$ promise = $ this ->connector ->connect ('example.com:80 ' );
56
82
$ promise ->cancel ();
57
83
@@ -61,6 +87,11 @@ public function testCancelConnectWillReturnRejectedPromise()
61
87
62
88
public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection ()
63
89
{
90
+ if (!$ this ->hasTimerSupport ()) {
91
+ $ this ->markTestSkipped ('No Timer support available ' );
92
+ return ;
93
+ }
94
+
64
95
$ promise = $ this ->connector ->connect ('example.com:80 ' );
65
96
66
97
$ connection = \React \Async \await (\React \Promise \Timer \timeout ($ promise , self ::TIMEOUT ));
@@ -73,6 +104,11 @@ public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection
73
104
74
105
public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnectionForCustomBindAddress ()
75
106
{
107
+ if (!$ this ->hasTimerSupport ()) {
108
+ $ this ->markTestSkipped ('No Timer support available ' );
109
+ return ;
110
+ }
111
+
76
112
$ this ->connector = new SshSocksConnector (getenv ('SSH_PROXY ' ) . '?bind=127.0.0.1:1081 ' );
77
113
$ promise = $ this ->connector ->connect ('example.com:80 ' );
78
114
@@ -86,6 +122,11 @@ public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection
86
122
87
123
public function testConnectPendingWillNotInheritActiveFileDescriptors ()
88
124
{
125
+ if (!$ this ->hasTimerSupport ()) {
126
+ $ this ->markTestSkipped ('No Timer support available ' );
127
+ return ;
128
+ }
129
+
89
130
$ server = stream_socket_server ('tcp://127.0.0.1:0 ' );
90
131
$ address = stream_socket_get_name ($ server , false );
91
132
0 commit comments