@@ -320,12 +320,14 @@ public function testExternalKeyVault($withExternalKeyVault)
320
320
$ client = $ this ->getContext ()->getClient ();
321
321
$ client ->selectCollection ('db ' , 'coll ' )->drop ();
322
322
323
- $ keyId = $ client
324
- ->selectCollection ('keyvault ' , 'datakeys ' )
325
- ->insertOne (
326
- $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption/external/external-key.json ' )),
327
- ['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY )]
328
- )
323
+ $ keyVaultCollection = $ client ->selectCollection (
324
+ 'keyvault ' ,
325
+ 'datakeys ' ,
326
+ ['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY )] + $ this ->getContext ()->defaultWriteOptions
327
+ );
328
+ $ keyVaultCollection ->drop ();
329
+ $ keyId = $ keyVaultCollection
330
+ ->insertOne ($ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption/external/external-key.json ' )))
329
331
->getInsertedId ();
330
332
331
333
$ encryptionOpts = [
@@ -400,14 +402,15 @@ function () use ($collection) {
400
402
]);
401
403
},
402
404
function ($ command ) use (&$ commands ) {
405
+ if ($ command ['started ' ]->getCommandName () !== 'insert ' ) {
406
+ return ;
407
+ }
408
+
403
409
$ commands [] = $ command ;
404
410
}
405
411
);
406
412
407
413
$ test ->assertCount (2 , $ commands );
408
- foreach ($ commands as $ command ) {
409
- $ test ->assertSame ('insert ' , $ command ['started ' ]->getCommandName ());
410
- }
411
414
},
412
415
];
413
416
@@ -428,14 +431,15 @@ function () use ($collection, $document) {
428
431
]);
429
432
},
430
433
function ($ command ) use (&$ commands ) {
434
+ if ($ command ['started ' ]->getCommandName () !== 'insert ' ) {
435
+ return ;
436
+ }
437
+
431
438
$ commands [] = $ command ;
432
439
}
433
440
);
434
441
435
442
$ test ->assertCount (2 , $ commands );
436
- foreach ($ commands as $ command ) {
437
- $ test ->assertSame ('insert ' , $ command ['started ' ]->getCommandName ());
438
- }
439
443
},
440
444
];
441
445
0 commit comments