@@ -28,12 +28,28 @@ public function setUpConnector()
2828 */
2929 public function tearDownSSHClientProcess ()
3030 {
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+
3136 // run loop in order to shut down SSH client process again
3237 \React \Async \await (\React \Promise \Timer \sleep (0.001 ));
3338 }
3439
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+
3546 public function testConnectInvalidProxyUriWillReturnRejectedPromise ()
3647 {
48+ if (!$ this ->hasTimerSupport ()) {
49+ $ this ->markTestSkipped ('No Timer support available ' );
50+ return ;
51+ }
52+
3753 $ this ->connector = new SshSocksConnector (getenv ('SSH_PROXY ' ) . '.invalid ' );
3854
3955 $ promise = $ this ->connector ->connect ('example.com:80 ' );
@@ -44,6 +60,11 @@ public function testConnectInvalidProxyUriWillReturnRejectedPromise()
4460
4561 public function testConnectInvalidTargetWillReturnRejectedPromise ()
4662 {
63+ if (!$ this ->hasTimerSupport ()) {
64+ $ this ->markTestSkipped ('No Timer support available ' );
65+ return ;
66+ }
67+
4768 $ promise = $ this ->connector ->connect ('example.invalid:80 ' );
4869
4970 $ this ->setExpectedException ('RuntimeException ' , 'Connection to tcp://example.invalid:80 failed because connection to proxy was lost ' );
@@ -52,6 +73,11 @@ public function testConnectInvalidTargetWillReturnRejectedPromise()
5273
5374 public function testCancelConnectWillReturnRejectedPromise ()
5475 {
76+ if (!$ this ->hasTimerSupport ()) {
77+ $ this ->markTestSkipped ('No Timer support available ' );
78+ return ;
79+ }
80+
5581 $ promise = $ this ->connector ->connect ('example.com:80 ' );
5682 $ promise ->cancel ();
5783
@@ -61,6 +87,11 @@ public function testCancelConnectWillReturnRejectedPromise()
6187
6288 public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection ()
6389 {
90+ if (!$ this ->hasTimerSupport ()) {
91+ $ this ->markTestSkipped ('No Timer support available ' );
92+ return ;
93+ }
94+
6495 $ promise = $ this ->connector ->connect ('example.com:80 ' );
6596
6697 $ connection = \React \Async \await (\React \Promise \Timer \timeout ($ promise , self ::TIMEOUT ));
@@ -73,6 +104,11 @@ public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection
73104
74105 public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnectionForCustomBindAddress ()
75106 {
107+ if (!$ this ->hasTimerSupport ()) {
108+ $ this ->markTestSkipped ('No Timer support available ' );
109+ return ;
110+ }
111+
76112 $ this ->connector = new SshSocksConnector (getenv ('SSH_PROXY ' ) . '?bind=127.0.0.1:1081 ' );
77113 $ promise = $ this ->connector ->connect ('example.com:80 ' );
78114
@@ -86,6 +122,11 @@ public function testConnectValidTargetWillReturnPromiseWhichResolvesToConnection
86122
87123 public function testConnectPendingWillNotInheritActiveFileDescriptors ()
88124 {
125+ if (!$ this ->hasTimerSupport ()) {
126+ $ this ->markTestSkipped ('No Timer support available ' );
127+ return ;
128+ }
129+
89130 $ server = stream_socket_server ('tcp://127.0.0.1:0 ' );
90131 $ address = stream_socket_get_name ($ server , false );
91132
0 commit comments