Skip to content

Commit 500d1db

Browse files
committed
Remove the PHPUnit config file during testing
Running PHPUnit 7 under PHP 8.1 causes an error when reading config files due to the assignment of by reference. By removing the config file and specifying the settings on the command line, this bit of code is skipped. The additional config options in the config file have also been removed as they didn't seem to be necessary, but this needs to be validated in the pipeline first.
1 parent 7e1cbca commit 500d1db

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.github/workflows/test.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575

7676
# For PHP 8.0+, we need to install with ignore platform reqs as PHPUnit 7 is still used.
7777
- name: Install Composer dependencies - with ignore platform
78-
if: ${{ matrix.php >= 8.0 }}
78+
if: ${{ matrix.custom_ini == false }}
7979
uses: "ramsey/composer-install@v1"
8080
with:
8181
composer-options: --ignore-platform-reqs
@@ -85,21 +85,27 @@ jobs:
8585
- name: 'PHPCS: set the path to PHP'
8686
run: php bin/phpcs --config-set php_path php
8787

88+
# We need to remove the config file so that PHPUnit doesn't try to read it.
89+
# This causes an error on PHP 8.1+ with PHPunit 7, but it's not needed here anyway as the
90+
# phpunit command (below) specifies all required settings.
91+
- name: 'PHPUnit: remove config file'
92+
run: rm phpunit.xml.dist
93+
8894
- name: 'PHPUnit: run the tests'
89-
run: vendor/bin/phpunit tests/AllTests.php
95+
run: vendor/bin/phpunit tests/AllTests.php --bootstrap=tests/bootstrap.php
9096

9197
- name: 'PHPCS: check code style without cache, no parallel'
92-
if: ${{ matrix.custom_ini == false }}
98+
if: ${{ matrix.custom_ini == false }}
9399
run: php bin/phpcs --no-cache --parallel=1
94100

95101
- name: 'Composer: validate config'
96-
if: ${{ matrix.custom_ini == false }}
102+
if: ${{ matrix.custom_ini == false }}
97103
run: composer validate --no-check-all --strict
98104

99105
- name: Build the phar
100-
if: ${{ matrix.custom_ini == false }}
106+
if: ${{ matrix.custom_ini == false }}
101107
run: php scripts/build-phar.php
102108

103109
- name: 'PHPCS: check code style using the Phar file'
104-
if: ${{ matrix.custom_ini == false }}
110+
if: ${{ matrix.custom_ini == false }}
105111
run: php phpcs.phar

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="true" beStrictAboutTestsThatDoNotTestAnything="false" bootstrap="tests/bootstrap.php">
2+
<phpunit bootstrap="tests/bootstrap.php">
33
<testsuites>
44
<testsuite name="PHP_CodeSniffer Test Suite">
55
<file>tests/AllTests.php</file>

0 commit comments

Comments
 (0)