Repository navigation
test(php): run PHPUnit in a separate wp-env config - #34
Merged
Merged
Conversation
wp-env 11.16 deprecates the env block and the automatic tests environment. The replacement it documents is a second config file, so .wp-env.tests.json defines the test environment (port 8889, its own containers and database, the plugin plus twentytwentytwo, WP_DEBUG on), and .wp-env.json lists the plugin at the top level with testsEnvironment false. pretest:php starts the test environment and the test:php scripts run PHPUnit in its cli container. A second config, not the development environment's cli container: wp-env's wp-tests-config.php there uses the site's database and wp_ prefix, so the suite would wipe the development site's content. CI keeps working unchanged: WP_ENV_PHP_VERSION and WP_ENV_CORE apply to the test environment too. The dev-tools feature already reads a top-level plugins list; a test now covers it.
AnuragVasanwala
approved these changes
Oct 1, 2026
Merged
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.
@wordpress/env11.16 deprecates theenvblock and the automatic tests environment, and prints a warning on everywp-env start. Its documented replacement is a second config file passed with--config.Changes
.wp-env.tests.jsondefines the test environment: the plugin, thetwentytwentytwotheme, port 8889, its own containers and database, andWP_DEBUGon..wp-env.jsonlists the plugin at the top level and setstestsEnvironmenttofalse.pretest:phpstarts the test environment and installs Composer dependencies in itsclicontainer;test:php,pretest:php:coverageandtest:php:coveragerun there.WP_ENV_TESTS_PORT.pluginslist from.wp-env.json; a new test covers it (it fails if that fallback is removed)..gitignoreignores.wp-env.tests.override.json.Why not run the tests in the development environment's
clicontainer: wp-env'swp-tests-config.phpthere uses the site's database andwp_prefix, so the suite wipes the development site's content.CI needs no change:
ci-test-phprunsnpm run wp-env startand thennpm run test:php, whose pretest hook starts the test environment, andWP_ENV_PHP_VERSIONandWP_ENV_COREapply to it too.The dev-tools override still writes
env.development, which wp-env still accepts; moving it to the new shape is a separate change for both starters.Testing
npm run wp-env startandnpm run test:php: no deprecation warnings; the test environment comes up on 8889npm run test:php -- --filter UtilTeststill passes arguments throughWP_ENV_PHP_VERSION=8.3 npm run test:phpruns on PHP 8.3.35 and passesnpm run lintpasses