Repository navigation
Conversation
wp-env has deprecated its built-in tests containers and warns on every start. Turn them off and run the integration suite in a second environment from .wp-env.tests.json on port 8889, as wp-env recommends. It keeps the dev site's mappings and config. Drop WP_PHPUNIT__TESTS_CONFIG from make test-integration: wp-env sets WP_TESTS_DIR to its own test library and config, which the bootstrap uses first, so tests/php/wp-tests-config.php only applies outside wp-env.
"plugins": [ "." ] mounts and activates the plugin under the checkout's directory name, so in a worktree the active copy was named after the worktree, and the copy the mapping put at wp-content/plugins/wp-super-cache, which WPCACHEHOME points at, was inactive. Mount the plugin only through the mapping and activate it after wp-env starts.
wp-env names each checkout's containers after its directory plus a hash. make status shows both sites' state, URL and install path, whose name is the compose project the containers belong to.
make down failed with Error 1 when the test site had never been started, because wp-env exits 1 when asked to stop an uninitialised site. Ignore that failure on the test-site stop. The PORT and TEST_PORT make variables overrode any WP_ENV_PORT set in the shell and picked up unrelated PORT exports. Use WP_ENV_PORT and WP_ENV_TESTS_PORT instead, defaulting to 8888 and 8889.
donnchawp
force-pushed
the
fix/wp-env-separate-tests-config
branch
from
December 1, 2026 17:05
01655ee to
74b946e
Compare
WP_ENV_PORT=8890 make up only lasted one command: the next plain make up or make test-integration went back to 8888/8889 and clashed with the main checkout. A second checkout now puts its ports in .wp-env.override.json and .wp-env.tests.override.json, which wp-env reads itself. The Makefile only passes WP_ENV_PORT when a port is given, so the files decide otherwise, and drops an exported WP_ENV_PORT for the test site so it doesn't take the development site's port.
The wpsc-loopback-fix mu-plugin only rewrote requests to http://localhost:8888. The test site runs on 8889, and a second checkout now uses other ports from .wp-env.override.json, so their preloader, WP-Cron and REST loopbacks went to a port nothing listens on inside the container. Take the port from the site's home URL instead.
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.
wp-env has deprecated its built-in tests containers (
tests-cli,tests-wordpress,tests-mysql) and warns about them on everywp-env start. Its README recommends a second config file used with--configinstead, so that's what this does..wp-env.jsonsets"testsEnvironment": false, somake upstarts only the development site on 8888..wp-env.tests.jsonis the test site on 8889, the port the old tests containers used. It has the same plugin mappings, mu-plugins andWPCACHEHOMEas the development site, so the integration tests run in the same setup as before.make test-integrationstarts the test site and runs PHPUnit in itsclicontainer.make downandmake destroyhandle both sites..wp-env.override.jsonand.wp-env.tests.override.json(gitignored, e.g.{ "port": 8890 }), which wp-env reads itself, so every make target uses them. For a one-off,WP_ENV_PORTandWP_ENV_TESTS_PORToverride the files, from the environment or as make arguments. The Makefile only passesWP_ENV_PORTwhen a port is given, and drops an exported one for the test site so it doesn't take the development site's port.make statusshows whether each site is running, its URL, and its install path. wp-env names each checkout's containers after its directory plus a hash, likewp-env-wp-super-cache-1a2b3c4d, and the install path has the same name, so it tells you which containers belong to this checkout.I also dropped
WP_PHPUNIT__TESTS_CONFIGfrommake test-integration, because it was never used there. wp-env setsWP_TESTS_DIRto its own test library in the cli container, andtests/php/bootstrap-integration.phpuses that before wp-phpunit. That library has its own config, which reads theWORDPRESS_DB_*variables wp-env sets.tests/php/wp-tests-config.phpis still there for running the suite outside wp-env, and I've updated its comment andtests/php/README.mdto say so.Before you pull this
The old tests containers stay around until you remove them. If you followed the note in #1131 and stopped the old
wp-super-cacheproject, there's nothing else to do. Otherwisemake test-integrationwill fail on port 8889 until you stop it.Testing
In a fresh worktree on spare ports, at 74b946e:
WP_ENV_TESTS_PORT=8895 make test-integrationpasses all 53 integration tests with no deprecation warning. The test site runs WordPress 7.1.5, haswpsc-loopback-fix.phpin mu-plugins, and hasWPCACHEHOMEset.WP_ENV_PORT=8894 make upstarts only the three development containers, withwp-super-cacheactive.make status WP_ENV_PORT=8894 WP_ENV_TESTS_PORT=8895shows both sites running at their URLs.WP_ENV_PORT=8894 WP_ENV_TESTS_PORT=8895 make downstops both sites, and exits 0 when the test site, or neither site, was ever started.make test(the smoke suite) still passes all 160 tests.make upandmake test-integrationstay on those ports. An exportedWP_ENV_PORT=8896moves only the development site, andmake test-integration WP_ENV_TESTS_PORT=8897moves only the test site. Without override files the sites use 8888 and 8889. The integration suite passed all 53 tests in each case (e518a9d).74b946e renamed the port variables from
PORTandTEST_PORTtoWP_ENV_PORTandWP_ENV_TESTS_PORT, so aWP_ENV_PORTset in the shell is no longer overridden and an unrelatedPORTexport is ignored. Dry runs (make -n) showWP_ENV_PORT=8890,PORT=3000andWP_ENV_TESTS_PORT=8891give ports 8890, 8888 and 8891. The same commit letsmake downsucceed when the test site was never started; before, wp-env's "not initialized" exit failed the target. 56ce456 does the same for the development site, somake downalso succeeds in a checkout where neither site has ever started.Loopback requests on other ports
tests/dev/mu-plugins/wpsc-loopback-fix.phpsends the site's requests to itself (preloader, WP-Cron, REST) to thewordpresscontainer, but it only handledhttp://localhost:8888. On the test site (8889), or a checkout on other ports, those requests went to a port nothing listens on inside the container. 2357519 takes the port from the site's home URL instead.DevLoopbackFixTest(2 new integration tests) checks that a request to the site's own port is sent tohttp://wordpresswith the originalHost, and that requests to other origins are left alone. The first fails on the old code, and the second fails if the fix rewrites everyhttp://localhostURL. With it, the integration suite passes all 55 tests on a test site at 8895.Plugin activation in worktrees
The second commit fixes a problem with worktrees.
"plugins": [ "." ]mounts and activates the plugin under the checkout's folder name, so in a worktree the active plugin was named after the worktree. The copy the mapping puts atwp-content/plugins/wp-super-cache, whichWPCACHEHOMEpoints at, was inactive. In the main checkout both are the same folder, so you never saw it there.The plugin is now mounted only through the mapping, and an
afterStartlifecycle script runswp plugin activate wp-super-cache, so plainwp-env startactivates it too. The test site doesn't need it: the integration suite reinstalls WordPress and loads the plugin files itself.In a fresh worktree,
wp plugin listnow showswp-super-cacheactive and nothing named after the worktree. A secondmake upstill succeeds, and the 53 integration tests still pass.