From 5f250586e771166df684eac317081c13ce16c4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 30 Nov 2022 16:06:24 +0100 Subject: [PATCH 1/2] Update test suite and report failed assertions --- .github/workflows/ci.yml | 9 +++++---- composer.json | 20 ++++++++++++-------- phpunit.xml.dist | 17 +++++++++++++---- phpunit.xml.legacy | 10 +++++++++- 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 276944d..1105f82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,8 @@ on: jobs: PHPUnit: - runs-on: ubuntu-20.04 + name: PHPUnit (PHP ${{ matrix.php }}) + runs-on: ubuntu-22.04 strategy: matrix: php: @@ -23,12 +24,12 @@ jobs: - 5.4 - 5.3 steps: - - uses: actions/checkout@v2 - - name: Setup PHP - uses: shivammathur/setup-php@v2 + - uses: actions/checkout@v3 + - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} coverage: xdebug + ini-file: development - run: composer install - run: vendor/bin/phpunit --coverage-text if: ${{ matrix.php >= 7.3 }} diff --git a/composer.json b/composer.json index 8ee7150..9cbcaa4 100644 --- a/composer.json +++ b/composer.json @@ -10,12 +10,6 @@ "email": "christian@clue.engineering" } ], - "autoload": { - "psr-4": { "Clue\\React\\Docker\\": "src/" } - }, - "autoload-dev": { - "psr-4": { "Clue\\Tests\\React\\Docker\\": "tests/" } - }, "require": { "php": ">=5.3", "clue/json-stream": "^0.1", @@ -28,9 +22,19 @@ "rize/uri-template": "^0.3" }, "require-dev": { - "react/async": "^4 || ^3 || ^2", "clue/caret-notation": "^0.2", "clue/tar-react": "^0.2", - "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", + "react/async": "^4 || ^3 || ^2" + }, + "autoload": { + "psr-4": { + "Clue\\React\\Docker\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Clue\\Tests\\React\\Docker\\": "tests/" + } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2a2c1e9..bbf0b7d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,11 +1,12 @@ - - + + convertDeprecationsToExceptions="true"> ./tests/ @@ -16,4 +17,12 @@ ./src/ + + + + + + + + diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy index 4e371fa..75423a9 100644 --- a/phpunit.xml.legacy +++ b/phpunit.xml.legacy @@ -1,6 +1,6 @@ - + ./src/ + + + + + + + + From 2cf9795a2ced265f8ca92a8132bbf4f2ded6349e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Thu, 15 Jul 2021 15:45:21 +0200 Subject: [PATCH 2/2] Fix tests to support latest Docker version --- tests/FunctionalClientTest.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/FunctionalClientTest.php b/tests/FunctionalClientTest.php index 56ff0bb..3affe99 100644 --- a/tests/FunctionalClientTest.php +++ b/tests/FunctionalClientTest.php @@ -91,13 +91,21 @@ public function testCreateStartAndRemoveContainer() $promise = $this->client->events($start, $end, array('container' => array($container['Id']))); $ret = \React\Async\await($promise); - // expects "start", "attach", "kill", "die", "destroy" events - $this->assertEquals(5, count($ret)); - $this->assertEquals('start', $ret[0]['status']); - $this->assertEquals('attach', $ret[1]['status']); - $this->assertEquals('kill', $ret[2]['status']); - $this->assertEquals('die', $ret[3]['status']); - $this->assertEquals('destroy', $ret[4]['status']); + $this->assertIsArray($ret); + + $status = array(); // array_column($ret, 'status'); // PHP 5.5+ + foreach ($ret as $one) { + $status[] = $one['status']; + } + + // expect 4 events as of ~2021, 5 in earlier versions + if (count($status) === 4) { + // start, die, attach, destroy + $this->assertEquals(array('start', 'die', 'attach', 'destroy'), $status); + } else { + // expects "start", "attach", "kill", "die", "destroy" events + $this->assertEquals(array('start', 'attach', 'kill', 'die', 'destroy'), $status); + } } /**