Make 'headers' key optional for encoded messages
This commit is contained in:
parent
675c45850c
commit
bb881c9cd0
@ -37,4 +37,19 @@ class AmqpSenderTest extends TestCase
|
||||
$sender = new AmqpSender($connection, $serializer);
|
||||
$sender->send($envelope);
|
||||
}
|
||||
|
||||
public function testItSendsTheEncodedMessageWithoutHeaders()
|
||||
{
|
||||
$envelope = new Envelope(new DummyMessage('Oy'));
|
||||
$encoded = ['body' => '...'];
|
||||
|
||||
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
|
||||
$serializer->method('encode')->with($envelope)->willReturnOnConsecutiveCalls($encoded);
|
||||
|
||||
$connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock();
|
||||
$connection->expects($this->once())->method('publish')->with($encoded['body'], []);
|
||||
|
||||
$sender = new AmqpSender($connection, $serializer);
|
||||
$sender->send($envelope);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class AmqpSender implements SenderInterface
|
||||
{
|
||||
$encodedMessage = $this->serializer->encode($envelope);
|
||||
|
||||
$this->connection->publish($encodedMessage['body'], $encodedMessage['headers']);
|
||||
$this->connection->publish($encodedMessage['body'], $encodedMessage['headers'] ?? []);
|
||||
|
||||
return $envelope;
|
||||
}
|
||||
|
Reference in New Issue
Block a user