Add wp-env support for running PHPUnit tests#7894
Merged
Conversation
Add a test-php:wp-env npm script that runs PHPUnit inside the wp-env Docker container, matching the pattern used by WooCommerce. Update the tests README to recommend wp-env as the primary setup method and replace the outdated VVV instructions. Use sys_get_temp_dir() in the test bootstrap for better cross-platform compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a wp-env-based workflow for running the plugin’s PHPUnit suite inside the WordPress Docker environment, and updates test setup documentation accordingly while adjusting the test bootstrap’s default WP test library path.
Changes:
- Add an npm script (
test-php:wp-env) to run PHPUnit inside the wp-envtests-clicontainer. - Update
tests/README.mdto recommend wp-env and refresh local-MySQL setup instructions. - Change the PHPUnit bootstrap’s default
WP_TESTS_DIRfallback to usesys_get_temp_dir().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/bootstrap.php |
Updates default WP test suite path fallback used by PHPUnit bootstrap. |
tests/README.md |
Rewrites setup/run instructions to prioritize wp-env and modernize local DB guidance. |
package.json |
Adds test-php:wp-env script to run PHPUnit within wp-env’s container. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The wp-env test script runs vendor/bin/phpunit from the mounted local directory, so Composer dependencies must be installed locally. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
test-php:wp-envnpm script that runs PHPUnit inside the wp-env Docker container, matching the pattern used by WooCommerce.sys_get_temp_dir()in the test bootstrap for better cross-platform compatibility.&vs&) and quotes (“vs UTF-8 curly quotes) differently across versions, which caused assertion failures on WP nightly. The tests now normalize these equivalent representations before comparing.Test plan
npm run wp-env startto start the environmentnpm run test-php:wp-envto verify all tests executenpm run test-php:wp-env -- --filter Sensei_Class_Admin_Testto verify argument passing worksnpm run test-phpstill works for local MySQL setups