10up/wp_mock
wp_mock is a Mockery-powered library for unit testing WordPress plugins and themes. It lets you mock core functions, hooks, and globals so tests run fast and isolated, without a WordPress install.
require-dev) dependency that lets us unit-test WordPress-facing PHP without booting WordPress, a database, or wp-env. The decision it unlocks: invest in a fast unit suite instead of bespoke harness code or slower container-based CI. Because it never ships to production, adoption is reversible — this is a low-risk pilot, not an architecture commitment.apply_filters, get_option, transients, WP_Error, and wp_remote_* surfaces exactly which WordPress APIs a feature depends on. That's the input for scoping WP core upgrade work, deprecation timing, and go/no-go on legacy plugin refactors — with coverage as the gate.Http::fake/Mockery already cover the ground.Adopt when:
NOASSERTION; the project is widely understood to be MIT, but this must be resolved in writing before commercial adoption — it's a one-line blocker, not a design question.Look elsewhere when:
wp-env, the WordPress core test suite (WP_UnitTestCase), or Playwright. A mock will happily confirm behavior real WordPress would never exhibit.@wordpress/scripts and Jest.Adoption conditions: pilot on one plugin or module, measure CI duration and defect escape rate before and after, and keep a thin integration suite so mocks never become the only source of truth.
To executives: This is a free, development-only dependency that makes our WordPress code testable in CI without spinning up WordPress instances. Expected returns are faster PR feedback, fewer regressions when WordPress ships updates, and lower CI infrastructure spend. Risk is contained: it is not shipped to production and can be removed in a day. Two things to clear — a license confirmation (metadata is ambiguous) and a small, ongoing engineering cost to keep it aligned with PHPUnit releases. Recommend a time-boxed pilot on one product with a measured before/after on CI time and escaped defects.
To engineering: WP_Mock is a Mockery-based framework that stubs WordPress's procedural API — add_action, apply_filters, get_option, transients, WP_Error, wp_remote_* — so hook callbacks, shortcodes, and extracted business logic can be tested without a full WP bootstrap. It complements rather than replaces wp-env/WP_UnitTestCase: unit tests for logic we own, integration tests for wiring WordPress owns. Three asks: pin the version, assign an owner for the PHPUnit/Mockery upgrade path, and keep at least one real-WordPress smoke suite so mocked assumptions get checked against reality.
Framing note: despite the "Laravel/PHP" label, this is a PHP Composer package specific to WordPress. It belongs in the WordPress product line's toolchain, not in Laravel service repos — worth stating explicitly so it isn't mis-scoped into the wrong backlog.
How can I help you explore Laravel packages today?