@Sofia, this series has a section on "doubles" https://laracasts.com/series/php-testing-jargon
Looking for some testing advice
Hello,
I'm trying to refactor a function that does a complex transformation so that can be tested without having to access the database.
The function accepts an associative array that is constructed from some form input and returns a collection of models. There are a couple of eloquent queries that fetch data required for the transformation, and this is the part that I need to factor out, but it's tangled up at the moment. The query parameters are based on input.
Ideally, we could test this transformation as a 'unit' vs. breaking it up into several calculations (before and after queries). Breaking it up would force us to create many more tests to cover all the cases.
I was also thinking about creating a repository for the queries, where it can be swapped for one that returns in-memory models when testing, but not sure how to put that together and haven't been able to find any good examples online.
Any ideas, relevant resources, or advice appreciated.
Thank you!
Please or to participate in this conversation.