Skip to content

Commit 3dc034a

Browse files
Merge branch '4.2'
* 4.2: (27 commits) cs fix cs fix [PHPUnit-Bridge] override some environment variables [TwigBridge] Remove use spaceless tag Upgrade zookeeper ext [translation] Update defaut format from yml to yaml Change default log level for output streams update docblock to match the actual behavior Don't resolve the Deprecation error handler mode until a deprecation is triggered compatibility with phpunit8 Make 'headers' key optional for encoded messages [Debug][DebugClassLoader] Detect annotations before blank docblock lines on final and internal methods Fix undefined variable fromConstructor when passing context to getTypes Added translations for chineese language. Allow 3rd argument to be null Remove whitespace (tab on blank line) [Monolog] Really reset logger when calling logger::reset() [Form] Fixes debug:form appears many times as type extensions configured with new getExtendedTypes method Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php ...
2 parents 83e3a0b + 9942f6c commit 3dc034a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Tests/Transport/AmqpExt/AmqpSenderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ public function testItSendsTheEncodedMessage()
3838
$sender->send($envelope);
3939
}
4040

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+
}
55+
4156
/**
4257
* @expectedException \Symfony\Component\Messenger\Exception\TransportException
4358
*/

Transport/AmqpExt/AmqpSender.php

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

4545
try {
46-
$this->connection->publish($encodedMessage['body'], $encodedMessage['headers']);
46+
$this->connection->publish($encodedMessage['body'], $encodedMessage['headers'] ?? []);
4747
} catch (\AMQPException $e) {
4848
throw new TransportException($e->getMessage(), 0, $e);
4949
}

0 commit comments

Comments
 (0)