I often run into situations when acceptance testing Laravel applications where a useful error message gets suppressed before reaching PHPUnit, making it difficult to track down what’s going wrong.
In this quick screencast, I go over an example of how the problem has bitten me, and a neat solution that makes use of PHP 7’s newly added anonymous classes.
You can check out the snippet from the screencast as well as an alternative solution for PHP 5 in this gist.
Trying to wrap your head around testing? Test-Driven Laravel is a course I recently launched that teaches you how to TDD an app from start to finish. Learn more about it here.