Skip to content
Permalink
Browse files

bug #30466 [Messenger] Make 'headers' key optional for encoded messag…

…es (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
-------

bb881c9 Make 'headers' key optional for encoded messages
  • Loading branch information...
fabpot committed Mar 9, 2019
2 parents bfcc607 + bb881c9 commit 9c6049079896d466c78db5aa7fd14a5032aef1d8
@@ -37,4 +37,19 @@ public function testItSendsTheEncodedMessage()
$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 @@ public function send(Envelope $envelope): Envelope
{
$encodedMessage = $this->serializer->encode($envelope);
$this->connection->publish($encodedMessage['body'], $encodedMessage['headers']);
$this->connection->publish($encodedMessage['body'], $encodedMessage['headers'] ?? []);
return $envelope;
}

0 comments on commit 9c60490

Please sign in to comment.
You can’t perform that action at this time.