Split wp-env into dedicated QA and PHPUnit instances - #395
Merged
Conversation
wp-env 11 deprecates starting the dev and tests environments from one config and warns on every start. Set testsEnvironment: false in .wp-env.json (QA, port 8890) and move PHPUnit to a dedicated instance defined by .wp-env.tests.json (port 8891), targeted by the test:php* scripts via --config. The tests config mirrors the old tests environment's WP_DEBUG/SCRIPT_DEBUG=false defaults so wp_trigger_error() notices don't fail the strict PHPUnit suite.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What it does
Silences wp-env 11's deprecation warning on every
wp-env startby migrating off the deprecated dual-environment mode.npm run env:startnow brings up only the manual-QA instance (port8890, 3 containers instead of 6), and PHPUnit runs in a dedicated instance defined by the new.wp-env.tests.json(port8891), started withnpm run env:start:tests.Rationale
wp-env 11 deprecated starting the dev and tests environments from one config:
The suggested
"testsEnvironment": falsealone would have brokennpm run test:php, which ran inside thetests-clicontainer that flag removes. The upstream-recommended replacement is a separate config file per environment via the--configflag, which is what this PR does. As a bonus, QA state and test runs no longer share anything, and each stack is half the containers.Implementation
.wp-env.jsonsets"testsEnvironment": falseand dropstestsPort; it is now purely the QA instance..wp-env.tests.jsondefines the PHPUnit instance. It mirrors the old tests environment'sWP_DEBUG/SCRIPT_DEBUGfalsedefaults; without that, WordPress 7.0'swp_trigger_error()inwp_update_plugins()fires a notice under the dev-instance default ofWP_DEBUG: truethat the strict PHPUnit config turns into a test error (caught inpluginsWindowRegistration.phpwhile verifying this migration).test:php/test:php:installtarget the tests instance viawp-env run --config=.wp-env.tests.json cli; itsclicontainer hasWP_TESTS_DIRand a generatedwp-tests-config.phpjust liketests-clidid. Newenv:start:tests/env:stop:tests/env:destroy:testsscripts manage it.bin/setup-wp-env.shdrops thetests-cliGutenberg setup. PHPUnit never needed it (the guidelines test registers its own stub surface), so the tests instance starts with noafterStartat all..wp-env.plugin-check.jsonalso gets"testsEnvironment": false.AGENTS.md,docs/DEVELOPMENT.md,tests/phpunit/bootstrap.phpheader) updated to the new flow.WP_ENV_TESTS_PORTis obsolete; worktrees now override each instance's port withWP_ENV_PORTper command, or via git-ignored.wp-env.override.json/.wp-env.tests.override.json.Testing instructions
Note: instances created by the old config keep their now-orphaned
tests-*containers until youwp-env destroythem once.