-
Notifications
You must be signed in to change notification settings - Fork 442
feat: Make serializer configurable via YAML configuration #1390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,34 @@ public function testShouldSetJsonSerializerInConstructor() | |
$this->assertInstanceOf(JsonSerializer::class, $context->getSerializer()); | ||
} | ||
|
||
public function testShouldUseStringSerializerClassFromConfig() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding unit test that checks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what you mean by checking constructor options with method call assertions. Could you please explain in more detail? Do you mean I should check how P.S sorry for delayed response. I took a break from coding. Now I am really up to finish this. |
||
{ | ||
$mockSerializerClass = get_class($this->createMock(Serializer::class)); | ||
|
||
$context = new RdKafkaContext([ | ||
'serializer' => $mockSerializerClass, | ||
]); | ||
|
||
$this->assertInstanceOf($mockSerializerClass, $context->getSerializer()); | ||
} | ||
|
||
public function testShouldUseJsonSerializer() | ||
{ | ||
$context = new RdKafkaContext([]); | ||
|
||
$this->assertInstanceOf(JsonSerializer::class, $context->getSerializer()); | ||
} | ||
|
||
public function testShouldThrowExceptionOnInvalidSerializerConfig() | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Invalid serializer configuration'); | ||
|
||
new RdKafkaContext([ | ||
'serializer' => 123, | ||
]); | ||
} | ||
|
||
public function testShouldAllowGetPreviouslySetSerializer() | ||
{ | ||
$context = new RdKafkaContext([]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to re-specify the return type, since it's already present in the PHP declaration.
As for the description, I'm not sure it's worthwile - but nothing against it either.