From 7a6038e4bb80589ba8707e7a86d6cea06831f162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Mon, 5 Feb 2024 14:33:01 +0100 Subject: [PATCH] Enhancement: Add support for using Phar with phpunit/phpunit:^9.0.0 --- .github/workflows/integrate.yaml | 6 +++- .phive/phars.xml | 4 +-- CHANGELOG.md | 5 ++++ Makefile | 1 + README.md | 23 ++++++++++++++- manifest.xml | 4 +-- test/Phar/Version09/SleeperTest.php | 45 +++++++++++++++++++++++++++++ test/Phar/Version09/bootstrap.php | 14 +++++++++ test/Phar/Version09/phpunit.xml | 28 ++++++++++++++++++ 9 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 test/Phar/Version09/SleeperTest.php create mode 100644 test/Phar/Version09/bootstrap.php create mode 100644 test/Phar/Version09/phpunit.xml diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index d0359958..b2372add 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -598,7 +598,7 @@ jobs: run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version11/phpunit.xml" - name: "Download Phar" - if: "matrix.phpunit-version == '10.0.0'" + if: "matrix.phpunit-version == '9.0.0' || matrix.phpunit-version == '10.0.0'" uses: "actions/download-artifact@v4.1.1" with: name: "phpunit-slow-test-detector-phar" @@ -607,6 +607,10 @@ jobs: - name: "Remove autoloader for composer" run: "composer install --ansi --no-autoloader --no-interaction" + - name: "Run phar tests with phpunit/phpunit:9.0.0" + if: "matrix.phpunit-version == '9.0.0'" + run: "vendor/bin/phpunit --colors=always --configuration=test/Phar/Version09/phpunit.xml" + - name: "Run phar tests with phpunit/phpunit:10.0.0" if: "matrix.phpunit-version == '10.0.0'" run: "vendor/bin/phpunit --colors=always --configuration=test/Phar/Version10/phpunit.xml" diff --git a/.phive/phars.xml b/.phive/phars.xml index f017663f..630ae87d 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,5 +1,5 @@ - - + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 57f18d92..67b675ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), For a full diff see [`2.9.0...main`][2.9.0...main]. +### Changed + +- Added support for using `phpunit-slow-test-detector.phar` with `phpunit/phpunit:^9.0.0` ([#491]), by [@localheinz] + ## [`2.9.0`][2.9.0] For a full diff see [`2.8.0...2.9.0`][2.8.0...2.9.0]. @@ -263,6 +267,7 @@ For a full diff see [`7afa59c...1.0.0`][7afa59c...1.0.0]. [#396]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/396 [#447]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/447 [#448]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/448 +[#491]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/491 [@HypeMC]: https://github.com/HypeMC [@localheinz]: https://github.com/localheinz diff --git a/Makefile b/Makefile index 4a41b4a4..3ca6c064 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,7 @@ tests: phar ## Runs unit, end-to-end, and phar tests with phpunit/phpunit composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:^9.0.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version09/phpunit.xml; git checkout HEAD -- composer.json composer.lock composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:^10.0.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version10/phpunit.xml; git checkout HEAD -- composer.json composer.lock composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:11.0.x-dev --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version11/phpunit.xml; git checkout HEAD -- composer.json composer.lock + composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:^9.0.0 --no-interaction --quiet --update-with-all-dependencies; composer install --no-autoloader --no-interaction --quiet; vendor/bin/phpunit --configuration=test/Phar/Version09/phpunit.xml; git checkout HEAD -- composer.json composer.lock composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --quiet; composer require phpunit/phpunit:^10.0.0 --no-interaction --quiet --update-with-all-dependencies; composer install --no-autoloader --no-interaction --quiet; vendor/bin/phpunit --configuration=test/Phar/Version10/phpunit.xml; git checkout HEAD -- composer.json composer.lock vendor: composer.json composer.lock diff --git a/README.md b/README.md index 98b09116..db0936b1 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ to install `ergebnis/phpunit-slow-test-detector` as a `composer` package when us ### Installation as Phar -Download `phpunit-slow-test-detector.phar` from the [latest release](https://github.com/ergebnis/phpunit-slow-test-detector/releases/latest) when using `phpunit/phpunit:^10.0.0`. +Download `phpunit-slow-test-detector.phar` from the [latest release](https://github.com/ergebnis/phpunit-slow-test-detector/releases/latest) when using `phpunit/phpunit:^9.0.0` or `phpunit/phpunit:^10.0.0`. ## Usage @@ -106,6 +106,27 @@ To bootstrap the extension as a `composer` package when using `phpunit/phpunit:^ ``` +### Bootstrapping the extension as a PHAR when using `phpunit/phpunit:^10.0.0` + +To bootstrap the extension as a PHAR when using `phpunit/phpunit:^9.0.0`, adjust your `phpunit.xml` configuration file and configure the [`extensionsDirectory` attribute](https://docs.phpunit.de/en/9.6/configuration.html#the-extensionsdirectory-attribute) of the [`` element](https://docs.phpunit.de/en/9.6/configuration.html#the-phpunit-element): + +```diff + ++ ++ ++ + + + test/Unit/ + + + +``` ### Bootstrapping the extension as a `composer` package when using `phpunit/phpunit:^10.0.0` To bootstrap the extension as a `composer` package when using `phpunit/phpunit:^10.0.0`, adjust your `phpunit.xml` configuration file and configure the [`extensions` element](https://docs.phpunit.de/en/10.5/configuration.html#the-extensions-element): diff --git a/manifest.xml b/manifest.xml index 49b909b0..8b0866d3 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,7 +1,7 @@ - + @@ -10,6 +10,6 @@ - + diff --git a/test/Phar/Version09/SleeperTest.php b/test/Phar/Version09/SleeperTest.php new file mode 100644 index 00000000..dc2ce521 --- /dev/null +++ b/test/Phar/Version09/SleeperTest.php @@ -0,0 +1,45 @@ +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + public function testSleeperSleepsJustAboveDefaultMaximumDuration(): void + { + $milliseconds = 600; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } +} diff --git a/test/Phar/Version09/bootstrap.php b/test/Phar/Version09/bootstrap.php new file mode 100644 index 00000000..4e56e1de --- /dev/null +++ b/test/Phar/Version09/bootstrap.php @@ -0,0 +1,14 @@ + + + + + + + . + + +