3
3
namespace MongoDB \Tests \Database ;
4
4
5
5
use MongoDB \BSON \PackedArray ;
6
+ use MongoDB \Codec \Encoder ;
6
7
use MongoDB \Collection ;
7
8
use MongoDB \Database ;
8
9
use MongoDB \Driver \BulkWrite ;
@@ -50,6 +51,7 @@ public function testConstructorOptionTypeChecks(array $options): void
50
51
public static function provideInvalidConstructorOptions ()
51
52
{
52
53
return self ::createOptionDataProvider ([
54
+ 'builderEncoder ' => self ::getInvalidObjectValues (),
53
55
'readConcern ' => self ::getInvalidReadConcernValues (),
54
56
'readPreference ' => self ::getInvalidReadPreferenceValues (),
55
57
'typeMap ' => self ::getInvalidArrayValues (),
@@ -366,6 +368,7 @@ public function testSelectGridFSBucketPassesOptions(): void
366
368
public function testWithOptionsInheritsOptions (): void
367
369
{
368
370
$ databaseOptions = [
371
+ 'builderEncoder ' => $ this ->createMock (Encoder::class),
369
372
'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
370
373
'readPreference ' => new ReadPreference (ReadPreference::SECONDARY_PREFERRED ),
371
374
'typeMap ' => ['root ' => 'array ' ],
@@ -378,19 +381,16 @@ public function testWithOptionsInheritsOptions(): void
378
381
379
382
$ this ->assertSame ($ this ->manager , $ debug ['manager ' ]);
380
383
$ 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
+ }
389
388
}
390
389
391
390
public function testWithOptionsPassesOptions (): void
392
391
{
393
392
$ databaseOptions = [
393
+ 'builderEncoder ' => $ this ->createMock (Encoder::class),
394
394
'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
395
395
'readPreference ' => new ReadPreference (ReadPreference::SECONDARY_PREFERRED ),
396
396
'typeMap ' => ['root ' => 'array ' ],
@@ -400,13 +400,8 @@ public function testWithOptionsPassesOptions(): void
400
400
$ clone = $ this ->database ->withOptions ($ databaseOptions );
401
401
$ debug = $ clone ->__debugInfo ();
402
402
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
+ }
411
406
}
412
407
}
0 commit comments