Conversation
Replaces the Docker/wp-env-based PHPUnit job with a lightweight setup that installs WordPress, WooCommerce, and the WP PHPUnit test suite directly on the runner — no Node.js or container startup required. Changes: - bin/install-wp-tests.sh: new script that downloads WP core and the WP PHPUnit suite via SVN, generates wp-tests-config.php, creates the test DB, downloads WooCommerce latest-stable, and symlinks the plugin - .github/workflows/ci.yml: phpunit job now spins up a MySQL 8 service and runs install-wp-tests.sh + composer run test-unit instead of wp-env start + wp-env run tests-cli - composer.json: add test-unit script alias (mirrors WCA convention) - tests/integration/bootstrap.php: update docblock to document both the wp-env (local) and bare-PHP (CI) execution paths Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n tests The WP test harness only loads the front-end; wp-admin/includes/plugin.php (which defines activate_plugin()) is never required. This caused the bootstrap to return early before calling WC_Install::install(), so create_roles() never ran and manage_woocommerce was never added to the administrator role on a fresh database. The wp-env environment masked the bug because WooCommerce was pre-installed via the afterStart lifecycle script, so roles were already in the DB. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two related issues prevented manage_woocommerce from being visible to current_user_can() on a clean database: 1. WP_Roles singleton is stale after create_roles() runs. WP_Roles is initialized lazily; when WC_Install::create_roles() adds capabilities the in-memory singleton does not reflect the changes for any code path that already held a reference. Resetting $GLOBALS['wp_roles'] = null and calling wp_roles() forces a fresh read from the database. (Same pattern WCA uses; see WP trac #28374.) 2. WC's own check_version() hook (plugins_loaded) ran WC_Install::install() before our HPOS options were set, then our install call was skipped because the db_version already matched. Setting woocommerce_db_version in muplugins_loaded after loading WC prevents the premature auto-install; we delete the option again in init (priority 0) so our controlled call to WC_Install::install() -- with HPOS enabled -- actually runs. Also fixes bin/install-wp-tests.sh to split host:port when calling mysqladmin, which requires separate --host and --port flags. Verified: 256/256 tests pass on a fresh MySQL 8 database (CI path) and via wp-env (local path). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
93fd374 to
63f8247
Compare
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
bin/install-wp-tests.shwhich downloads WP core, checks out the WP PHPUnit suite via SVN, generateswp-tests-config.php, creates the test DB, downloads WooCommerce latest-stable, and symlinks the repo into the plugins directoryphpunitCI job's Node.js + wp-env setup with a MySQL service container + the install script +composer run test-unit— no Docker-in-Docker requiredtest-unitcomposer script alias (mirrors the WCA convention)bin/checkand the local wp-env workflow are unchanged.Test plan
bin/checkstill works locally🤖 Generated with Claude Code