From cf3fcd5fed3f5a1e305ab1d2f015c078ee0db40b Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Thu, 3 Apr 2025 12:24:42 -0400 Subject: [PATCH] PHPLIB-1659: Fix dropping collections after successful tests (#1653) cb33c1c92b5d5cead5f18996db5825cc6064e81f introduced onNotSuccessfulTest(), but that is the inverse logic. The internal TestCase::status() method seems to be the only replacement for TestCase::hasFailed(), which was removed in PHPUnit 10. --- tests/FunctionalTestCase.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/FunctionalTestCase.php b/tests/FunctionalTestCase.php index 483823faa..dc0a9d0ae 100644 --- a/tests/FunctionalTestCase.php +++ b/tests/FunctionalTestCase.php @@ -17,7 +17,6 @@ use MongoDB\Operation\DatabaseCommand; use MongoDB\Operation\ListCollections; use stdClass; -use Throwable; use UnexpectedValueException; use function array_intersect_key; @@ -70,15 +69,12 @@ public function setUp(): void $this->configuredFailPoints = []; } - protected function onNotSuccessfulTest(Throwable $t): never - { - $this->cleanupCollections(); - - throw $t; - } - public function tearDown(): void { + if ($this->status()->isSuccess()) { + $this->cleanupCollections(); + } + $this->disableFailPoints(); parent::tearDown();