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.
Architecture fit — low for a Laravel codebase. 10up/wp_mock is a PHPUnit-oriented mocking framework for WordPress's procedural surface: global functions (add_action, apply_filters, get_option, wp_remote_get) and the hook system. Laravel applications do not have that surface; they have a container, facades, and first-party test doubles (Http::fake, Event::fake, Mockery integration). Adopting wp_mock in a Laravel repo inverts the testing model — it exists to simulate a global-function runtime that Laravel deliberately avoids. The only legitimate fit is a hybrid estate: a Laravel application that also ships or consumes a WordPress plugin/theme, or a monorepo where a legacy WP plugin is being progressively extracted.
Integration feasibility — feasible but narrow. Technically it installs via Composer as a dev dependency, requires a PHPUnit bootstrap that loads WP stubs before the test suite, and depends on Mockery plus a runtime function-redefinition mechanism. That mechanism is the friction point: it must patch global functions before they are bound, which constrains bootstrap ordering, interacts poorly with opcache/preloading, and can conflict with Laravel's own tests/bootstrap.php and CreatesApplication flow. It is achievable in a single test suite; keeping two bootstraps (Laravel + WP) in one process is where teams burn time.
Technical risk — elevated and concentrated in four areas.
NOASSERTION. Even if the underlying license is permissive, an unattributed license is a legal-review gate before it enters a commercial build. Budget for counsel time.Key questions for the maintainers / sponsors.
NOASSERTION license resolvable via a specific SPDX identifier and an OSI-approved text in the repo?Verdict. Composite score of ~22.7 with a 7.2 opportunity signal reads correctly: real value inside the WordPress niche, poor fit for a Laravel-primary stack. Recommend conditional rejection — approve only if a named WordPress component exists in scope; otherwise standardize on Laravel-native doubles.
Stack fit. Treat wp_mock as a boundary tool, not a framework tool. It belongs in the test suite of a WordPress plugin/theme package, or in a legacy-migration package inside the monorepo — never in tests/ of the Laravel application itself. Keep it isolated to a Composer path/workspace package so its bootstrap and Mockery constraints cannot leak into the app's test configuration.
Migration path. The defensible use case is characterization before extraction:
OptionsRepository, HookDispatcher, HttpClient) in the legacy code.wp_mock to pin current WP behavior and lock in regression tests around those adapters.Config, Event::dispatch, Http).wp_mock dependency; the characterization tests survive as contract tests.This converts a testing dependency into a bounded, time-boxed migration instrument with a defined exit date — the key TPM control.
Compatibility. Pin an exact version in composer.json (no caret range) and record the resolved PHPUnit/Mockery/PHP matrix in the repo. Verify the pinned release against our CI PHP version before any broader rollout; the release date metadata being ahead of the current date is itself a signal to verify artifacts manually rather than trust the index.
Sequencing.
Maintenance. The ongoing cost is not the dependency — it is mock fidelity. Someone must own the mapping between WordPress core behavior and our stubs, and refresh it on WP major releases. That is a recurring, low-glamour workload with no upstream guarantee. Plan for an internal fork with a designated maintainer, or accept that the suite's trustworthiness decays between WP releases.
Support. Community-supported, single-vendor origin (10up) with a credible reputation but no SLA. Escalation path is "open an issue." For a tool that gates our test signal, that is a real support gap; the mitigation is fork-and-patch authority, not vendor commitment.
Scaling. Test suites grow, and this tool's design is hostile to scale: global function redefinition plus shared hook state makes parallel execution (Paratest) and test isolation fragile, and forces deterministic ordering or process isolation. Expect suite runtime to grow superlinearly and expect intermittent cross-test contamination that is expensive to diagnose. Keep the wp_mock suite in its own CI job so it cannot slow or destabilize the main Laravel pipeline.
Failure modes to monitor.
wp_mock initialization colliding with Laravel's test bootstrap, manifesting as intermittent class-not-found or "function already defined" errors after unrelated dependency updates.Ramp-up. A mid-level PHP developer fluent in PHPUnit and Mockery needs roughly one to two days to be productive; the real learning curve is WordPress internals — hook priority semantics, filter return contracts, and the order in which core loads — which is a week-plus for someone without WP background. Do not assume Laravel testing experience transfers; the mental model is different and the failure modes are silent. Budget a short internal write-up on "when a passing test here means nothing" as part of onboarding.
Bottom line for planning. Cost is low in license terms and moderate in engineering; the dominant risk is signal quality — a test suite that is green for the wrong reasons. Approve only with (a) a named WordPress component in scope, (b) license clarification, (c) a paired real-WordPress integration job, and (d) an exit criterion tied to the extraction roadmap.
How can I help you explore Laravel packages today?