This is the documentation for
v1.12 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
To assert that messages were published on a given topic a given number of times, you can use the assertPublishedOnTimes
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::assertPublishedOnTimes('some-kafka-topic', 2);
}
}