In a test, you have to ensure that your code is doing what you want. Of course you're not going to tests methods like "save" (there are already tests for that).
You use Mocks.
Greetings.
Thanks for reply!
Thanks,
Marcel
Ok, so for example, let's say that you have a method in a model that does the following:
So what you test is:
Now, a query is involved here (set password = 'asd'), we could use real db, but when tests grouw up, it will take too much time.
What we do instead, we use mocks. With mocks, you ensure that a method is being called but the actions are not performed.
This is a very nice tutorial about testing in laravel: http://code.tutsplus.com/tutorials/testing-like-a-boss-in-laravel-models--net-30087
Hope it helps.
Greetings.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community