Skip to content

Commit d0e26fa

Browse files
committed
Run tests on PHP 8.4 and update test suite
1 parent 5861005 commit d0e26fa

File tree

4 files changed

+103
-11
lines changed

4 files changed

+103
-11
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ on:
77
jobs:
88
PHPUnit:
99
name: PHPUnit (PHP ${{ matrix.php }})
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-24.04
1111
strategy:
1212
matrix:
1313
php:
14+
- 8.4
15+
- 8.3
1416
- 8.2
1517
- 8.1
1618
- 8.0
@@ -24,28 +26,36 @@ jobs:
2426
- 5.4
2527
- 5.3
2628
steps:
27-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v3
2830
- uses: shivammathur/setup-php@v2
2931
with:
3032
php-version: ${{ matrix.php }}
3133
coverage: xdebug
3234
- run: composer remove react/mysql --dev --no-interaction # do not install react/mysql example on legacy PHP
35+
- name: Handle PHP 5.3 compatibility
3336
if: ${{ matrix.php == 5.3 }}
37+
run: |
38+
composer remove react/mysql react/promise-timer --dev --no-interaction
39+
# Skip tests that require React\Promise\Timer
40+
echo "PHPUNIT_ARGS=--exclude-group=internet" >> $GITHUB_ENV
3441
- run: composer install
35-
- run: vendor/bin/phpunit --coverage-text
42+
- run: vendor/bin/phpunit --coverage-text $PHPUNIT_ARGS
3643
if: ${{ matrix.php >= 7.3 }}
37-
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
44+
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy $PHPUNIT_ARGS
3845
if: ${{ matrix.php < 7.3 }}
3946

4047
PHPUnit-hhvm:
4148
name: PHPUnit (HHVM)
42-
runs-on: ubuntu-18.04
49+
runs-on: ubuntu-24.04
4350
continue-on-error: true
4451
steps:
45-
- uses: actions/checkout@v2
46-
- uses: azjezz/setup-hhvm@v1
52+
- uses: actions/checkout@v3
53+
- run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM
54+
- name: Run HHVM Composer install
55+
uses: docker://hhvm/hhvm:3.30-lts-latest
4756
with:
48-
version: lts-3.30
49-
- run: composer self-update --2.2 # downgrade Composer for HHVM
50-
- run: hhvm $(which composer) install
51-
- run: hhvm vendor/bin/phpunit
57+
args: hhvm composer.phar remove react/mysql react/promise-timer --dev --no-interaction && hhvm composer.phar install
58+
- name: Run HHVM PHPUnit
59+
uses: docker://hhvm/hhvm:3.30-lts-latest
60+
with:
61+
args: hhvm vendor/bin/phpunit --exclude-group=internet

tests/FunctionalSshProcessConnectorTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ public function setUpConnector()
2323
$this->connector = new SshProcessConnector($url);
2424
}
2525

26+
/**
27+
* @before
28+
*/
29+
public function checkTimerSupport()
30+
{
31+
// Skip this test for PHP 5.3 where React\Promise\Timer isn't available
32+
if (!class_exists('React\\Promise\\Timer')) {
33+
$this->markTestSkipped('No Timer support available');
34+
}
35+
}
36+
2637
public function testConnectInvalidProxyUriWillReturnRejectedPromise()
2738
{
2839
$this->connector = new SshProcessConnector(getenv('SSH_PROXY') . '.invalid');

tests/FunctionalSshSocksConnectorTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

tests/SshProcessConnectorTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@
66

77
class SshProcessConnectorTest extends TestCase
88
{
9+
/**
10+
* @after
11+
*/
12+
public function tearDownSSHClientProcess()
13+
{
14+
// Skip timer-based teardown for PHP 5.3 where React\Promise\Timer is not available
15+
if (!class_exists('React\\Promise\\Timer\\TimeoutException')) {
16+
return;
17+
}
18+
19+
// run loop in order to shut down SSH client process again
20+
\React\Async\await(\React\Promise\Timer\sleep(0.001));
21+
}
22+
23+
// Helper method to check if Timer functions are available
24+
private function hasTimerSupport()
25+
{
26+
return class_exists('React\\Promise\\Timer\\TimeoutException');
27+
}
28+
929
public function testConstructWithoutLoopAssignsLoopAutomatically()
1030
{
1131
$connector = new SshProcessConnector('host');
@@ -104,6 +124,11 @@ public function testConstructorAcceptsHostWithLeadingDashWhenPrefixedWithUser()
104124

105125
public function testConnectReturnsRejectedPromiseForInvalidUri()
106126
{
127+
if (!$this->hasTimerSupport()) {
128+
$this->markTestSkipped('No Timer support available');
129+
return;
130+
}
131+
107132
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
108133
$connector = new SshProcessConnector('host', $loop);
109134

@@ -113,6 +138,11 @@ public function testConnectReturnsRejectedPromiseForInvalidUri()
113138

114139
public function testConnectReturnsRejectedPromiseForInvalidHost()
115140
{
141+
if (!$this->hasTimerSupport()) {
142+
$this->markTestSkipped('No Timer support available');
143+
return;
144+
}
145+
116146
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
117147
$connector = new SshProcessConnector('host', $loop);
118148

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy