From 4a945fcd8973a997bc74c6096946fdec1be64d37 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 18 Sep 2023 23:55:49 +0200 Subject: [PATCH 1/5] .gitignore: ignore PHPUnit cache file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 892666ef0..97f8812df 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /phpunit.xml /temp /vendor +/.phpunit.result.cache From 7be9f28f3611189ed5efcc9dfa304cdcbe0bd1b3 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 24 Sep 2023 09:36:01 +0200 Subject: [PATCH 2/5] PHPUnit config: display errors/warnings/notices etc The config as it was, was hiding 6 `Undefined array key`/`Trying to access array offset on null` notices. As any notice caused by a sniff will stop a PHPCS scan of a file dead, these should be discovered when running the tests and then fixed. Better yet: the tests should fail on them. This change in the configuration makes it so. Note: this does mean you now have a bug to fix. Also see: https://github.com/squizlabs/PHP_CodeSniffer/issues/3844 --- phpunit.xml.dist | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a98564147..b76ba3252 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -13,6 +13,13 @@ stopOnDefect="true" executionOrder="defects" cacheDirectory="temp/phpunit-cache" + displayDetailsOnTestsThatTriggerErrors="true" + displayDetailsOnTestsThatTriggerWarnings="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + failOnWarning="true" + failOnNotice="true" + failOnDeprecation="true" > From e45d3f2b252bfb6a21c08019586aab7c80d0e1e3 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 3 Oct 2023 23:53:48 +0200 Subject: [PATCH 3/5] PHPUnit config: upgrade to 10.3 schema This upgrades the XML configuration to one accepted by PHPUnit 10.3 and higher, which is in line with the PHPUnit requirements in the `composer.json` file. Note: the configuration will not validate for PHPUnit < 10.3 and will throw warnings, but as code coverage in CI is only run with PHPUnit 10 and the warnings are about that part of the configuration, this is nothing to worry about. Moreover, on PHPUnit 8.x/9.x, those warnings won't fail the build and the tests will still be run. --- phpunit.xml.dist | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b76ba3252..1e0236cee 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ ./tests/ - + SlevomatCodingStandard + + From 40ede6282a48513217089ba66f22c9d05af4b031 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 4 Oct 2023 00:28:52 +0200 Subject: [PATCH 4/5] GH Actions: turn error reporting on The default ini file used by the SetupPHP action is the production one, which turns error_reporting/display off. For the purposes of CI, I'd recommend running with `error_reporting=-1` and `display_errors=On` to ensure **all** PHP notices are shown. Also see: https://github.com/shivammathur/setup-php/issues/469 --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3d7dd166..d6828ae80 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,6 +41,7 @@ jobs: with: coverage: "none" php-version: "${{ matrix.php-version }}" + ini-values: error_reporting=-1, display_errors=On, zend.assertions=1 - name: "Reset composer platform" if: matrix.php-version == '7.2' || matrix.php-version == '7.3' || matrix.php-version == '7.4' @@ -77,6 +78,7 @@ jobs: with: coverage: "none" php-version: "${{ matrix.php-version }}" + ini-values: error_reporting=-1, display_errors=On, zend.assertions=1 - name: "Install dependencies" uses: "ramsey/composer-install@v2" @@ -152,6 +154,7 @@ jobs: coverage: "none" php-version: "${{ matrix.php-version }}" extensions: mbstring + ini-values: error_reporting=-1, display_errors=On, zend.assertions=1 - name: "Reset composer platform" if: matrix.php-version == '7.2' || matrix.php-version == '7.3' || matrix.php-version == '7.4' || matrix.php-version == '8.0' @@ -188,6 +191,7 @@ jobs: with: coverage: "pcov" php-version: "${{ matrix.php-version }}" + ini-values: error_reporting=-1, display_errors=On, zend.assertions=1 - name: "Install dependencies" uses: "ramsey/composer-install@v2" From cff76d6132af4e3fea7f97a7433af228b4c02476 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 4 Oct 2023 01:31:43 +0200 Subject: [PATCH 5/5] Composer: no need to allow PHPUnit 7.x PHPUnit 8.x has a minimum supported version of PHP 7.2, so there is no need to include PHPUnit 7.x in the allowed versions. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3ba01603c..670f865e0 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "phpstan/phpstan-deprecation-rules": "1.1.4", "phpstan/phpstan-phpunit": "1.3.14", "phpstan/phpstan-strict-rules": "1.5.1", - "phpunit/phpunit": "7.5.20|8.5.21|9.6.8|10.3.5" + "phpunit/phpunit": "8.5.21|9.6.8|10.3.5" }, "autoload": { "psr-4": {