Skip to content

PHPUnit tests fail: routes.php generated under build/ but tests bootstrap from src/ #292

@avatarf

Description

@avatarf

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions