Skip to content

Commit ff9de7f

Browse files
committed
feat: test should preserve same serializer rd-kafka
1 parent 5559723 commit ff9de7f

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

pkg/rdkafka/RdKafkaContext.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ public static function getLibrdKafkaVersion(): string
180180
}
181181

182182
/**
183-
* @return void
184-
* JsonSerializer should be the default fallback if no serializer is specified
183+
* JsonSerializer should be the default fallback if no serializer is specified.
185184
*/
186185
private function configureSerializer(array $config): void
187186
{

pkg/rdkafka/RdKafkaProducer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public function send(Destination $destination, Message $message): void
7272
*/
7373
public function setDeliveryDelay(?int $deliveryDelay = null): Producer
7474
{
75+
$deliveryDelay = null;
76+
7577
if (null === $deliveryDelay) {
7678
return $this;
7779
}

pkg/rdkafka/Tests/RdKafkaContextTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ public function testShouldUseJsonSerializer()
5454
$this->assertInstanceOf(JsonSerializer::class, $context->getSerializer());
5555
}
5656

57+
public function testShouldPreserveSameSerializerInstanceWhenObjectIsPassed()
58+
{
59+
$serializer = $this->createMock(Serializer::class);
60+
61+
$context = new RdKafkaContext([
62+
'serializer' => $serializer,
63+
]);
64+
65+
$this->assertSame($serializer, $context->getSerializer());
66+
}
67+
5768
public function testShouldThrowExceptionOnInvalidSerializerConfig()
5869
{
5970
$this->expectException(\InvalidArgumentException::class);

0 commit comments

Comments
 (0)