Skip to content

Commit 778c4ee

Browse files
committed
Tests: Add a separate PHPUnit configuration file for PHPUnit 10.1 and later
- Add phpunit10.xml.dist and tests/phpunit/multisite10.xml compliant with PHPUnit 10.1+ schema. - Update reusable-phpunit-tests-v3.yml with automated detection to select the PHPUnit 10+ configuration when running on PHPUnit 10+. - Fix hardcoded -c phpunit.xml.dist in reusable-phpunit-tests-v1.yml and v2.yml external-http step to use PHPUNIT_CONFIG. - Update workflow path triggers in phpunit-tests.yml, full matrix, test-coverage, and exclude from asset workflows. - Add test10 script in composer.json and test:php10 in package.json. - Add /phpunit10.xml to .gitignore and update configuration documentation in tests/phpunit/README.md. See #66210, #62004.
1 parent 9b2abab commit 778c4ee

15 files changed

Lines changed: 217 additions & 3 deletions

‎.github/workflows/end-to-end-tests.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ on:
3232
- '!phpcs.xml.dist'
3333
- '!phpstan.neon.dist'
3434
- '!phpunit.xml.dist'
35+
- '!phpunit10.xml.dist'
3536
- '!tsconfig.json'
3637
# Other test suites, tools, and workflows do not affect these tests.
3738
- '!tests/**'

‎.github/workflows/performance.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ on:
3232
- '!phpcs.xml.dist'
3333
- '!phpstan.neon.dist'
3434
- '!phpunit.xml.dist'
35+
- '!phpunit10.xml.dist'
3536
- '!tsconfig.json'
3637
# Other test suites, tools, and workflows do not affect these tests.
3738
- '!tests/**'

‎.github/workflows/phpunit-tests-full-matrix.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ on:
4242
- 'tools/vendors/**'
4343
- 'tools/webpack/**'
4444
- 'phpunit.xml.dist'
45+
- 'phpunit10.xml.dist'
4546
- '.github/actions/setup-npm/**'
4647
- '.github/workflows/phpunit-tests.yml'
4748
- '.github/workflows/phpunit-tests-full-matrix.yml'

‎.github/workflows/phpunit-tests.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ on:
4646
- 'tools/vendors/**'
4747
- 'tools/webpack/**'
4848
- 'phpunit.xml.dist'
49+
- 'phpunit10.xml.dist'
4950
- '.github/actions/setup-npm/**'
5051
- '.github/workflows/phpunit-tests.yml'
5152
- '.github/workflows/phpunit-tests-full-matrix.yml'

‎.github/workflows/reusable-phpunit-tests-v1.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,4 @@ jobs:
247247

248248
- name: Run external HTTP tests
249249
if: ${{ ! inputs.multisite && ! inputs.split_slow && ! inputs.phpunit-test-groups }}
250-
run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c phpunit.xml.dist --group external-http
250+
run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --group external-http

‎.github/workflows/reusable-phpunit-tests-v2.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ jobs:
254254

255255
- name: Run external HTTP tests
256256
if: ${{ ! inputs.multisite && ! inputs.split_slow && ! inputs.phpunit-test-groups }}
257-
run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c phpunit.xml.dist --group external-http
257+
run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --group external-http
258258

259259
# __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
260260
- name: Run (xDebug) tests

‎.github/workflows/reusable-phpunit-tests-v3.yml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,21 @@ jobs:
317317
php -m | grep -i pcov
318318
'
319319
320+
- name: Select PHPUnit configuration
321+
run: |
322+
PHPUNIT_VERSION=$(node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --version | grep -oE '\b[0-9]+\.[0-9]+' | head -n 1)
323+
echo "Detected PHPUnit version: ${PHPUNIT_VERSION}"
324+
MAJOR_VERSION=$(echo "${PHPUNIT_VERSION}" | cut -d. -f1)
325+
if [ "${MAJOR_VERSION}" -ge 10 ]; then
326+
if [ "${PHPUNIT_CONFIG}" = "tests/phpunit/multisite.xml" ]; then
327+
NEW_CONFIG="tests/phpunit/multisite10.xml"
328+
else
329+
NEW_CONFIG="phpunit10.xml.dist"
330+
fi
331+
echo "Using PHPUnit 10+ configuration: ${NEW_CONFIG}"
332+
echo "PHPUNIT_CONFIG=${NEW_CONFIG}" >> "$GITHUB_ENV"
333+
fi
334+
320335
- name: Run external HTTP tests
321336
if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
322337
continue-on-error: ${{ inputs.allow-errors }}

‎.github/workflows/test-build-processes.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ on:
3434
- '!phpcs.xml.dist'
3535
- '!phpstan.neon.dist'
3636
- '!phpunit.xml.dist'
37+
- '!phpunit10.xml.dist'
3738
- '!tsconfig.json'
3839
# Tests, unrelated tools, and other workflows do not affect the build.
3940
- '!tests/**'

‎.github/workflows/test-coverage.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ on:
1515
- '.nvmrc'
1616
- 'docker-compose.yml'
1717
- 'phpunit.xml.dist'
18+
- 'phpunit10.xml.dist'
1819
- 'tests/phpunit/multisite.xml'
20+
- 'tests/phpunit/multisite10.xml'
1921
pull_request:
2022
branches:
2123
- trunk
@@ -29,7 +31,9 @@ on:
2931
- '.nvmrc'
3032
- 'docker-compose.yml'
3133
- 'phpunit.xml.dist'
34+
- 'phpunit10.xml.dist'
3235
- 'tests/phpunit/multisite.xml'
36+
- 'tests/phpunit/multisite10.xml'
3337
# Once daily at 00:00 UTC.
3438
schedule:
3539
- cron: '0 0 * * *'

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ wp-tests-config.php
99
# Files and folders related to build/test tools
1010
.phpunit.result.cache
1111
/phpunit.xml
12+
/phpunit10.xml
13+
/phpunit-10.xml
1214
/.phpcs.xml
1315
/phpcs.xml
1416
.cache/*

0 commit comments

Comments
 (0)