Skip to content

fix: load PHPUnit harness before project-mode TestSuite discovery #1771

Description

@chubes4

Problem

The WordPress PHPUnit runner can enter bootstrap-mode=project without a loaded PHPUnit harness, then construct PHPUnit\Framework\TestSuite during test discovery. Projects whose native bootstrap does not load PHPUnit fail before any project tests execute:

BOOTSTRAP FAILURE: load_tests: Uncaught Error: Class "PHPUnit\Framework\TestSuite" not found

This was originally tracked as Extra-Chill/homeboy#8019. Ownership tracing shows Homeboy only delegates release tests to the WordPress extension, which delegates recipe construction to WP Codebox. The constructor is in packages/runtime-playground/src/phpunit-command-handlers.ts; project mode currently permits boot to continue without an autoloader before discovery reaches new PHPUnit\Framework\TestSuite(...).

Expected

The runtime must load or require the configured PHPUnit harness before constructing a test suite while preserving project-owned WordPress/bootstrap behavior. Missing harness configuration should fail with an actionable bootstrap error rather than an undefined PHPUnit class.

Acceptance criteria

  1. Reproduce project mode with a native bootstrap that does not load PHPUnit.
  2. Ensure the PHPUnit harness is initialized before TestSuite construction.
  3. Preserve custom project bootstrap ordering and managed mode.
  4. Add deterministic regression coverage proving test discovery executes after harness initialization.
  5. Run the repository test/lint gates relevant to runtime-playground.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions