From 778c4ee9d538449256135c1ff03361c706c400a0 Mon Sep 17 00:00:00 2001 From: robelsust Date: Sat, 10 Oct 2026 11:34:47 +0600 Subject: [PATCH 1/2] 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. --- .github/workflows/end-to-end-tests.yml | 1 + .github/workflows/performance.yml | 1 + .../workflows/phpunit-tests-full-matrix.yml | 1 + .github/workflows/phpunit-tests.yml | 1 + .../workflows/reusable-phpunit-tests-v1.yml | 2 +- .../workflows/reusable-phpunit-tests-v2.yml | 2 +- .../workflows/reusable-phpunit-tests-v3.yml | 15 ++++ .github/workflows/test-build-processes.yml | 1 + .github/workflows/test-coverage.yml | 4 + .gitignore | 2 + composer.json | 3 +- package.json | 1 + phpunit10.xml.dist | 85 +++++++++++++++++++ tests/phpunit/README.md | 17 ++++ tests/phpunit/multisite10.xml | 84 ++++++++++++++++++ 15 files changed, 217 insertions(+), 3 deletions(-) create mode 100644 phpunit10.xml.dist create mode 100644 tests/phpunit/multisite10.xml diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index e249f6e25475c..f5f228173bc43 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -32,6 +32,7 @@ on: - '!phpcs.xml.dist' - '!phpstan.neon.dist' - '!phpunit.xml.dist' + - '!phpunit10.xml.dist' - '!tsconfig.json' # Other test suites, tools, and workflows do not affect these tests. - '!tests/**' diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 808f299208bc6..57a051d47916e 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -32,6 +32,7 @@ on: - '!phpcs.xml.dist' - '!phpstan.neon.dist' - '!phpunit.xml.dist' + - '!phpunit10.xml.dist' - '!tsconfig.json' # Other test suites, tools, and workflows do not affect these tests. - '!tests/**' diff --git a/.github/workflows/phpunit-tests-full-matrix.yml b/.github/workflows/phpunit-tests-full-matrix.yml index eedbbdb087e4e..dcc0d82da71ab 100644 --- a/.github/workflows/phpunit-tests-full-matrix.yml +++ b/.github/workflows/phpunit-tests-full-matrix.yml @@ -42,6 +42,7 @@ on: - 'tools/vendors/**' - 'tools/webpack/**' - 'phpunit.xml.dist' + - 'phpunit10.xml.dist' - '.github/actions/setup-npm/**' - '.github/workflows/phpunit-tests.yml' - '.github/workflows/phpunit-tests-full-matrix.yml' diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index a212e3b6be563..d746215e5414a 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -46,6 +46,7 @@ on: - 'tools/vendors/**' - 'tools/webpack/**' - 'phpunit.xml.dist' + - 'phpunit10.xml.dist' - '.github/actions/setup-npm/**' - '.github/workflows/phpunit-tests.yml' - '.github/workflows/phpunit-tests-full-matrix.yml' diff --git a/.github/workflows/reusable-phpunit-tests-v1.yml b/.github/workflows/reusable-phpunit-tests-v1.yml index dc5a0d1edd982..a9a9fc5f6f584 100644 --- a/.github/workflows/reusable-phpunit-tests-v1.yml +++ b/.github/workflows/reusable-phpunit-tests-v1.yml @@ -247,4 +247,4 @@ jobs: - name: Run external HTTP tests if: ${{ ! inputs.multisite && ! inputs.split_slow && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c phpunit.xml.dist --group external-http + run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --group external-http diff --git a/.github/workflows/reusable-phpunit-tests-v2.yml b/.github/workflows/reusable-phpunit-tests-v2.yml index 628b5387f0e4f..56767756f0315 100644 --- a/.github/workflows/reusable-phpunit-tests-v2.yml +++ b/.github/workflows/reusable-phpunit-tests-v2.yml @@ -254,7 +254,7 @@ jobs: - name: Run external HTTP tests if: ${{ ! inputs.multisite && ! inputs.split_slow && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c phpunit.xml.dist --group external-http + run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --group external-http # __fakegroup__ is excluded to force PHPUnit to ignore the settings in phpunit.xml.dist. - name: Run (xDebug) tests diff --git a/.github/workflows/reusable-phpunit-tests-v3.yml b/.github/workflows/reusable-phpunit-tests-v3.yml index 024a4afd7f498..1c8c6c4fc8387 100644 --- a/.github/workflows/reusable-phpunit-tests-v3.yml +++ b/.github/workflows/reusable-phpunit-tests-v3.yml @@ -317,6 +317,21 @@ jobs: php -m | grep -i pcov ' + - name: Select PHPUnit configuration + run: | + 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) + echo "Detected PHPUnit version: ${PHPUNIT_VERSION}" + MAJOR_VERSION=$(echo "${PHPUNIT_VERSION}" | cut -d. -f1) + if [ "${MAJOR_VERSION}" -ge 10 ]; then + if [ "${PHPUNIT_CONFIG}" = "tests/phpunit/multisite.xml" ]; then + NEW_CONFIG="tests/phpunit/multisite10.xml" + else + NEW_CONFIG="phpunit10.xml.dist" + fi + echo "Using PHPUnit 10+ configuration: ${NEW_CONFIG}" + echo "PHPUNIT_CONFIG=${NEW_CONFIG}" >> "$GITHUB_ENV" + fi + - name: Run external HTTP tests if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }} continue-on-error: ${{ inputs.allow-errors }} diff --git a/.github/workflows/test-build-processes.yml b/.github/workflows/test-build-processes.yml index ed970276e9833..fdab4afc1e659 100644 --- a/.github/workflows/test-build-processes.yml +++ b/.github/workflows/test-build-processes.yml @@ -34,6 +34,7 @@ on: - '!phpcs.xml.dist' - '!phpstan.neon.dist' - '!phpunit.xml.dist' + - '!phpunit10.xml.dist' - '!tsconfig.json' # Tests, unrelated tools, and other workflows do not affect the build. - '!tests/**' diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index c29be2fb4043e..095b284b7dc97 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -15,7 +15,9 @@ on: - '.nvmrc' - 'docker-compose.yml' - 'phpunit.xml.dist' + - 'phpunit10.xml.dist' - 'tests/phpunit/multisite.xml' + - 'tests/phpunit/multisite10.xml' pull_request: branches: - trunk @@ -29,7 +31,9 @@ on: - '.nvmrc' - 'docker-compose.yml' - 'phpunit.xml.dist' + - 'phpunit10.xml.dist' - 'tests/phpunit/multisite.xml' + - 'tests/phpunit/multisite10.xml' # Once daily at 00:00 UTC. schedule: - cron: '0 0 * * *' diff --git a/.gitignore b/.gitignore index 15876fa47fee8..b55a1a88d2852 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ wp-tests-config.php # Files and folders related to build/test tools .phpunit.result.cache /phpunit.xml +/phpunit10.xml +/phpunit-10.xml /.phpcs.xml /phpcs.xml .cache/* diff --git a/composer.json b/composer.json index f61b6e5e72854..9a9267d825bf1 100644 --- a/composer.json +++ b/composer.json @@ -80,6 +80,7 @@ "format": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --report=summary,source", "lint": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --report=summary,source", "lint:errors": "@lint -n", - "test": [ "Composer\\Config::disableProcessTimeout", "@php ./vendor/phpunit/phpunit/phpunit" ] + "test": [ "Composer\\Config::disableProcessTimeout", "@php ./vendor/phpunit/phpunit/phpunit" ], + "test10": [ "Composer\\Config::disableProcessTimeout", "@php ./vendor/phpunit/phpunit/phpunit -c phpunit10.xml.dist" ] } } diff --git a/package.json b/package.json index 8f3be7558b3d2..d7e5e31ef474a 100644 --- a/package.json +++ b/package.json @@ -152,6 +152,7 @@ "env:pull": "node ./tools/local-env/scripts/docker.js pull", "test:performance": "wp-scripts test-playwright --config tests/performance/playwright.config.js", "test:php": "node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpunit", + "test:php10": "node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpunit -c phpunit10.xml.dist", "test:coverage": "npm run test:php -- --coverage-html ./coverage/html/ --coverage-php ./coverage/php/report.php --coverage-text=./coverage/text/report.txt", "test:e2e": "wp-scripts test-playwright --config tests/e2e/playwright.config.js", "test:visual": "wp-scripts test-playwright --config tests/visual-regression/playwright.config.js", diff --git a/phpunit10.xml.dist b/phpunit10.xml.dist new file mode 100644 index 0000000000000..937dc46e567e7 --- /dev/null +++ b/phpunit10.xml.dist @@ -0,0 +1,85 @@ + + + + + + tests/phpunit/tests + tests/phpunit/tests/rest-api/rest-autosaves-controller.php + + + + tests/phpunit/tests/rest-api/rest-autosaves-controller.php + + + + + ajax + ms-files + ms-required + external-http + html-api-web-platform-tests + + + + + src + + + + src/wp-includes/ID3 + src/wp-includes/IXR + src/wp-includes/PHPMailer + src/wp-includes/Requests + src/wp-includes/php-ai-client + src/wp-includes/SimplePie + src/wp-includes/sodium_compat + src/wp-includes/Text + + + src/wp-content + + src/wp-admin/includes/class-ftp.php + src/wp-admin/includes/class-ftp-pure.php + src/wp-admin/includes/class-ftp-sockets.php + src/wp-admin/includes/class-pclzip.php + src/wp-admin/includes/deprecated.php + src/wp-admin/includes/ms-deprecated.php + + src/wp-includes/atomlib.php + src/wp-includes/class-IXR.php + src/wp-includes/class-json.php + src/wp-includes/class-phpass.php + src/wp-includes/class-pop3.php + src/wp-includes/class-requests.php + src/wp-includes/class-simplepie.php + src/wp-includes/class-snoopy.php + src/wp-includes/deprecated.php + src/wp-includes/ms-deprecated.php + src/wp-includes/pluggable-deprecated.php + src/wp-includes/rss.php + + + + + + + + + diff --git a/tests/phpunit/README.md b/tests/phpunit/README.md index 679ed831112d2..9500fe60f551e 100644 --- a/tests/phpunit/README.md +++ b/tests/phpunit/README.md @@ -6,6 +6,23 @@ For more information, please review the relevant Core Handbook pages: - [PHP: PHPUnit](https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/) - [Writing PHP Tests](https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/) +## Configuration Files + +WordPress core maintains separate configuration files to support both PHPUnit 9 and PHPUnit 10.1+: + +- `phpunit.xml.dist` and `tests/phpunit/multisite.xml`: Used for PHPUnit 9 and earlier. +- `phpunit10.xml.dist` and `tests/phpunit/multisite10.xml`: Used for PHPUnit 10.1 and later. + +### Running Tests Locally + +When running tests via Composer: +- `composer test`: Runs tests using the default configuration (PHPUnit < 10). +- `composer test10`: Runs tests using `phpunit10.xml.dist` (PHPUnit 10+). + +When running tests via npm and Docker: +- `npm run test:php`: Runs tests using the default configuration. +- `npm run test:php10`: Runs tests using `phpunit10.xml.dist`. + ## Run the full matrix on a pull request Add the `Full PHPUnit Matrix` label to a pull request in `WordPress/wordpress-develop` to run the same PHP and database combinations as the weekly scheduled run. The label-triggered workflow uses the same path filters as normal PHPUnit runs. diff --git a/tests/phpunit/multisite10.xml b/tests/phpunit/multisite10.xml new file mode 100644 index 0000000000000..57d6d1b007069 --- /dev/null +++ b/tests/phpunit/multisite10.xml @@ -0,0 +1,84 @@ + + + + + + + + + + tests + tests/rest-api/rest-autosaves-controller.php + + + + tests/rest-api/rest-autosaves-controller.php + + + + + ajax + ms-files + ms-excluded + external-http + oembed-headers + html-api-web-platform-tests + + + + + ../../src + + + + ../../src/wp-includes/ID3 + ../../src/wp-includes/IXR + ../../src/wp-includes/PHPMailer + ../../src/wp-includes/Requests + ../../src/wp-includes/php-ai-client + ../../src/wp-includes/SimplePie + ../../src/wp-includes/sodium_compat + ../../src/wp-includes/Text + + + ../../src/wp-content + + ../../src/wp-admin/includes/class-ftp.php + ../../src/wp-admin/includes/class-ftp-pure.php + ../../src/wp-admin/includes/class-ftp-sockets.php + ../../src/wp-admin/includes/class-pclzip.php + ../../src/wp-admin/includes/deprecated.php + ../../src/wp-admin/includes/ms-deprecated.php + + ../../src/wp-includes/atomlib.php + ../../src/wp-includes/class-IXR.php + ../../src/wp-includes/class-json.php + ../../src/wp-includes/class-phpass.php + ../../src/wp-includes/class-pop3.php + ../../src/wp-includes/class-requests.php + ../../src/wp-includes/class-simplepie.php + ../../src/wp-includes/class-snoopy.php + ../../src/wp-includes/deprecated.php + ../../src/wp-includes/ms-deprecated.php + ../../src/wp-includes/pluggable-deprecated.php + ../../src/wp-includes/rss.php + + + From 479ae87f5613e0498788b2953b0e54b3555c706b Mon Sep 17 00:00:00 2001 From: robelsust Date: Sat, 10 Oct 2026 20:48:01 +0600 Subject: [PATCH 2/2] Tests: Address review feedback on PHPUnit 10 configuration and workflow integration - Remove --verbose and -v options from reusable-phpunit-tests-v3.yml since PHPUnit 10 rejects them. - Pass -c "${PHPUNIT_CONFIG}" to the Xdebug test step in reusable-phpunit-tests-v3.yml. - Restore JUnit logging in tests/phpunit/multisite10.xml matching tests/phpunit/multisite.xml. See #66210, #62004. --- .github/workflows/reusable-phpunit-tests-v3.yml | 9 ++++----- tests/phpunit/multisite10.xml | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/reusable-phpunit-tests-v3.yml b/.github/workflows/reusable-phpunit-tests-v3.yml index 1c8c6c4fc8387..eb38e7484286b 100644 --- a/.github/workflows/reusable-phpunit-tests-v3.yml +++ b/.github/workflows/reusable-phpunit-tests-v3.yml @@ -335,7 +335,7 @@ jobs: - name: Run external HTTP tests if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }} continue-on-error: ${{ inputs.allow-errors }} - run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c "${PHPUNIT_CONFIG}" --group external-http + run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -c "${PHPUNIT_CONFIG}" --group external-http # PHPUnit versions used below PHP 7.3 do not support --fail-on-empty-test-suite. - name: Run PHPUnit tests${{ inputs.phpunit-test-groups && format( ' ({0} groups)', inputs.phpunit-test-groups ) || '' }}${{ inputs.coverage-report && ' with coverage report' || '' }} @@ -343,7 +343,6 @@ jobs: run: | node ./tools/local-env/scripts/docker.js ${{ inputs.coverage-report && 'exec' || 'run' }} \ php ./vendor/bin/phpunit \ - --verbose \ -c "${PHPUNIT_CONFIG}" \ ${{ inputs.phpunit-test-groups && '--group "${TEST_GROUPS}"' || '' }} \ ${{ inputs.phpunit-test-groups && inputs.php >= '7.3' && '--fail-on-empty-test-suite' || '' }} \ @@ -412,18 +411,18 @@ jobs: - name: Run AJAX tests if: ${{ ! inputs.phpunit-test-groups && ! inputs.coverage-report }} continue-on-error: ${{ inputs.allow-errors }} - run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c "${PHPUNIT_CONFIG}" --group ajax + run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -c "${PHPUNIT_CONFIG}" --group ajax - name: Run ms-files tests as a multisite install if: ${{ inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }} continue-on-error: ${{ inputs.allow-errors }} - run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c "${PHPUNIT_CONFIG}" --group ms-files + run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -c "${PHPUNIT_CONFIG}" --group ms-files # __fakegroup__ is excluded to force PHPUnit to ignore the settings in phpunit.xml.dist. - name: Run (Xdebug) tests if: ${{ ! inputs.phpunit-test-groups && ! inputs.coverage-report }} continue-on-error: ${{ inputs.allow-errors }} - run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__ + run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -c "${PHPUNIT_CONFIG}" --group xdebug --exclude-group __fakegroup__ - name: Upload test coverage report to Codecov if: ${{ inputs.coverage-report }} diff --git a/tests/phpunit/multisite10.xml b/tests/phpunit/multisite10.xml index 57d6d1b007069..eed9c0540bcf9 100644 --- a/tests/phpunit/multisite10.xml +++ b/tests/phpunit/multisite10.xml @@ -81,4 +81,7 @@ ../../src/wp-includes/rss.php + + +