Skip to content

Commit 020811f

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

File tree

4 files changed

+99
-9
lines changed

4 files changed

+99
-9
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,36 @@ jobs:
2424
- 5.4
2525
- 5.3
2626
steps:
27-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v3
2828
- uses: shivammathur/setup-php@v2
2929
with:
3030
php-version: ${{ matrix.php }}
3131
coverage: xdebug
3232
- run: composer remove react/mysql --dev --no-interaction # do not install react/mysql example on legacy PHP
33+
- name: Handle PHP 5.3 compatibility
3334
if: ${{ matrix.php == 5.3 }}
35+
run: |
36+
composer remove react/mysql react/promise-timer --dev --no-interaction
37+
# Skip tests that require React\Promise\Timer
38+
echo "PHPUNIT_ARGS=--exclude-group=internet" >> $GITHUB_ENV
3439
- run: composer install
35-
- run: vendor/bin/phpunit --coverage-text
40+
- run: vendor/bin/phpunit --coverage-text $PHPUNIT_ARGS
3641
if: ${{ matrix.php >= 7.3 }}
37-
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
42+
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy $PHPUNIT_ARGS
3843
if: ${{ matrix.php < 7.3 }}
3944

4045
PHPUnit-hhvm:
4146
name: PHPUnit (HHVM)
4247
runs-on: ubuntu-18.04
4348
continue-on-error: true
4449
steps:
45-
- uses: actions/checkout@v2
46-
- uses: azjezz/setup-hhvm@v1
50+
- uses: actions/checkout@v3
51+
- run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM
52+
- name: Run HHVM Composer install
53+
uses: docker://hhvm/hhvm:3.30-lts-latest
4754
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
55+
args: hhvm composer.phar remove react/mysql react/promise-timer --dev --no-interaction && hhvm composer.phar install
56+
- name: Run HHVM PHPUnit
57+
uses: docker://hhvm/hhvm:3.30-lts-latest
58+
with:
59+
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