When running WordPress core PHPUnit tests via phpunit-test-runner, tests fail with a fatal error because a generated build artifact is expected under src/, but is actually created under build/.
Specifically, PHPUnit bootstraps WordPress from src/, which requires:
src/wp-includes/build/routes.php`
However, after a successful prepare.php, this file is generated at:
build/wp-includes/build/routes.php
As a result, running test.php fails even though prepare.php exits successfully.
Error output
PHP Warning: require(/tmp/wp-test-runner/src/wp-includes/build/routes.php):
Failed to open stream: No such file or directory in wp-settings.php
PHP Fatal error: Uncaught Error: Failed opening required
'/tmp/wp-test-runner/src/wp-includes/build/routes.php'
What works / what doesn’t
-
php prepare.php
✅ completes successfully
✅ build artifacts are generated under build/
-
php test.php
❌ fails because tests bootstrap from src/, where routes.php does not exist
Verified details
routes.php does exist after prepare:
build/wp-includes/build/routes.php
-
vendor/ (PHPUnit) lives in the repo root, so pointing tests directly at build/ breaks PHPUnit execution.
-
The runner enforces WPT_TEST_DIR == WPT_PREPARE_DIR in local mode, which makes it impossible to cleanly switch to build/ for tests only.
Environment
- Runner:
WordPress/phpunit-test-runner
- WordPress source: wordpress-develop (default clone)
- PHP: 8.2.x
- Node: 20.x
- OS: Ubuntu 24.04 (LXD container)
When running WordPress core PHPUnit tests via
phpunit-test-runner, tests fail with a fatal error because a generated build artifact is expected undersrc/, but is actually created underbuild/.Specifically, PHPUnit bootstraps WordPress from
src/, which requires:However, after a successful
prepare.php, this file is generated at:As a result, running
test.phpfails even thoughprepare.phpexits successfully.Error output
What works / what doesn’t
php prepare.php✅ completes successfully
✅ build artifacts are generated under
build/php test.php❌ fails because tests bootstrap from
src/, where routes.php does not existVerified details
routes.phpdoes exist after prepare:vendor/(PHPUnit) lives in the repo root, so pointing tests directly atbuild/breaks PHPUnit execution.The runner enforces
WPT_TEST_DIR == WPT_PREPARE_DIRin local mode, which makes it impossible to cleanly switch tobuild/for tests only.Environment
WordPress/phpunit-test-runner