Skip to content

Add wp-env as the default local test environment - #48

Merged
remyperona merged 1 commit into
developfrom
add-wp-env-testing
Aug 14, 2026
Merged

Add wp-env as the default local test environment#48
remyperona merged 1 commit into
developfrom
add-wp-env-testing

Conversation

@remyperona

Copy link
Copy Markdown
Contributor

What

Introduces @wordpress/env as 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's get_path_to_wp_test_dir(). No production code changes were needed.

Changes

  • .wp-env.json (new) — latest WordPress, PHP 8.3, repo mounted via mappings into wp-content/plugins/wpmedia-phpunit. It's a library (no plugin header), so it is not listed under plugins to 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/env devDependency plus env:* and test: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 — ignore node_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.yml still runs the PHP 8.0–8.5 matrix and tests_legacy.yml runs PHP 7.4 / WP 5.9 via the wp-media/workflows/setup-wp-tests action (wp-env can't cover that full matrix in one config). Both wp-env and CI invoke the same composer scripts.

Verification

Ran end to end via wp-env on PHP 8.3.33 — all green:

  • Unit: 101 tests, 303 assertions — OK
  • Integration: 29 tests, 70 assertions — OK
  • Admin integration: 3 tests, 4 assertions — OK

🤖 Generated with Claude Code

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>
@remyperona remyperona self-assigned this Aug 14, 2026
@remyperona
remyperona merged commit 88846c6 into develop Aug 14, 2026
9 checks passed
@remyperona
remyperona deleted the add-wp-env-testing branch August 14, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant