Opened 7 weeks ago
Last modified 6 days ago
#66210 new task (blessed)
Tests: Add a separate PHPUnit configuration file for PHPUnit 10.1 and later
| Reported by: | lancewillett | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Build/Test Tools | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: | tests |
Description
Split from #62004 (problem 1 there).
PHPUnit 10.0 and 10.1 changed the XML configuration file, and --migrate-configuration doesn't carry over the top-level <phpunit> settings. Trunk still has to run on PHPUnit 9 for PHP 7.4, so it needs two files: the current phpunit.xml.dist for PHPUnit 9 and earlier, and a new one for PHPUnit 10.1 and later.
Scope:
- add the second configuration file
- pick the right file in CI based on the installed PHPUnit version
- document which file to use: Composer scripts and the handbook
A draft of this sits on the Build/Test Tools project board.
Change History (8)
This ticket was mentioned in PR #14145 on WordPress/wordpress-develop by @therssoftware.
5 weeks ago
#2
- Keywords has-patch has-unit-tests added; needs-patch removed
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 #62004 as scoped in #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 correspondingdisplayDetailsOnTestsThatTrigger*="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
- 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" />.
- Conforms to PHPUnit 10.1+ XML Schema (
- Added
tests/phpunit/multisite10.xml:- The PHPUnit 10.1+ multisite counterpart to
tests/phpunit/multisite.xml. - Sets
WP_TESTS_MULTISITE="1"andWP_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 totests/phpunit/.
- The PHPUnit 10.1+ multisite counterpart to
- Workflow & CI Automation:
reusable-phpunit-tests-v3.yml: Added aSelect PHPUnit configurationstep before running tests that detects the installed PHPUnit version inside the container. If PHPUnit version >= 10, it automatically switchesPHPUNIT_CONFIGtophpunit10.xml.dist(ortests/phpunit/multisite10.xmlwhen testing multisite).reusable-phpunit-tests-v1.yml&reusable-phpunit-tests-v2.yml: Fixed theexternal-httptest 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, andtest-coverage.ymlto trigger onphpunit10.xml.distandmultisite10.xml, while excluding!phpunit10.xml.distfrom asset/e2e/performance workflows.
- 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.xmland/phpunit-10.xmlto ignore local developer overrides.tests/phpunit/README.md: Added aConfiguration Filessection documenting which configuration file to use for PHPUnit 9 vs PHPUnit 10+.
Verification
- Both
phpunit10.xml.distandtests/phpunit/multisite10.xmlwere strictly validated against official PHPUnit 10.1, 10.5, and 11.0 XSD schemas viaxmllint --noout --schemawith 0 errors. composer validateexecuted with 0 errors.package.jsonsyntax validated.- Existing PHPUnit test suite confirmed running without regressions under PHPUnit 9.
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.
#3
@
5 weeks ago
I have created a pull request addressing all items in the scope:
PR: https://github.com/WordPress/wordpress-develop/pull/14145
Summary of work done:
- Created
phpunit10.xml.distandtests/phpunit/multisite10.xmlcomplying strictly with PHPUnit 10.1+ XML Schema (validated against official 10.1, 10.5, and 11.0 XSDs withxmllint). - Configured
failOnDeprecation="true",failOnNotice="true",failOnWarning="true",failOnRisky="true"and display details attributes to maintain strict error and deprecation handling as discussed in #54183 and #62004. - Updated CI workflows:
- Added automatic detection in
reusable-phpunit-tests-v3.ymlto switchPHPUNIT_CONFIGto the PHPUnit 10+ counterpart when running on PHPUnit 10+. - Replaced hard-coded
-c phpunit.xml.distwith-c "${PHPUNIT_CONFIG}"for theexternal-httpstep inreusable-phpunit-tests-v1.ymlandreusable-phpunit-tests-v2.yml. - Updated path triggers in
phpunit-tests.yml,phpunit-tests-full-matrix.yml, andtest-coverage.yml.
- Added automatic detection in
- Added
composer test10andnpm run test:php10scripts, added/phpunit10.xmlto.gitignore, and documented configuration usage intests/phpunit/README.md.
@therssoftware commented on PR #14145:
5 weeks ago
#4
Thanks for the thorough review and catching these integration gaps @lancewillett!
I have addressed all three items in commit https://github.com/WordPress/wordpress-develop/commit/479ae87f56:
- Removed
--verboseand-vinreusable-phpunit-tests-v3.yml: Removed from all test invocation steps (external-http, main tests,ajax,ms-files, andxdebug) to resolve the PHPUnit 10Unknown option "--verbose"error. - Passed
-c "${PHPUNIT_CONFIG}"to Xdebug tests: TheRun (Xdebug) testsstep now uses-c "${PHPUNIT_CONFIG}"so it respects the dynamic PHPUnit 10+ configuration selection. - Restored JUnit logging in
tests/phpunit/multisite10.xml: Added<logging><junit outputFile="build/logs/junit.xml" /></logging>matchingtests/phpunit/multisite.xml. Both XML files re-validated cleanly against PHPUnit 10.1, 10.5, and 11.0 schemas.
@lancewillett commented on PR #14145:
2 weeks ago
#5
@johnbillion, could you give this an independent review before we land it? The author addressed the PHPUnit 10 invocation and configuration issues, and my code approval stands. I’m holding this larger integration change for a second review of the approach.
<sub>AI review · <code>gpt-6</code></sub>
@lancewillett commented on PR #14145:
9 days ago
#6
@robelsust this now conflicts with trunk in .github/workflows/reusable-phpunit-tests-v3.yml, after r65292 switched local coverage to the PCOV extension in the Docker images. Could you rebase onto trunk? My earlier approval stands; I'll re-check the rebased head.
<sub>AI review · <code>claude-opus-5-5</code></sub>
@therssoftware commented on PR #14145:
9 days ago
#7
@lancewillett Rebased cleanly onto latest trunk and resolved the conflict in .github/workflows/reusable-phpunit-tests-v3.yml with the r65292 PCOV changes. Ready for your re-check!
@johnbillion commented on PR #14145:
6 days ago
#8
This is looking good but I think we can be more clever about the config file loading so we don't need to introduce new commands with the 10 suffix in their name. I'm trying a few things.
Scope notes from trunk:
phpunit.xml.distandtests/phpunit/multisite.xml..github/workflows/phpunit-tests.ymlpicks between them, so each needs a PHPUnit 10.1+ counterpart.-c phpunit.xml.distinreusable-phpunit-tests-v1.ymlandreusable-phpunit-tests-v2.yml.phpunit.xml.distsetsconvertErrorsToExceptions,convertWarningsToExceptions,convertNoticesToExceptionsandconvertDeprecationsToExceptions. PHPUnit 10.0 removed all four, along with the behavior they controlled, so the new file needs another way to keep failing on PHP deprecations. See #54183.