File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 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 ;
8
9
use MongoDB \Exception \UnsupportedException ;
@@ -92,6 +93,23 @@ public function testHintOptionAndUnacknowledgedWriteConcernUnsupportedClientSide
92
93
$ operation ->execute ($ this ->getPrimaryServer ());
93
94
}
94
95
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
+
95
113
public function testSessionOption (): void
96
114
{
97
115
(new CommandObserver ())->observe (
You can’t perform that action at this time.
0 commit comments