File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-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,25 @@ public function testHintOptionAndUnacknowledgedWriteConcernUnsupportedClientSide
92
93
$ operation ->execute ($ this ->getPrimaryServer ());
93
94
}
94
95
96
+ public function testFindAndModifyReportedWriteConcernError (): void
97
+ {
98
+ if (($ this ->isShardedCluster () && ! $ this ->isShardedClusterUsingReplicasets ()) || ! $ this ->isReplicaSet ()) {
99
+ $ this ->markTestSkipped ('Test only applies to replica sets ' );
100
+ }
101
+
102
+ $ this ->expectException (CommandException::class);
103
+ $ this ->expectExceptionCode (100 );
104
+ $ this ->expectExceptionMessageMatches ('/Write Concern error:/ ' );
105
+
106
+ $ operation = new FindAndModify (
107
+ $ this ->getDatabaseName (),
108
+ $ this ->getCollectionName (),
109
+ ['remove ' => true , 'writeConcern ' => new WriteConcern (50 )]
110
+ );
111
+
112
+ $ operation ->execute ($ this ->getPrimaryServer ());
113
+ }
114
+
95
115
public function testSessionOption (): void
96
116
{
97
117
(new CommandObserver ())->observe (
You can’t perform that action at this time.
0 commit comments