Skip to content

fix(phpunit): apply wpConfigDefines before plugin activation in PHPUnit recipes - #2616

Merged
chubes4 merged 1 commit into
mainfrom
fix/issue-2615-wp-codebox
Dec 2, 2026
Merged

chubes4 merged 1 commit into
mainfrom
fix/issue-2615-wp-codebox

Conversation

@chubes4

@chubes4 chubes4 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

PHPUnit recipes previously passed wpConfigDefines only to the test runner, so plugins that needed those constants could fail during activation. The recipe now writes the constants to the runtime’s wp-config.php before activation and still passes the same values to PHPUnit’s separate test config. In a local CLI run, the fixture that requires FIXTURE_ENV failed in activate_plugins before the fix; after the fix, it activated and its PHPUnit test passed without duplicate-constant warnings.

What changed

  • Reuse the bench recipe’s defineWpConfigConsts step, with an explicit wp-config rewrite for PHPUnit.
  • Keep runtime constants out of PHP’s request-wide predefines so PHPUnit’s multisite pre-install overrides still win.
  • Add a regression case for blueprint step ordering, unchanged PHPUnit arguments, and the WPMU_PLUGIN_DIR override.
  • Compatibility: Additive. Bench recipes and PHPUnit recipes without wpConfigDefines retain their existing behavior.

Verification

All gates passed on 9721b76. Base main@81e8bd5 unchanged.

  • HOMEBOY_LINT_BASE=81e8bd506d50ff0a1366a5a9789915950d4ad488 homeboy --placement local review lint wp-codebox --path . --…: passed, 161641 ms; retained gate metadata.
  • npm run build: passed, 604 ms; retained gate metadata.
  • npx tsx --test tests/phpunit-discovery-only.test.ts tests/phpunit-project-autoload.test.ts: passed, 2609 ms; retained gate metadata.
  • repro: none (no repro gate was declared, so these gates do not prove the issue).
  • CI: pending

Cook run
  • Cook ID: agent-task-f81925ac-a559-46bf-82d5-0238b5c2faf0
  • Attempt run ID: agent-task-f81925ac-a559-46bf-82d5-0238b5c2faf0-attempt-1-a0224677
  • Gate 1: tree 03300929127196c7f8581e721cb55d25dea71f6e
  • Gate 2: tree 03300929127196c7f8581e721cb55d25dea71f6e
  • Gate 3: tree 03300929127196c7f8581e721cb55d25dea71f6e

Evidence

  • Local CLI fixture: recipe build phpunit generated the recipe with wpConfigDefines: { FIXTURE_ENV: true }, then recipe-run reported run_blueprint_steps completed during runtime.create, activate_plugins completed with fixture-env/fixture-env.php active, and FixtureEnvTest::test_fixture_env passed. No duplicate-constant warnings appeared in the CLI output or artifacts. The same fixture on the unchanged checkout failed in activate_plugins with FIXTURE_ENV missing.
  • The focused PHPUnit regression failed before the fix and passed afterward. The Playground bootstrap test also passed locally. Multisite override precedence was checked in the focused tests, not in a separate live multisite CLI run.

AI disclosure

Tool: Homeboy Cook. Agent: Homeboy (roadie). Model: roadie · route cook-heavy · served gpt-6.2-sol. Cook time: 39m50s.

AI traced the startup and activation order, implemented the fix, and verified it with focused tests and a CLI fixture, under the direction of the Cook requester. Homeboy reports controller verification separately from this account of the AI's work. A human reviews before merge.

Refs #2615

@chubes4

chubes4 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

End-to-end check through Homeboy's WordPress PHPUnit adapter (homeboy --placement local review test --extension wordpress --setting-json 'wp_config_defines={"FIXTURE_ENV":true}'). The fixture plugin fatals at load when FIXTURE_ENV is undefined and has one WP_UnitTestCase asserting the constant:

  • main (3ada50d): activate_plugins fatals with FIXTURE_ENV missing; Total: 0, zero executed tests.
  • this PR (7887a33): Total: 1, Passed: 1, no "already defined" notices.

The browser failure (service-worker preview proxy) also fails on main.

AI disclosure: Claude Opus (Pi, via Roadie) reviewed this and ran the end-to-end check. The implementation is GPT-6.2 Sol (Homeboy Cook).

@chubes4
chubes4 marked this pull request as ready for review December 2, 2026 18:46
@chubes4
chubes4 merged commit 4eafeb7 into main Dec 2, 2026
4 of 5 checks passed
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.

1 participant