@@ -320,12 +320,14 @@ public function testExternalKeyVault($withExternalKeyVault)
320320 $ client = $ this ->getContext ()->getClient ();
321321 $ client ->selectCollection ('db ' , 'coll ' )->drop ();
322322
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 ' )))
329331 ->getInsertedId ();
330332
331333 $ encryptionOpts = [
@@ -400,14 +402,15 @@ function () use ($collection) {
400402 ]);
401403 },
402404 function ($ command ) use (&$ commands ) {
405+ if ($ command ['started ' ]->getCommandName () !== 'insert ' ) {
406+ return ;
407+ }
408+
403409 $ commands [] = $ command ;
404410 }
405411 );
406412
407413 $ test ->assertCount (2 , $ commands );
408- foreach ($ commands as $ command ) {
409- $ test ->assertSame ('insert ' , $ command ['started ' ]->getCommandName ());
410- }
411414 },
412415 ];
413416
@@ -428,14 +431,15 @@ function () use ($collection, $document) {
428431 ]);
429432 },
430433 function ($ command ) use (&$ commands ) {
434+ if ($ command ['started ' ]->getCommandName () !== 'insert ' ) {
435+ return ;
436+ }
437+
431438 $ commands [] = $ command ;
432439 }
433440 );
434441
435442 $ test ->assertCount (2 , $ commands );
436- foreach ($ commands as $ command ) {
437- $ test ->assertSame ('insert ' , $ command ['started ' ]->getCommandName ());
438- }
439443 },
440444 ];
441445
0 commit comments