8000 Make 'headers' key optional for encoded messages · symfony/symfony@bb881c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit bb881c9

Browse files
committed
Make 'headers' key optional for encoded messages
1 parent 675c458 commit bb881c9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,19 @@ public function testItSendsTheEncodedMessage()
3737
$sender = new AmqpSender($connection, $serializer);
3838
$sender->send($envelope);
3939
}
40+
41+
public function testItSendsTheEncodedMessageWithoutHeaders()
42+
{
43+
$envelope = new Envelope(new DummyMessage('Oy'));
44+
$encoded = ['body' => '...'];
45+
46+
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
47+
$serializer->method('encode')->with($envelope)->willReturnOnConsecutiveCalls($encoded);
48+
49+
$connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock();
50+
$connection->expects($this->once())->method('publish')->with($encoded['body'], []);
51+
52+
$sender = new AmqpSender($connection, $serializer);
53+
$sender->send($envelope);
54+
}
4055
}

src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function send(Envelope $envelope): Envelope
4141
{
4242
$encodedMessage = $this->serializer->encode($envelope);
4343

44-
$this->connection->publish($encodedMessage['body'], $encodedMessage['headers']);
44+
$this->connection->publish($encodedMessage['body'], $encodedMessage['headers'] ?? []);
4545

4646
return $envelope;
4747
}

0 commit comments

Comments
 (0)
0