Skip to content

Commit 7ae6866

Browse files
authored
Merge pull request #80 from clue-labs/update-tests
Update test suite and report failed assertions
2 parents f800f3a + 2cf9795 commit 7ae6866

File tree

5 files changed

+54
-24
lines changed

5 files changed

+54
-24
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66

77
jobs:
88
PHPUnit:
9-
runs-on: ubuntu-20.04
9+
name: PHPUnit (PHP ${{ matrix.php }})
10+
runs-on: ubuntu-22.04
1011
strategy:
1112
matrix:
1213
php:
@@ -23,12 +24,12 @@ jobs:
2324
- 5.4
2425
- 5.3
2526
steps:
26-
- uses: actions/checkout@v2
27-
- name: Setup PHP
28-
uses: shivammathur/setup-php@v2
27+
- uses: actions/checkout@v3
28+
- uses: shivammathur/setup-php@v2
2929
with:
3030
php-version: ${{ matrix.php }}
3131
coverage: xdebug
32+
ini-file: development
3233
- run: composer install
3334
- run: vendor/bin/phpunit --coverage-text
3435
if: ${{ matrix.php >= 7.3 }}

composer.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
"email": "[email protected]"
1111
}
1212
],
13-
"autoload": {
14-
"psr-4": { "Clue\\React\\Docker\\": "src/" }
15-
},
16-
"autoload-dev": {
17-
"psr-4": { "Clue\\Tests\\React\\Docker\\": "tests/" }
18-
},
1913
"require": {
2014
"php": ">=5.3",
2115
"clue/json-stream": "^0.1",
@@ -28,9 +22,19 @@
2822
"rize/uri-template": "^0.3"
2923
},
3024
"require-dev": {
31-
"react/async": "^4 || ^3 || ^2",
3225
"clue/caret-notation": "^0.2",
3326
"clue/tar-react": "^0.2",
34-
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
27+
"phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35",
28+
"react/async": "^4 || ^3 || ^2"
29+
},
30+
"autoload": {
31+
"psr-4": {
32+
"Clue\\React\\Docker\\": "src/"
33+
}
34+
},
35+
"autoload-dev": {
36+
"psr-4": {
37+
"Clue\\Tests\\React\\Docker\\": "tests/"
38+
}
3539
}
3640
}

phpunit.xml.dist

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
4-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
3+
<!-- PHPUnit configuration file with new format for PHPUnit 9.5+ -->
4+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
66
bootstrap="vendor/autoload.php"
7+
cacheResult="false"
78
colors="true"
8-
cacheResult="false">
9+
convertDeprecationsToExceptions="true">
910
<testsuites>
1011
<testsuite name="Docker React Test Suite">
1112
<directory>./tests/</directory>
@@ -16,4 +17,12 @@
1617
<directory>./src/</directory>
1718
</include>
1819
</coverage>
20+
<php>
21+
<ini name="error_reporting" value="-1" />
22+
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
23+
<!-- <ini name="zend.assertions" value="1" /> -->
24+
<ini name="assert.active" value="1" />
25+
<ini name="assert.exception" value="1" />
26+
<ini name="assert.bail" value="0" />
27+
</php>
1928
</phpunit>

phpunit.xml.legacy

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
3+
<!-- PHPUnit configuration file with old format for legacy PHPUnit -->
44
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
66
bootstrap="vendor/autoload.php"
@@ -15,4 +15,12 @@
1515
<directory>./src/</directory>
1616
</whitelist>
1717
</filter>
18+
<php>
19+
<ini name="error_reporting" value="-1" />
20+
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
21+
<!-- <ini name="zend.assertions" value="1" /> -->
22+
<ini name="assert.active" value="1" />
23+
<ini name="assert.exception" value="1" />
24+
<ini name="assert.bail" value="0" />
25+
</php>
1826
</phpunit>

tests/FunctionalClientTest.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,21 @@ public function testCreateStartAndRemoveContainer()
9191
$promise = $this->client->events($start, $end, array('container' => array($container['Id'])));
9292
$ret = \React\Async\await($promise);
9393

94-
// expects "start", "attach", "kill", "die", "destroy" events
95-
$this->assertEquals(5, count($ret));
96-
$this->assertEquals('start', $ret[0]['status']);
97-
$this->assertEquals('attach', $ret[1]['status']);
98-
$this->assertEquals('kill', $ret[2]['status']);
99-
$this->assertEquals('die', $ret[3]['status']);
100-
$this->assertEquals('destroy', $ret[4]['status']);
94+
$this->assertIsArray($ret);
95+
96+
$status = array(); // array_column($ret, 'status'); // PHP 5.5+
97+
foreach ($ret as $one) {
98+
$status[] = $one['status'];
99+
}
100+
101+
// expect 4 events as of ~2021, 5 in earlier versions
102+
if (count($status) === 4) {
103+
// start, die, attach, destroy
104+
$this->assertEquals(array('start', 'die', 'attach', 'destroy'), $status);
105+
} else {
106+
// expects "start", "attach", "kill", "die", "destroy" events
107+
$this->assertEquals(array('start', 'attach', 'kill', 'die', 'destroy'), $status);
108+
}
101109
}
102110

103111
/**

0 commit comments

Comments
 (0)