I'm trying to migrate a page from an old system to a new one were we try to unit test everything.
The page contains around 40 advanced search filters to search inside our products table and its related table.
Some of them are simple field search, but others create new joins or sub queries.
I'm at a loss is how to unit test the repository, the method receives an array of user provided filters and should return the corresponding products, inside it uses Doctrine ORM and DQL to generate all the queries.
I though of the following:
So how would you go about testing this?
Unless you can guarantee the order of the code, then checking the MySQL code is as expected will take a long time to check. Instead you could:
For part 2, if you can automate this to run the checks, then even better. Checking all possible additions is going to be near impossible, as there are 1,099,511,627,775 combinations from selecting just 1 filter, right through to selecting all 40. Each of those would need to be tested for generating SQL containing what you expect, but also run correctly.
Sometimes unit testing everything is impossible. Sometimes you've got to just test "enough", however you measure that.