/** * @covers ::consumeMessage * @covers ::produceMessage * @covers ::acknowledgeMessage * @covers ::emulateReconnect */ public function testOnlyAckedMessagesComeBackOnReconnect() { $message_bank = new MessageBank(); $acked_message = 'a-' . uniqid(); $unacked_message = 'b-' . uniqid(); $message_bank->produceMessage($acked_message); $message_bank->produceMessage($unacked_message); $consumed_ack_message = $message_bank->consumeMessage(); $this->assertSame($acked_message, $consumed_ack_message->getContent()); $consumed_ack_message->acknowledge(); $this->assertSame($unacked_message, $message_bank->consumeMessage()->getContent()); $message_bank->emulateReconnect(); $this->assertSame($unacked_message, $message_bank->consumeMessage()->getContent()); }
/** * @param string[] $messages */ public function produceMessageBatch(array $messages) { foreach ($messages as $message) { $this->message_bank->produceMessage($message->getEncodedContent()); } }