Skip to content

Tests: Add a separate PHPUnit configuration file for PHPUnit 10.1 and later - #14145

Open
robelsust wants to merge 2 commits into
WordPress:trunkfrom
robelsust:feature/66210-phpunit-10-config
Open

robelsust wants to merge 2 commits into
WordPress:trunkfrom
robelsust:feature/66210-phpunit-10-config

Conversation

@robelsust

@robelsust robelsust commented Oct 10, 2026 •

Copy link
Copy Markdown

Introduces separate PHPUnit 10.1+ configuration files (phpunit10.xml.dist and tests/phpunit/multisite10.xml) alongside the existing PHPUnit 9 configuration files (phpunit.xml.dist and tests/phpunit/multisite.xml), fulfilling Problem 1 of Trac #62004 as scoped in Trac #66210.

Background & Context

  • In PHPUnit 10.0 and 10.1, the XML configuration schema changed significantly. Attributes on the root <phpunit> element (convertErrorsToExceptions, convertWarningsToExceptions, convertNoticesToExceptions, convertDeprecationsToExceptions) were removed.
  • PHP native deprecations, notices, and warnings are now configured via failOnDeprecation="true", failOnNotice="true", failOnWarning="true", failOnRisky="true", and the corresponding displayDetailsOnTestsThatTrigger*="true" attributes.
  • The <filter><whitelist> element was replaced by <source><include> and <source><exclude>.
  • The <logging><log type="junit" target="..."/></logging> element was replaced by <logging><junit outputFile="..."/></logging>.
  • Because WordPress Core trunk must continue to support PHPUnit 9 for PHP 7.4 while supporting PHPUnit 10.1+ on newer PHP versions, separate configuration files are needed.

Changes

  1. Added phpunit10.xml.dist:

    • Conforms to PHPUnit 10.1+ XML Schema (https://schema.phpunit.de/10.1/phpunit.xsd).
    • Configures failOnDeprecation="true", failOnNotice="true", failOnWarning="true", failOnRisky="true", and details display.
    • Migrates code coverage path definitions into <source><include> and <source><exclude>.
    • Modernizes logging to <logging><junit outputFile="tests/phpunit/build/logs/junit.xml" />.
  2. Added tests/phpunit/multisite10.xml:

    • The PHPUnit 10.1+ multisite counterpart to tests/phpunit/multisite.xml.
    • Sets WP_TESTS_MULTISITE="1" and WP_RUN_CORE_TESTS="1".
    • Excludes the appropriate test groups (ajax, ms-files, ms-excluded, external-http, oembed-headers, html-api-web-platform-tests).
    • Configures <source> paths relative to tests/phpunit/.
  3. Workflow & CI Automation:

    • reusable-phpunit-tests-v3.yml: Added a Select PHPUnit configuration step before running tests that detects the installed PHPUnit version inside the container. If PHPUnit version >= 10, it automatically switches PHPUNIT_CONFIG to phpunit10.xml.dist (or tests/phpunit/multisite10.xml when testing multisite).
    • reusable-phpunit-tests-v1.yml & reusable-phpunit-tests-v2.yml: Fixed the external-http test step which previously hard-coded -c phpunit.xml.dist, now correctly using -c "${PHPUNIT_CONFIG}".
    • Path Triggers: Updated .github/workflows/phpunit-tests.yml, phpunit-tests-full-matrix.yml, and test-coverage.yml to trigger on phpunit10.xml.dist and multisite10.xml, while excluding !phpunit10.xml.dist from asset/e2e/performance workflows.
  4. Developer Tooling & Documentation:

    • composer.json: Added "test10": [ "Composer\\Config::disableProcessTimeout", "@php ./vendor/phpunit/phpunit/phpunit -c phpunit10.xml.dist" ].
    • package.json: Added "test:php10": "node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpunit -c phpunit10.xml.dist".
    • .gitignore: Added /phpunit10.xml and /phpunit-10.xml to ignore local developer overrides.
    • tests/phpunit/README.md: Added a Configuration Files section documenting which configuration file to use for PHPUnit 9 vs PHPUnit 10+.

Verification

  • Both phpunit10.xml.dist and tests/phpunit/multisite10.xml were strictly validated against official PHPUnit 10.1, 10.5, and 11.0 XSD schemas via xmllint --noout --schema with 0 errors.
  • composer validate executed with 0 errors.
  • package.json syntax validated.
  • Existing PHPUnit test suite confirmed running without regressions under PHPUnit 9.

Trac ticket: https://core.trac.wordpress.org/ticket/66210

Use of AI Tools

AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini
Used for: Validating schema conformity against PHPUnit 10.1/10.5/11.0 XSD specifications, updating CI workflow configuration detection and reusable test runner workflows, and authoring developer documentation. All changes were reviewed, verified, and validated locally.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props therssoftware, lancewillett.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

… 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.
@robelsust
robelsust force-pushed the feature/66210-phpunit-10-config branch from ce49f65 to 778c4ee Compare October 10, 2026 06:08
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separate configurations fit the ticket’s scope. Please address three integration gaps before landing:

  1. In reusable-phpunit-tests-v3.yml, remove or version-gate --verbose and -v. PHPUnit 10 rejects these options; I reproduced Unknown option "--verbose" with PHPUnit 10.5.60 in Docker.
  2. Pass -c "${PHPUNIT_CONFIG}" to the xDebug test step too. It currently bypasses the new configuration selection.
  3. Restore JUnit logging in tests/phpunit/multisite10.xml, matching the existing multisite configuration:
    <logging>
        <junit outputFile="build/logs/junit.xml" />
    </logging>
    This preserves the output consumed by CI reporting and timing tools.

Both XML files passed PHPUnit 10.1 schema validation, and isolated PHPUnit 10 probes confirmed that their settings fail on deprecations, notices, and warnings. Actionlint passed. CI is green, but the inspected PHP 8.5 job uses PHPUnit 9.6, so it does not exercise the new configuration.

These are focused configuration/invocation fixes; completing the broader PHPUnit 10 migration can remain separate.

AI review · gpt-6

…ow 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.
@robelsust

Copy link
Copy Markdown
Author

Thanks for the thorough review and catching these integration gaps @lancewillett!

I have addressed all three items in commit 479ae87f56:

  1. Removed --verbose and -v in reusable-phpunit-tests-v3.yml: Removed from all test invocation steps (external-http, main tests, ajax, ms-files, and xdebug) to resolve the PHPUnit 10 Unknown option "--verbose" error.
  2. Passed -c "${PHPUNIT_CONFIG}" to Xdebug tests: The Run (Xdebug) tests step now uses -c "${PHPUNIT_CONFIG}" so it respects the dynamic PHPUnit 10+ configuration selection.
  3. Restored JUnit logging in tests/phpunit/multisite10.xml: Added <logging><junit outputFile="build/logs/junit.xml" /></logging> matching tests/phpunit/multisite.xml. Both XML files re-validated cleanly against PHPUnit 10.1, 10.5, and 11.0 schemas.

@lancewillett
lancewillett self-requested a review October 10, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants