|
5 | 5 | use MongoDB\Driver\BulkWrite;
|
6 | 6 | use MongoDB\Driver\Exception\CommandException;
|
7 | 7 | use MongoDB\Driver\ReadPreference;
|
| 8 | +use MongoDB\Driver\Server; |
8 | 9 | use MongoDB\Driver\WriteConcern;
|
9 | 10 | use MongoDB\Exception\UnsupportedException;
|
10 | 11 | use MongoDB\Model\BSONDocument;
|
@@ -95,19 +96,21 @@ public function testHintOptionAndUnacknowledgedWriteConcernUnsupportedClientSide
|
95 | 96 |
|
96 | 97 | public function testFindAndModifyReportedWriteConcernError(): void
|
97 | 98 | {
|
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()); |
| 99 | + if (($this->isShardedCluster() && !$this->isShardedClusterUsingReplicasets()) || !$this->isReplicaSet()) { |
| 100 | + $this->markTestSkipped(sprintf('Cannot find topology for primary of type "%d".', $this->getPrimaryServer()->getType())); |
110 | 101 | }
|
| 102 | + |
| 103 | + $this->expectException(CommandException::class); |
| 104 | + $this->expectExceptionCode(100); |
| 105 | + $this->expectExceptionMessageMatches('/Write Concern error:/'); |
| 106 | + |
| 107 | + $operation = new FindAndModify( |
| 108 | + $this->getDatabaseName(), |
| 109 | + $this->getCollectionName(), |
| 110 | + ['remove' => true, 'writeConcern' => new WriteConcern(50)] |
| 111 | + ); |
| 112 | + |
| 113 | + $operation->execute($this->getPrimaryServer()); |
111 | 114 | }
|
112 | 115 |
|
113 | 116 | public function testSessionOption(): void
|
|
0 commit comments