The following solution is based on the work of my coworker Marcel Frank. The PHP library Mockery allows to use a simulated version of certain objects within unit tests, where objects are passed into methods as dependencies. This form of simulation is called mocking. Instead of trying to explain why simulating these objects in the tests makes sense, I will try to illustrate the need for it with an example.