Skip to content

fix(phpunit): reset project-mode database to core's test-install state - #2634

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

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

Conversation

@chubes4

@chubes4 chubes4 commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

In bootstrap-mode=project, PHPUnit reused the site Playground installed. That site has pretty permalinks, while core's tests/phpunit/includes/install.php leaves plain ones, so plugin suites built different URLs under Codebox than in core-based CI. Project mode now runs wp-phpunit's own install.php in a separate Playground request before the PHPUnit request. This stands in for the shell call core's bootstrap makes and Playground cannot. Suites start with permalink_structure === '' and flushed rewrite rules.

What changed

  • Project-mode wordpress.phpunit runs wp-phpunit's includes/install.php against wptests_ tables in a separate request, then boots the project bootstrap with WP_TESTS_SKIP_INSTALL=1 against those tables. This reuses the separate-request install that managed multisite already used, now single-site aware (phpunitTestInstallCode, formerly phpunitMultisitePreinstallCode).
  • After core's installer, the test install stores permalink_structure as '' (what core's multisite branch does; its single-site branch deletes the option) and flushes the rewrite rules, so get_option( 'permalink_structure' ) === '' before the first test.
  • If the configured tests directory has no includes/install.php, the install step is skipped and project mode falls back to the existing Playground wp_ site as before.
  • Main vs PR, from the new end-to-end test tests/playground-phpunit-project-install-state.integration.test.ts (PHPUnit 9.6 + wp-phpunit, project mode, core bootstrap.php): on main, permalink_structure captured after the project bootstrap, before the first test, was '/%year%/%monthnum%/%day%/%postname%/' and the test failed. On this PR it is '' with plain permalinks and empty rewrite_rules, get_pagenum_link(2) yields ?paged=2, and the test passes.

Verification

All gates passed on 14c6805c639d. Base main: gated on 2e5a985e9d1d, target now 2e5a985e9d1d, re-verified: no.

  • HOMEBOY_LINT_BASE=2e5a985e9d1d1f0b52b5cb1d9ef109487aa7836c homeboy --placement local review lint wp-codebox --path . --…: passed, 91800 ms; retained gate metadata.
  • npm run build: passed, 666 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-d7dfcff3-0317-4bfb-b636-140a75236787
  • Attempt run ID: agent-task-d7dfcff3-0317-4bfb-b636-140a75236787-attempt-1-a4584f0b
  • Gate 1: tree 0bdbac93b560d1d14d586f5575be2a704da47143
  • Gate 2: tree 0bdbac93b560d1d14d586f5575be2a704da47143

Delivery

  • Delivered: Project mode starts from core's test install state (permalink_structure '' and flushed rewrite rules) through the single project-mode setup path
  • Delivered: Reuse core's install.php, not a hand-copied list of option resets
  • Delivered: End-to-end project-mode test asserting permalink_structure === '' before the first test, failing on main and passing on the PR
  • Delivered: Main vs PR result in the PR body

Evidence

  • Existing Playground PHPUnit integration tests passed locally: the PHPUnit 9/10/11/12 isolation tests (including project-mode fatal and empty-child subtests), the PHPUnit 11 project recipe test and the bootstrap-failure test. The phpunit-project-autoload, discovery-only, runtime-failure-diagnostics, structured-evidence and smoke-discovery tests also passed.
  • With the change: the new e2e test passed (1 test, 0 failures, 0 errors). Initial permalink_structure was '', using_permalinks false, rewrite_rules empty, and get_pagenum_link(2) contained '?paged=2'.

AI disclosure

Tool: Homeboy Cook. Agent: Homeboy (roadie). Model: roadie · route cook-heavy · served claude-opus-5-5. Cook time: 1h23m.

The AI traced the project-mode bootstrap, core's install.php and the existing multisite separate-request install, then made that install path general for project mode. It wrote unit and end-to-end tests and ran the end-to-end test against both main and the change, 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 #2628

@chubes4
chubes4 marked this pull request as ready for review December 5, 2026 00:03
@chubes4

chubes4 commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed: project mode now runs wp-phpunit's own includes/install.php in a separate Playground request, reusing the existing multisite pre-install path. That is the in-sandbox equivalent of core's system( php install.php ). It then stores permalink_structure = '' and flushes rewrite rules in both the single-site and multisite branches. The Cook's end-to-end project-mode test (PHPUnit 9.6 + wp-phpunit) saw /%year%/%monthnum%/%day%/%postname%/ before the first test on main and '' with ?paged=2 here. CI is green except browser, which also fails on main. This fixes wpcomsh's AuthorSlugRedirectTest "paged" case under Codebox.

AI disclosure: Claude Opus (Pi, via Roadie) reviewed this PR. The implementation is Claude Opus 5.5 (Homeboy Cook, cook-heavy fallback route).

@chubes4
chubes4 merged commit b7b734d into main Dec 5, 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