Skip to content

Commit 5862d36

Browse files
committed
Consider PHPUnit Warnings for expectError in GridFS tests
1 parent 263151a commit 5862d36

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/UnifiedSpecTests/Operation.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use MongoDB\Operation\FindOneAndReplace;
1414
use MongoDB\Operation\FindOneAndUpdate;
1515
use PHPUnit\Framework\Assert;
16-
use PHPUnit\Framework\Exception as PHPUnitException;
16+
use PHPUnit\Framework\AssertionFailedError;
1717
use stdClass;
1818
use Throwable;
1919
use Traversable;
@@ -129,11 +129,15 @@ public function assert(bool $rethrowExceptions = false)
129129
$result = $this->execute();
130130
$saveResultAsEntity = $this->saveResultAsEntity;
131131
} catch (Throwable $e) {
132-
/* TODO: Consider adding operation details (e.g. operations[] index)
132+
/* Note: we must be selective about what PHPUnit exceptions to pass
133+
* through, as PHPUnit's Warning exception must be considered for
134+
* expectError in GridFS tests (see: PHPLIB-592).
135+
*
136+
* TODO: Consider adding operation details (e.g. operations[] index)
133137
* to the exception message. Alternatively, throw a new exception
134138
* and include this as the previous, since PHPUnit will render the
135139
* chain when reporting a test failure. */
136-
if ($e instanceof PHPUnitException) {
140+
if ($e instanceof AssertionFailedError) {
137141
throw $e;
138142
}
139143

0 commit comments

Comments
 (0)