|
3 | 3 | namespace MongoDB\Tests\Operation;
|
4 | 4 |
|
5 | 5 | use MongoDB\Driver\BulkWrite;
|
| 6 | +use MongoDB\Driver\Exception\CommandException; |
6 | 7 | use MongoDB\Driver\ReadPreference;
|
7 | 8 | use MongoDB\Driver\WriteConcern;
|
| 9 | +use MongoDB\Exception\Exception; |
8 | 10 | use MongoDB\Exception\UnsupportedException;
|
9 | 11 | use MongoDB\Model\BSONDocument;
|
10 | 12 | use MongoDB\Operation\FindAndModify;
|
@@ -92,6 +94,23 @@ public function testHintOptionAndUnacknowledgedWriteConcernUnsupportedClientSide
|
92 | 94 | $operation->execute($this->getPrimaryServer());
|
93 | 95 | }
|
94 | 96 |
|
| 97 | + public function testFindAndModifyReportedWriteConcernError(): void |
| 98 | + { |
| 99 | + try { |
| 100 | + $operation = new FindAndModify( |
| 101 | + $this->getDatabaseName(), |
| 102 | + $this->getCollectionName(), |
| 103 | + ['remove' => true, 'writeConcern' => new WriteConcern(50) ] |
| 104 | + ); |
| 105 | + |
| 106 | + $operation->execute($this->getPrimaryServer()); |
| 107 | + } catch (CommandException $e) { |
| 108 | + $this->assertInstanceOf(CommandException::class, $e); |
| 109 | + $this->assertStringContainsString('Write Concern error', $e->getMessage()); |
| 110 | + $this->assertSame(100, $e->getCode()); |
| 111 | + } |
| 112 | + } |
| 113 | + |
95 | 114 | public function testSessionOption(): void
|
96 | 115 | {
|
97 | 116 | (new CommandObserver())->observe(
|
|
0 commit comments