33namespace MongoDB \Tests \Database ;
44
55use MongoDB \BSON \PackedArray ;
6+ use MongoDB \Codec \Encoder ;
67use MongoDB \Collection ;
78use MongoDB \Database ;
89use MongoDB \Driver \BulkWrite ;
@@ -50,6 +51,7 @@ public function testConstructorOptionTypeChecks(array $options): void
5051 public static function provideInvalidConstructorOptions ()
5152 {
5253 return self ::createOptionDataProvider ([
54+ 'builderEncoder ' => self ::getInvalidObjectValues (),
5355 'readConcern ' => self ::getInvalidReadConcernValues (),
5456 'readPreference ' => self ::getInvalidReadPreferenceValues (),
5557 'typeMap ' => self ::getInvalidArrayValues (),
@@ -370,6 +372,7 @@ public function testSelectGridFSBucketPassesOptions(): void
370372 public function testWithOptionsInheritsOptions (): void
371373 {
372374 $ databaseOptions = [
375+ 'builderEncoder ' => $ this ->createMock (Encoder::class),
373376 'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
374377 'readPreference ' => new ReadPreference (ReadPreference::SECONDARY_PREFERRED ),
375378 'typeMap ' => ['root ' => 'array ' ],
@@ -382,19 +385,16 @@ public function testWithOptionsInheritsOptions(): void
382385
383386 $ this ->assertSame ($ this ->manager , $ debug ['manager ' ]);
384387 $ this ->assertSame ($ this ->getDatabaseName (), $ debug ['databaseName ' ]);
385- $ this ->assertInstanceOf (ReadConcern::class, $ debug ['readConcern ' ]);
386- $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
387- $ this ->assertInstanceOf (ReadPreference::class, $ debug ['readPreference ' ]);
388- $ this ->assertSame (ReadPreference::SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getModeString ());
389- $ this ->assertIsArray ($ debug ['typeMap ' ]);
390- $ this ->assertSame (['root ' => 'array ' ], $ debug ['typeMap ' ]);
391- $ this ->assertInstanceOf (WriteConcern::class, $ debug ['writeConcern ' ]);
392- $ this ->assertSame (WriteConcern::MAJORITY , $ debug ['writeConcern ' ]->getW ());
388+
389+ foreach ($ databaseOptions as $ key => $ value ) {
390+ $ this ->assertSame ($ value , $ debug [$ key ]);
391+ }
393392 }
394393
395394 public function testWithOptionsPassesOptions (): void
396395 {
397396 $ databaseOptions = [
397+ 'builderEncoder ' => $ this ->createMock (Encoder::class),
398398 'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
399399 'readPreference ' => new ReadPreference (ReadPreference::SECONDARY_PREFERRED ),
400400 'typeMap ' => ['root ' => 'array ' ],
@@ -404,13 +404,8 @@ public function testWithOptionsPassesOptions(): void
404404 $ clone = $ this ->database ->withOptions ($ databaseOptions );
405405 $ debug = $ clone ->__debugInfo ();
406406
407- $ this ->assertInstanceOf (ReadConcern::class, $ debug ['readConcern ' ]);
408- $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
409- $ this ->assertInstanceOf (ReadPreference::class, $ debug ['readPreference ' ]);
410- $ this ->assertSame (ReadPreference::SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getModeString ());
411- $ this ->assertIsArray ($ debug ['typeMap ' ]);
412- $ this ->assertSame (['root ' => 'array ' ], $ debug ['typeMap ' ]);
413- $ this ->assertInstanceOf (WriteConcern::class, $ debug ['writeConcern ' ]);
414- $ this ->assertSame (WriteConcern::MAJORITY , $ debug ['writeConcern ' ]->getW ());
407+ foreach ($ databaseOptions as $ key => $ value ) {
408+ $ this ->assertSame ($ value , $ debug [$ key ]);
409+ }
415410 }
416411}
0 commit comments