Skip to content

Comments

Add wp-env support for running PHPUnit tests#7894

Merged
donnapep merged 7 commits intotrunkfrom
update/unit-test-instructions
Feb 23, 2026
Merged

Add wp-env support for running PHPUnit tests#7894
donnapep merged 7 commits intotrunkfrom
update/unit-test-instructions

Conversation

@donnapep
Copy link
Contributor

@donnapep donnapep commented Feb 22, 2026

Summary

  • 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.
  • Normalize HTML entity variations in test assertions for cross-version compatibility. WordPress encodes ampersands (& 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

  • Run npm run wp-env start to start the environment
  • Run npm run test-php:wp-env to verify all tests execute
  • Run npm run test-php:wp-env -- --filter Sensei_Class_Admin_Test to verify argument passing works
  • Verify the existing npm run test-php still works for local MySQL setups

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>
Copilot AI review requested due to automatic review settings February 22, 2026 20:30
@donnapep donnapep added this to the 4.25.3 milestone Feb 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-env tests-cli container.
  • Update tests/README.md to recommend wp-env and refresh local-MySQL setup instructions.
  • Change the PHPUnit bootstrap’s default WP_TESTS_DIR fallback to use sys_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.

donnapep and others added 2 commits February 22, 2026 15:37
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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Copilot AI commented Feb 22, 2026

@donnapep I've opened a new pull request, #7895, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI commented Feb 22, 2026

@donnapep I've opened a new pull request, #7896, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI commented Feb 22, 2026

@donnapep I've opened a new pull request, #7897, to work on those changes. Once the pull request is ready, I'll request review from you.

@donnapep donnapep merged commit e4cf1b3 into trunk Feb 23, 2026
21 checks passed
@donnapep donnapep deleted the update/unit-test-instructions branch February 23, 2026 19:45
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.

2 participants