You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(phpunit): reset project-mode database to core's test-install state - #2634
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.
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'.
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.
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In
bootstrap-mode=project, PHPUnit reused the site Playground installed. That site has pretty permalinks, while core'stests/phpunit/includes/install.phpleaves plain ones, so plugin suites built different URLs under Codebox than in core-based CI. Project mode now runs wp-phpunit's owninstall.phpin a separate Playground request before the PHPUnit request. This stands in for the shell call core's bootstrap makes and Playground cannot. Suites start withpermalink_structure === ''and flushed rewrite rules.What changed
wordpress.phpunitruns wp-phpunit'sincludes/install.phpagainstwptests_tables in a separate request, then boots the project bootstrap withWP_TESTS_SKIP_INSTALL=1against those tables. This reuses the separate-request install that managed multisite already used, now single-site aware (phpunitTestInstallCode, formerlyphpunitMultisitePreinstallCode).permalink_structureas''(what core's multisite branch does; its single-site branch deletes the option) and flushes the rewrite rules, soget_option( 'permalink_structure' ) === ''before the first test.includes/install.php, the install step is skipped and project mode falls back to the existing Playgroundwp_site as before.tests/playground-phpunit-project-install-state.integration.test.ts(PHPUnit 9.6 + wp-phpunit, project mode, corebootstrap.php): on main,permalink_structurecaptured 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 emptyrewrite_rules,get_pagenum_link(2)yields?paged=2, and the test passes.Verification
All gates passed on
14c6805c639d. Basemain: gated on2e5a985e9d1d, target now2e5a985e9d1d, 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.Cook run
agent-task-d7dfcff3-0317-4bfb-b636-140a75236787agent-task-d7dfcff3-0317-4bfb-b636-140a75236787-attempt-1-a4584f0b0bdbac93b560d1d14d586f5575be2a704da471430bdbac93b560d1d14d586f5575be2a704da47143Delivery
Evidence
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