To avoid calling the close method in each test class, you can simply add TestListener to your phpunit configuration as follows:
<listeners> <listener class="\Mockery\Adapter\Phpunit\TestListener"></listener> </listeners>
This approach is explained in docs .
There is one thing in related documents:
Make sure that the Composers or Mockerys autoloader is present in the bootstrap file, or you will also need to define the βfileβ attribute that points to the file of the above TestListener class.
source share