Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ae8ba65

Browse files
Merge v1.x into v2.x (#1644)
2 parents f241cb5 + 2bdc0c4 commit ae8ba65

File tree

3 files changed

+24
-34
lines changed

3 files changed

+24
-34
lines changed

‎src/Database.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ public function watch(array|Pipeline $pipeline = [], array $options = []): Chang
623623
public function withOptions(array $options = []): Database
624624
{
625625
$options += [
626+
'builderEncoder' => $this->builderEncoder,
626627
'readConcern' => $this->readConcern,
627628
'readPreference' => $this->readPreference,
628629
'typeMap' => $this->typeMap,

‎tests/Collection/CollectionFunctionalTest.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace MongoDB\Tests\Collection;
44

55
use Closure;
6+
use MongoDB\Codec\DocumentCodec;
67
use MongoDB\Codec\Encoder;
78
use MongoDB\Collection;
89
use MongoDB\Database;
@@ -369,6 +370,8 @@ public function testRenameToDifferentDatabase(): void
369370
public function testWithOptionsInheritsOptions(): void
370371
{
371372
$collectionOptions = [
373+
'builderEncoder' => $this->createMock(Encoder::class),
374+
'codec' => $this->createMock(DocumentCodec::class),
372375
'readConcern' => new ReadConcern(ReadConcern::LOCAL),
373376
'readPreference' => new ReadPreference(ReadPreference::SECONDARY_PREFERRED),
374377
'typeMap' => ['root' => 'array'],
@@ -382,20 +385,17 @@ public function testWithOptionsInheritsOptions(): void
382385
$this->assertSame($this->manager, $debug['manager']);
383386
$this->assertSame($this->getDatabaseName(), $debug['databaseName']);
384387
$this->assertSame($this->getCollectionName(), $debug['collectionName']);
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 ($collectionOptions as $key => $value) {
390+
$this->assertSame($value, $debug[$key]);
391+
}
393392
}
394393

395394
public function testWithOptionsPassesOptions(): void
396395
{
397396
$collectionOptions = [
398-
'builderEncoder' => $builderEncoder = $this->createMock(Encoder::class),
397+
'builderEncoder' => $this->createMock(Encoder::class),
398+
'codec' => $this->createMock(DocumentCodec::class),
399399
'readConcern' => new ReadConcern(ReadConcern::LOCAL),
400400
'readPreference' => new ReadPreference(ReadPreference::SECONDARY_PREFERRED),
401401
'typeMap' => ['root' => 'array'],
@@ -405,15 +405,9 @@ public function testWithOptionsPassesOptions(): void
405405
$clone = $this->collection->withOptions($collectionOptions);
406406
$debug = $clone->__debugInfo();
407407

408-
$this->assertSame($builderEncoder, $debug['builderEncoder']);
409-
$this->assertInstanceOf(ReadConcern::class, $debug['readConcern']);
410-
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
411-
$this->assertInstanceOf(ReadPreference::class, $debug['readPreference']);
412-
$this->assertSame(ReadPreference::SECONDARY_PREFERRED, $debug['readPreference']->getModeString());
413-
$this->assertIsArray($debug['typeMap']);
414-
$this->assertSame(['root' => 'array'], $debug['typeMap']);
415-
$this->assertInstanceOf(WriteConcern::class, $debug['writeConcern']);
416-
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
408+
foreach ($collectionOptions as $key => $value) {
409+
$this->assertSame($value, $debug[$key]);
410+
}
417411
}
418412

419413
public static function collectionMethodClosures()

‎tests/Database/DatabaseFunctionalTest.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace MongoDB\Tests\Database;
44

55
use MongoDB\BSON\PackedArray;
6+
use MongoDB\Codec\Encoder;
67
use MongoDB\Collection;
78
use MongoDB\Database;
89
use 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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /