File tree 1 file changed +46
-0
lines changed
1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,52 @@ public function testShouldGetPartitionFromDestination(): void
323
323
$ producer ->send ($ destination , $ message );
324
324
}
325
325
326
+ public function testShouldAllowFalsyKeyFromMessage (): void
327
+ {
328
+ $ key = 0 ;
329
+
330
+ $ kafkaTopic = $ this ->createKafkaTopicMock ();
331
+ $ kafkaTopic
332
+ ->expects ($ this ->once ())
333
+ ->method ('producev ' )
334
+ ->with (
335
+ RD_KAFKA_PARTITION_UA ,
336
+ 0 ,
337
+ '' ,
338
+ $ key
339
+ )
340
+ ;
341
+
342
+ $ message = new RdKafkaMessage ();
343
+ $ message ->setKey ($ key );
344
+
345
+ $ producer = new RdKafkaProducer ($ this ->createKafkaProducerMock (), $ this ->createSerializerMock ());
346
+ $ producer ->send (new RdKafkaTopic ('' ), $ message );
347
+ }
348
+
349
+ public function testShouldAllowFalsyKeyFromDestination (): void
350
+ {
351
+ $ key = 0 ;
352
+
353
+ $ kafkaTopic = $ this ->createKafkaTopicMock ();
354
+ $ kafkaTopic
355
+ ->expects ($ this ->once ())
356
+ ->method ('producev ' )
357
+ ->with (
358
+ RD_KAFKA_PARTITION_UA ,
359
+ 0 ,
360
+ '' ,
361
+ $ key
362
+ )
363
+ ;
364
+
365
+ $ destination = new RdKafkaTopic ('' );
366
+ $ destination ->setKey ($ key );
367
+
368
+ $ producer = new RdKafkaProducer ($ this ->createKafkaProducerMock (), $ this ->createSerializerMock ());
369
+ $ producer ->send ($ destination , new RdKafkaMessage ());
370
+ }
371
+
326
372
/**
327
373
* @return \PHPUnit\Framework\MockObject\MockObject|ProducerTopic
328
374
*/
You can’t perform that action at this time.
0 commit comments