Mar 19, 2016
0
Level 1
How to avoid database access performed by type-hinted models in controllers while testing?
I have a PostController which contains the following method:
public function show(Post $post) { /* Stuff */ }
While testing my controllers, is it possible to avoid the database query performed by the Post class?
I tried mocking my Post model at no avail. The approach suggested by Jeffrey here didn't work either: https://gist.github.com/JeffreyWay/4968363
This is not a blocker as I can either use an in-memory SQLite database or, as a last resort, even remove the type-hinted model.
How do you guys workaround this issue?
Please or to participate in this conversation.