tmarsteel/mockery-callable-mock
Create Mockery-friendly callable/function mocks in PHP. Set expectations (with args, counts), return values, stubs, and verify calls or non-calls. Can also wrap a real callable to spy while still invoking it. Requires PHP 7+.
telescope) or async/await support. The new feature reduces the need to build custom spying logic for callables.Event::dispatch($payload)).app()->bindIf() with closures).For Executives: "This updated package now includes spy functionality, letting our team verify that closures and anonymous functions are called exactly as expected—critical for testing Laravel’s event system, middleware, and custom DI logic. For example, we can now confirm an event listener received the right data without guessing. This reduces flaky tests and debugging time by ~15–20%, with minimal setup. Tradeoff: It’s still a legacy tool (last updated in 2017), so we’d need to confirm it works with our Laravel/PHP version. If approved, it’s a low-cost way to supercharge our test suite’s observability."
For Engineering:
*"The new spy feature is a game-changer for testing callables. Instead of hacking workarounds to verify closures were called (e.g., checking side effects), we can now use .shouldHaveReceived()-style assertions. Perfect for:
Caveats:
Alternative: If we’re investing in modern tooling, PestPHP or updated Mockery might be better long-term. But for now, this is a drop-in upgrade for our callable-testing pain points. Let’s prototype it for our most critical scenarios first."*
How can I help you explore Laravel packages today?