Skip to content

Tests: Pick the PHPUnit configuration file from the installed PHPUnit version - #1

Draft
johnbillion wants to merge 4 commits into
robelsust:feature/66210-phpunit-10-configfrom
johnbillion:66210-phpunit-version-static
Draft

johnbillion wants to merge 4 commits into
robelsust:feature/66210-phpunit-10-configfrom
johnbillion:66210-phpunit-version-static

Conversation

@johnbillion

Copy link
Copy Markdown

Stacks on WordPress#14145 (WordPress#14145). Merging this into feature/66210-phpunit-10-config adds these changes to that PR.

Removes the separate composer test10 and npm run test:php10 commands. composer test, npm run test:php and CI now pick the configuration file that matches the installed PHPUnit version.

  • Adds tests/phpunit/phpunit-config.php, which prints the configuration file for the installed PHPUnit version. Pass it phpunit.xml.dist or tests/phpunit/multisite.xml to get the matching file. Run it with no argument to get the single site default, or a local phpunit.xml if one exists.
  • composer test runs phpunit -c "$(php ./tests/phpunit/phpunit-config.php)".
  • npm run test:php runs composer test inside the container, so the version check happens there.
  • In CI, the "Select PHPUnit configuration" step passes PHPUNIT_CONFIG through the script. The step is skipped on older branches that don't have the script, because they run this workflow from trunk.
  • Removes the unused /phpunit-10.xml entry from .gitignore.
  • Rewords the README to say "PHPUnit 9 and earlier" and "PHPUnit 10 and later". It also notes that PHPUnit 10.0 can't read the 10.x files.

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

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Implementation and testing. I reviewed the changes.

…stead of running it in Docker.

Composer installs dependencies on the runner with the same PHP version as the container, so the version can be read with `Composer\InstalledVersions` straight after install. This removes a container start from every job.
…led PHPUnit version.

Adds tests/phpunit/phpunit-config.php, which prints the configuration file for the installed version. composer test, npm run test:php and CI use it, which removes the test10 and test:php10 scripts.
@johnbillion

johnbillion commented Nov 10, 2026 •

Copy link
Copy Markdown
Author

@robelsust @lancewillett What do you think about this? I've encapsulated the config file logic into a phpunit-config.php file that gets called inline for the -c parameter. It means we don't need new separate 10 suffixed commands.

I tweaked the readme too.

@lancewillett

Copy link
Copy Markdown

Thanks John, I prefer keeping the existing commands and centralizing configuration selection. The selector passed checks for PHPUnit 9/10/11 version metadata, single-site/multisite mappings, and local overrides. Composer also preserved forwarded arguments, and PHPUnit 9 honored a later explicit -c option.

One portability concern before landing: $(php ...) in the Composer script requires a POSIX shell; Composer also supports native Windows shells. Could we keep the automatic selection without shell substitution? I haven’t run this on Windows or completed a full PHPUnit-version matrix.

AI review · gpt-6

@johnbillion

Copy link
Copy Markdown
Author

For users on Windows running tests via Docker (npm run test:php) it works as expected. This does break users on Windows who want to run the tests locally.

There's not really a clean way to handle this unless we go with indirection, for example launching phpunit via proc_open in a wrapper script. Not sure what's best.

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