padraic/mockery — pull request #352 by Danack (2014-06-24 13:05:35+00:00)
Title: Added fail safe

Currently Mockery doesn't 'failsafe' when a unit-test using Mockery doesn't meet expectations, and for whatever reason `Mockery::close()` isn't called. i.e. you can get false negatives where you think the unit tests have all passed, but in fact they haven't been run properly, which is just about the worst thing possible, as it could lead to you deploying none-working code.

The change above uses the `__destruct` method of ShutdownFailsafe to trigger `Mockery::close()`. Obviously it is not called in the correct place/scope and so the error message isn't attached to the correct test, but it at least makes it obvious that there has been an error through the error message shown, and more importantly makes PHPUnit return a non-zero error code, which makes any automated tools aware that the tests have failed.

i.e. it prevents false negatives, even if it doesn't do it perfectly.