Skip to content

Commit 5547d0e

Browse files
committed
Test Collection::getBuilderEncoder() and getCodec()
Also fixes the return type for getBuilderEncoder()
1 parent 3ecb8df commit 5547d0e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Collection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ public function findOneAndUpdate(array|object $filter, array|object $update, arr
753753
return $operation->execute(select_server_for_write($this->manager, $options));
754754
}
755755

756-
public function getBuilderEncoder(): BuilderEncoder
756+
public function getBuilderEncoder(): Encoder
757757
{
758758
return $this->builderEncoder;
759759
}

tests/Collection/CollectionFunctionalTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,22 @@ public static function provideInvalidConstructorOptions(): array
7777
]);
7878
}
7979

80+
public function testGetBuilderEncoder(): void
81+
{
82+
$collectionOptions = ['builderEncoder' => $this->createMock(Encoder::class)];
83+
$collection = new Collection($this->manager, $this->getDatabaseName(), $this->getCollectionName(), $collectionOptions);
84+
85+
$this->assertSame($collectionOptions['builderEncoder'], $collection->getBuilderEncoder());
86+
}
87+
88+
public function testGetCodec(): void
89+
{
90+
$collectionOptions = ['codec' => $this->createMock(DocumentCodec::class)];
91+
$collection = new Collection($this->manager, $this->getDatabaseName(), $this->getCollectionName(), $collectionOptions);
92+
93+
$this->assertSame($collectionOptions['codec'], $collection->getCodec());
94+
}
95+
8096
public function testGetManager(): void
8197
{
8298
$this->assertSame($this->manager, $this->collection->getManager());

0 commit comments

Comments
 (0)