Testing – WP Webhook Framework
Use the bundled wp-env application test setup to validate how the framework behaves inside WordPress.
The suite runs against the development site mounted by .wp-env.json, while PHPUnit uses the WordPress core test bootstrap inside that container.
What the suite covers
Section titled “What the suite covers”wp-envmounts the primary and secondary fixture plugins plus a receiver MU plugin used to capture real HTTP webhook deliveries.- Each fixture plugin loads the shared library from the repository checkout and calls
Service_Provider::register()on its own, which also loads the bundled Action Scheduler. tests/phpunit/bootstrap.phploads the same fixture plugin entrypoints for the WordPress core test bootstrap, because that bootstrap uses its own isolated install state.- The primary fixture consumer registers built-in post, term, user, and custom webhooks.
- The secondary fixture consumer registers its own post webhook to validate multi-plugin usage.
- PHPUnit tests execute scheduled Action Scheduler jobs, call real HTTP receiver endpoints, and assert persisted delivery logs.
- The GitHub Actions workflow runs the same suite on every push and pull request.
Action Scheduler resolution
Section titled “Action Scheduler resolution”Service_Provider::bootstrap_action_scheduler() checks two paths. The first is the production layout, where the framework sits in a consumer’s vendor tree and Action Scheduler resolves at ../../../woocommerce/action-scheduler. The second covers this repository checked out on its own, where vendor/ lives inside the checkout — which is how the suite runs it, so the suite exercises the second path.
Commands
Section titled “Commands”npm installnpm run wp-env:startnpm run composer:installnpm run test:phpunitnpm run wp-env:stopKey files
Section titled “Key files”.wp-env.jsonmounts the repository checkout and maps the receiver MU plugin.tests/phpunit/bootstrap.phploads fixture plugin entrypoints into the WordPress core PHPUnit bootstrap.tests/wp-env/mu-plugins/wpwf-test-receiver.phphandles incoming webhook HTTP requests and exposes log/reset endpoints for assertions.tests/wp-env/plugins/wpwf-test-app/wpwf-test-app.phpboots the shared framework from the primary plugin and defines its fixture hooks.tests/wp-env/plugins/wpwf-test-secondary/wpwf-test-secondary.phpboots the shared framework from the secondary plugin and defines its fixture hooks.tests/phpunit/includes/class-wpwf-webhook-test-case.phpprovides helpers for receiver log management and queued action execution.tests/phpunit/PostWebhookCrudTest.php,tests/phpunit/TermWebhookCrudTest.php, andtests/phpunit/UserWebhookCrudTest.phpprovide separate CRUD examples per entity.tests/phpunit/MetaWebhookTest.phpcovers meta emission modes, parent entity updates, and delivery payload enrichment.tests/phpunit/DeliveryModeTest.phpcovers scheduled vs immediate dispatch behavior.tests/phpunit/WebhookFilterTest.phpcovers runtime filters for delivery mode, URL routing, payload suppression, headers, and request body changes.tests/phpunit/WebhookFailureHandlingTest.phpcovers retries, backoff scheduling metadata, and URL blocking behavior.tests/phpunit/NotificationAndFailureStateTest.phpcovers blocked email notifications and expired-block recovery..github/workflows/integration-tests.ymlruns the suite in CI.
Extending the suite
Section titled “Extending the suite”Add new application tests under tests/phpunit. Reuse WPWF_Webhook_Test_Case when you need to:
- inspect pending
wpwf_send_webhookactions - execute scheduled actions immediately
- assert receiver log entries (URL, headers, payload, webhook name)
This keeps future validation tests focused on webhook behaviour instead of environment setup.