Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions tests/UnifiedSpecTests/ExpectedError.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use MongoDB\Driver\Exception\ExecutionTimeoutException;
use MongoDB\Driver\Exception\RuntimeException;
use MongoDB\Driver\Exception\ServerException;
use MongoDB\Driver\Exception\WriteException;
use MongoDB\Tests\UnifiedSpecTests\Constraint\Matches;
use PHPUnit\Framework\Assert;
use stdClass;
Expand Down Expand Up @@ -157,14 +156,14 @@ public function assert(?Throwable $e = null): void
}

if (isset($this->matchesResultDocument)) {
assertThat($e, logicalOr(isInstanceOf(CommandException::class), isInstanceOf(WriteException::class)));
assertThat($e, logicalOr(isInstanceOf(CommandException::class), isInstanceOf(BulkWriteException::class)));

if ($e instanceof CommandException) {
assertThat($e->getResultDocument(), $this->matchesResultDocument, 'CommandException result document matches');
} elseif ($e instanceof WriteException) {
} elseif ($e instanceof BulkWriteException) {
$writeErrors = $e->getWriteResult()->getErrorReplies();
assertCount(1, $writeErrors);
assertThat($writeErrors[0], $this->matchesResultDocument, 'WriteException result document matches');
assertThat($writeErrors[0], $this->matchesResultDocument, 'BulkWriteException result document matches');
}
}

Expand Down