Black Friday: the Laravel testing course is $149 instead of $249, through Dec 7. See the course →
logo

Better mock assertions with Eloquent models

Nice and clean, the Laravel way

Joel Clermont
Joel Clermont
2025-04-25

From our daily Laravel tips email. Get the next one in your inbox.

I never really liked how verbose it was to assert that a mock was called with an Eloquent model. It always seemed like it should be easier.

In today's video, I will show the default way, which doesn't work, the verbose solution, and then the nice, clean solution, which is what I wanted from the beginning.

Watch Now (6 min)

And after watching, don't forget to subscribe to our YouTube channel, so you don't miss future videos.

Here to help,

Joel

P.S. This video went a bit deep into how Mockery matches arguments. If you want a really deep dive on Laravel's validation rules, check out our book.

Want a tip like this in your inbox every weekday?

Each one takes less than 2 minutes to read. Join 4,000+ Laravel developers who already get them.

email
No spam. Only real-world advice.
Toss a coin in the jar if you found this helpful.