Skip to content

Commit 996522c

Browse files
author
levon80999
committed
PHPLIB-638: Ensure writeConcernError is reported for findAndModify
1 parent 3a9c15e commit 996522c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/Operation/FindAndModifyFunctionalTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace MongoDB\Tests\Operation;
44

55
use MongoDB\Driver\BulkWrite;
6+
use MongoDB\Driver\Exception\CommandException;
67
use MongoDB\Driver\ReadPreference;
78
use MongoDB\Driver\WriteConcern;
89
use MongoDB\Exception\UnsupportedException;
@@ -92,6 +93,23 @@ public function testHintOptionAndUnacknowledgedWriteConcernUnsupportedClientSide
9293
$operation->execute($this->getPrimaryServer());
9394
}
9495

96+
public function testFindAndModifyReportedWriteConcernError(): void
97+
{
98+
try {
99+
$operation = new FindAndModify(
100+
$this->getDatabaseName(),
101+
$this->getCollectionName(),
102+
['remove' => true, 'writeConcern' => new WriteConcern(50)]
103+
);
104+
105+
$operation->execute($this->getPrimaryServer());
106+
} catch (CommandException $e) {
107+
$this->assertInstanceOf(CommandException::class, $e);
108+
$this->assertStringContainsString('Write Concern error', $e->getMessage());
109+
$this->assertSame(100, $e->getCode());
110+
}
111+
}
112+
95113
public function testSessionOption(): void
96114
{
97115
(new CommandObserver())->observe(

0 commit comments

Comments
 (0)