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 (),
@@ -366,6 +368,7 @@ public function testSelectGridFSBucketPassesOptions(): void
366368 public function testWithOptionsInheritsOptions (): void
367369 {
368370 $ databaseOptions = [
371+ 'builderEncoder ' => $ this ->createMock (Encoder::class),
369372 'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
370373 'readPreference ' => new ReadPreference (ReadPreference::SECONDARY_PREFERRED ),
371374 'typeMap ' => ['root ' => 'array ' ],
@@ -378,19 +381,16 @@ public function testWithOptionsInheritsOptions(): void
378381
379382 $ this ->assertSame ($ this ->manager , $ debug ['manager ' ]);
380383 $ this ->assertSame ($ this ->getDatabaseName (), $ debug ['databaseName ' ]);
381- $ this ->assertInstanceOf (ReadConcern::class, $ debug ['readConcern ' ]);
382- $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
383- $ this ->assertInstanceOf (ReadPreference::class, $ debug ['readPreference ' ]);
384- $ this ->assertSame (ReadPreference::SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getModeString ());
385- $ this ->assertIsArray ($ debug ['typeMap ' ]);
386- $ this ->assertSame (['root ' => 'array ' ], $ debug ['typeMap ' ]);
387- $ this ->assertInstanceOf (WriteConcern::class, $ debug ['writeConcern ' ]);
388- $ this ->assertSame (WriteConcern::MAJORITY , $ debug ['writeConcern ' ]->getW ());
384+
385+ foreach ($ databaseOptions as $ key => $ value ) {
386+ $ this ->assertSame ($ value , $ debug [$ key ]);
387+ }
389388 }
390389
391390 public function testWithOptionsPassesOptions (): void
392391 {
393392 $ databaseOptions = [
393+ 'builderEncoder ' => $ this ->createMock (Encoder::class),
394394 'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
395395 'readPreference ' => new ReadPreference (ReadPreference::SECONDARY_PREFERRED ),
396396 'typeMap ' => ['root ' => 'array ' ],
@@ -400,13 +400,8 @@ public function testWithOptionsPassesOptions(): void
400400 $ clone = $ this ->database ->withOptions ($ databaseOptions );
401401 $ debug = $ clone ->__debugInfo ();
402402
403- $ this ->assertInstanceOf (ReadConcern::class, $ debug ['readConcern ' ]);
404- $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
405- $ this ->assertInstanceOf (ReadPreference::class, $ debug ['readPreference ' ]);
406- $ this ->assertSame (ReadPreference::SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getModeString ());
407- $ this ->assertIsArray ($ debug ['typeMap ' ]);
408- $ this ->assertSame (['root ' => 'array ' ], $ debug ['typeMap ' ]);
409- $ this ->assertInstanceOf (WriteConcern::class, $ debug ['writeConcern ' ]);
410- $ this ->assertSame (WriteConcern::MAJORITY , $ debug ['writeConcern ' ]->getW ());
403+ foreach ($ databaseOptions as $ key => $ value ) {
404+ $ this ->assertSame ($ value , $ debug [$ key ]);
405+ }
411406 }
412407}
0 commit comments