This is the documentation for
v1.8 but the latest version is
v1.13
.
You can switch versions in the menu on the left/at the top.
Check your current version with the following command:
composer show mateusjunges/laravel-kafka
Sometimes, you need to assert that Kafka has published a given number of messages. For that, you can use the assertPublishedTimes
method:
use PHPUnit\Framework\TestCase;
use Junges\Kafka\Facades\Kafka;
use Junges\Kafka\Message\Message;
class MyTest extends TestCase
{
public function testWithSpecificTopic()
{
Kafka::fake();
Kafka::publishOn('some-kafka-topic')
->withHeaders(['key' => 'value'])
->withBodyKey('key', 'value');
Kafka::publishOn('some-kafka-topic')
->withHeaders(['key' => 'value'])
->withBodyKey('key', 'value');
Kafka::assertPublishedTimes(2);
}
}