Assert not published
To assert that a given message was not published, use the assertNotPublished method. Like assertPublished, it accepts an expected message, a callback, or both:
use Junges\Kafka\Contracts\ProducerMessage; use Junges\Kafka\Facades\Kafka; use Tests\TestCase; class MyTest extends TestCase { public function testCancelledOrdersAreNotPublished() { Kafka::fake(); $this->post('/orders/1/cancel'); Kafka::assertNotPublished(function (ProducerMessage $message) { return $message->getTopicName() === 'orders' && $message->getBody()['id'] === 1; }); } }
To assert that nothing was published on a topic, use the assertNothingPublishedOn method:
Kafka::assertNothingPublishedOn('orders');
Sponsorship
Support Laravel Kafka by sponsoring me!
Laravel Kafka is free and Open Source software, built to empower developers like you. Your support helps maintain and enhance the project. If you find it valuable, please consider sponsoring me on GitHub. Every contribution makes a difference and keeps the development going strong! Thank you!
Become a Sponsor
Want to hide this message? Sponsor at any tier of $10/month or more!