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 (),
@@ -370,6 +372,7 @@ public function testSelectGridFSBucketPassesOptions(): void
370
372
public function testWithOptionsInheritsOptions (): void
371
373
{
372
374
$ databaseOptions = [
375
+ 'builderEncoder ' => $ this ->createMock (Encoder::class),
373
376
'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
374
377
'readPreference ' => new ReadPreference (ReadPreference::SECONDARY_PREFERRED ),
375
378
'typeMap ' => ['root ' => 'array ' ],
@@ -382,19 +385,16 @@ public function testWithOptionsInheritsOptions(): void
382
385
383
386
$ this ->assertSame ($ this ->manager , $ debug ['manager ' ]);
384
387
$ 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
+ }
393
392
}
394
393
395
394
public function testWithOptionsPassesOptions (): void
396
395
{
397
396
$ databaseOptions = [
397
+ 'builderEncoder ' => $ this ->createMock (Encoder::class),
398
398
'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
399
399
'readPreference ' => new ReadPreference (ReadPreference::SECONDARY_PREFERRED ),
400
400
'typeMap ' => ['root ' => 'array ' ],
@@ -404,13 +404,8 @@ public function testWithOptionsPassesOptions(): void
404
404
$ clone = $ this ->database ->withOptions ($ databaseOptions );
405
405
$ debug = $ clone ->__debugInfo ();
406
406
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
+ }
415
410
}
416
411
}
0 commit comments