-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 1.6 patch - Ensure json serialize does not double encode messages * code clean
- Loading branch information
1 parent
eed46ab
commit 7ef6099
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Junges\Kafka\Tests\Producers; | ||
|
||
use Junges\Kafka\Config\Config; | ||
use Junges\Kafka\Message\Serializers\JsonSerializer; | ||
use Junges\Kafka\Producers\Producer; | ||
use Junges\Kafka\Tests\LaravelKafkaTestCase; | ||
use Junges\Kafka\Message\Message; | ||
|
||
class ProducerTest extends LaravelKafkaTestCase | ||
{ | ||
public function testItDoesNotDoubleSerializeMessageWhenUsingJsonSerializer() | ||
{ | ||
$this->mockKafkaProducer(); | ||
$producer = new Producer(new Config('broker', ['test-topic']), 'test-topic', new JsonSerializer()); | ||
$payload = ['key' => 'value']; | ||
|
||
$message = new Message( | ||
body: $payload, | ||
); | ||
$producer->produce($message); | ||
$producer->produce($message); | ||
|
||
$this->assertSame($payload, $message->getBody()); | ||
} | ||
} |