Last updated: 15 November 2026. Series: Part 2 of 3. Tested on Laravel 13.40, PHP 8.3.6, Pest 4.7.8, Mockery 1.6.15. Continues the orders app from Part 1 . Update log at the end.
The order endpoint sends an email, queues an invoice job, fires an event and calls a payment API. A test should check that each of those happened without sending a real email or charging a real card. Laravel gives you fakes for most of it, and Mockery for the rest. The hard part is knowing which to use and what each one can silently miss. Every example here was run, including the ways they fail.
Fake, mock or spy?
Tool Use it when Example
Laravel fake The thing is a Laravel service with a built-in fake Mail::fake() , Queue::fake() , Event::fake() , Http::fake()
Mock (Mockery) Your own class or interface; you want to assert how it is called and control what it returns mock(PaymentGateway::class, ...)
Spy You want to assert after the fact that something was, or was not, called spy(PaymentGateway::class)
Hand-written fake The…