Source: medium.com

Testing with Test Doubles?
A Test Double is an object that can stand in for a real object in a test, similar to how a stunt double stands in for an actor in a movie. As I wrote in “The importance of the Tests in our Software”, there are several types of tests.

To test this service we can create a stub of the user and check if the response is what we were expecting.

This is the solution to solve the problem: And this is the mock: A fake is a simpler implementation of real objects.

We must know the scope of the code we are going to test to get the least coupled as possible.That means if we have to pick a test double, first, we must know if the test is outside of our boundaries we have to pick a fake, otherwise, we will pick the corresponding double test with the least knowledge possible: dummy, stub, spy or mock (in that order).
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners