@@ -201,16 +201,34 @@ jobs:
201201 if : ${{ matrix.phpcs_version == 'lowest' }}
202202 run : composer update squizlabs/php_codesniffer --prefer-lowest --no-scripts --no-interaction
203203
204+ - name : Grab PHPUnit version
205+ id : phpunit_version
206+ # yamllint disable-line rule:line-length
207+ run : echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT
208+
209+ - name : Determine PHPUnit config file to use
210+ id : phpunit_config
211+ run : |
212+ if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then
213+ echo 'FILE=phpunit10.xml.dist' >> $GITHUB_OUTPUT
214+ echo 'EXTRA_ARGS=' >> $GITHUB_OUTPUT
215+ else
216+ echo 'FILE=phpunit.xml.dist' >> $GITHUB_OUTPUT
217+ echo 'EXTRA_ARGS= --repeat 2' >> $GITHUB_OUTPUT
218+ fi
219+
204220 - name : Run the unit tests without caching (non-risky)
205221 if : ${{ matrix.risky == false }}
206- run : vendor/bin/phpunit --no-coverage
222+ run : vendor/bin/phpunit -c ${{ steps.phpunit_config.outputs.FILE }} - -no-coverage
207223 env :
208224 PHPCS_VERSION : ${{ matrix.phpcs_version == '4.0.x-dev' && '4.0.0' || matrix.phpcs_version }}
209225 PHPCSUTILS_USE_CACHE : false
210226
211227 - name : Run the unit tests with caching (non-risky)
212228 if : ${{ matrix.risky == false }}
213- run : vendor/bin/phpunit --testsuite PHPCSUtils --no-coverage --repeat 2
229+ run : >
230+ vendor/bin/phpunit -c ${{ steps.phpunit_config.outputs.FILE }}
231+ --testsuite PHPCSUtils --no-coverage ${{ steps.phpunit_config.outputs.EXTRA_ARGS }}
214232 env :
215233 PHPCS_VERSION : ${{ matrix.phpcs_version == '4.0.x-dev' && '4.0.0' || matrix.phpcs_version }}
216234 PHPCSUTILS_USE_CACHE : true
@@ -220,15 +238,15 @@ jobs:
220238 - name : Run the unit tests (risky, comparewithPHPCS)
221239 if : ${{ matrix.risky && matrix.phpcs_version == 'dev-master' }}
222240 # "nothing" is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
223- run : vendor/bin/phpunit --no-coverage --group compareWithPHPCS --exclude-group nothing
241+ run : vendor/bin/phpunit -c ${{ steps.phpunit_config.outputs.FILE }} - -no-coverage --group compareWithPHPCS --exclude-group nothing
224242 env :
225243 PHPCS_VERSION : ${{ matrix.phpcs_version == '4.0.x-dev' && '4.0.0' || matrix.phpcs_version }}
226244
227245 # Run the "xtra" group against high and low PHPCS as these are tests safeguarding PHPCS itself.
228246 - name : Run the unit tests (risky, xtra)
229247 if : ${{ matrix.risky }}
230248 # "nothing" is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
231- run : vendor/bin/phpunit --no-coverage --group xtra --exclude-group nothing
249+ run : vendor/bin/phpunit -c ${{ steps.phpunit_config.outputs.FILE }} - -no-coverage --group xtra --exclude-group nothing
232250 env :
233251 PHPCS_VERSION : ${{ matrix.phpcs_version == '4.0.x-dev' && '4.0.0' || matrix.phpcs_version }}
234252
@@ -312,20 +330,21 @@ jobs:
312330 # As of PHPUnit 9.3.4, a cache warming option is available.
313331 # Using that option prevents issues with PHP-Parser backfilling PHP tokens when PHPCS does not (yet),
314332 # which would otherwise cause tests to fail on tokens being available when they shouldn't be.
333+ # As coverage is only run on high/low PHP, the high PHP version will use PHPUnit 10, so just check for that.
315334 - name : " Warm the PHPUnit cache (PHPUnit 9.3+)"
316- if : ${{ steps.phpunit_version.outputs.VERSION >= '9.3' }}
317- run : vendor/bin/phpunit --coverage-cache ./build/phpunit-cache --warm-coverage-cache
335+ if : ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
336+ run : vendor/bin/phpunit -c phpunit10.xml.dist - -coverage-cache ./build/phpunit-cache --warm-coverage-cache
318337
319- - name : " Run the unit tests without caching with code coverage (PHPUnit < 9.3 )"
320- if : ${{ steps.phpunit_version.outputs.VERSION < '9.3' }}
338+ - name : " Run the unit tests without caching with code coverage (PHPUnit < 10 )"
339+ if : ${{ ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
321340 run : vendor/bin/phpunit
322341 env :
323342 PHPCS_VERSION : ${{ matrix.phpcs_version }}
324343 PHPCSUTILS_USE_CACHE : false
325344
326- - name : " Run the unit tests without caching with code coverage (PHPUnit 9.3 +)"
327- if : ${{ steps.phpunit_version.outputs.VERSION >= '9.3' }}
328- run : vendor/bin/phpunit --coverage-cache ./build/phpunit-cache
345+ - name : " Run the unit tests without caching with code coverage (PHPUnit 10 +)"
346+ if : ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
347+ run : vendor/bin/phpunit -c phpunit10.xml.dist - -coverage-cache ./build/phpunit-cache
329348 env :
330349 PHPCS_VERSION : ${{ matrix.phpcs_version }}
331350 PHPCSUTILS_USE_CACHE : false
0 commit comments