bug #30466 [Messenger] Make 'headers' key optional for encoded messages (yceruto)
This PR was merged into the 4.2 branch.
Discussion
----------
[Messenger] Make 'headers' key optional for encoded messages
| Q | A
| ------------- | ---
| Branch? | 4.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #30455
| License | MIT
Commits
-------
bb881c9cd0
Make 'headers' key optional for encoded messages
This commit is contained in:
commit
9c60490798
@ -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