diff --git a/CHANGELOG.md b/CHANGELOG.md index 65d048a4c..cb770f64e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ * Fix Mockery not setting properties on overloaded instance mocks * BC BREAK - Fix Mockery not trying default expectations if there is any concrete expectation * BC BREAK - Mockery's PHPUnit integration will mark a test as risky if it - thinks one it's exceptions has been swallowed. Use `$e->dismiss()` to dismiss. + thinks one it's exceptions has been swallowed in PHPUnit > 5.7.6. Use `$e->dismiss()` to dismiss. ## 0.9.4 (XXXX-XX-XX) diff --git a/library/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegration.php b/library/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegration.php index 2abd1e89c..57b733c59 100644 --- a/library/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegration.php +++ b/library/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegration.php @@ -54,6 +54,10 @@ protected function addMockeryExpectationsToAssertionCount() protected function checkMockeryExceptions() { + if (!method_exists($this, "markAsRisky")) { + return; + } + foreach (Mockery::getContainer()->mockery_thrownExceptions() as $e) { if (!$e->dismissed()) { $this->markAsRisky('Mockery found an exception that appears to have been swallowed: '.$e->getMessage()); diff --git a/tests/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegrationTest.php b/tests/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegrationTest.php index 2df0e7262..7db722c72 100644 --- a/tests/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegrationTest.php +++ b/tests/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegrationTest.php @@ -13,12 +13,17 @@ class BaseClassStub function finish() { $this->checkMockeryExceptions(); - } + } + + function markAsRisky() {} }; class MockeryPHPUnitIntegrationTest extends MockeryTestCase { - /** @test */ + /** + * @test + * @requires PHPUnit 5.7.6 + */ public function it_marks_a_passing_test_as_risky_if_we_threw_exceptions() { $mock = mock(); @@ -34,7 +39,10 @@ public function it_marks_a_passing_test_as_risky_if_we_threw_exceptions() $test->shouldHaveReceived()->markAsRisky(m::type("string")); } - /** @test */ + /** + * @test + * @requires PHPUnit 5.7.6 + */ public function the_user_can_manually_dismiss_an_exception_to_avoid_the_risky_test() { $mock = mock();