Add wp-env as the default local test environment - #48
Merged
Conversation
Introduce @wordpress/env as the supported way to run this package's unit and WordPress integration tests locally. wp-env provides a Dockerized WordPress + MySQL with Composer/PHPUnit/WP-CLI preinstalled and exposes WP_TESTS_DIR, which the existing integration bootstrap already consumes via Yoast's get_path_to_wp_test_dir() — no production code changes needed. - .wp-env.json: latest WP, PHP 8.3, repo mounted via mappings (library, not activated as a plugin). Ports 8890/8891 to avoid the Local by Flywheel conflict on 8888/8889. - package.json: @wordpress/env devDependency plus env:* and test:php* wrapper scripts. - README: "Running This Package's Tests" section documenting wp-env as the default path. - CLAUDE.md: agent guidance covering the wp-env workflow, ports, and the CI-vs-local split. - .gitignore: ignore node_modules/ and .wp-env.override.json. CI is unchanged and continues to run the PHP matrix via setup-wp-tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Introduces
@wordpress/envas the default, supported way to run this package's unit and WordPress integration tests locally.wp-env provides a Dockerized WordPress + MySQL with Composer, PHPUnit, and WP-CLI preinstalled, and exposes the WordPress test suite via
WP_TESTS_DIR— which the existing integration bootstrap (src/Integration/bootstrap.php) already consumes through Yoast'sget_path_to_wp_test_dir(). No production code changes were needed.Changes
.wp-env.json(new) — latest WordPress, PHP 8.3, repo mounted viamappingsintowp-content/plugins/wpmedia-phpunit. It's a library (no plugin header), so it is not listed underpluginsto avoid an activation failure. Ports set to 8890/8891 because wp-env's defaults 8888/8889 collide with Local by Flywheel.package.json/package-lock.json(new) —@wordpress/envdevDependency plusenv:*andtest:php*wrapper scripts.README.md— new "Running This Package's Tests" section documenting wp-env as the default path.CLAUDE.md(new) — agent guidance covering the wp-env workflow, ports, library-not-plugin mounting, and the CI-vs-local split..gitignore— ignorenode_modules/and.wp-env.override.json.Developer flow
```bash
npm install && npm run env:start && npm run env:install
npm run test:php
```
Scope / CI
This is the local default only. CI is unchanged:
tests.ymlstill runs the PHP 8.0–8.5 matrix andtests_legacy.ymlruns PHP 7.4 / WP 5.9 via thewp-media/workflows/setup-wp-testsaction (wp-env can't cover that full matrix in one config). Both wp-env and CI invoke the samecomposerscripts.Verification
Ran end to end via wp-env on PHP 8.3.33 — all green:
🤖 Generated with Claude Code