File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
src/Symfony/Component/Messenger Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -37,4 +37,19 @@ public function testItSendsTheEncodedMessage()
37
37
$ sender = new AmqpSender ($ connection , $ serializer );
38
38
$ sender ->send ($ envelope );
39
39
}
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
+ }
40
55
}
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ public function send(Envelope $envelope): Envelope
41
41
{
42
42
$ encodedMessage = $ this ->serializer ->encode ($ envelope );
43
43
44
- $ this ->connection ->publish ($ encodedMessage ['body ' ], $ encodedMessage ['headers ' ]);
44
+ $ this ->connection ->publish ($ encodedMessage ['body ' ], $ encodedMessage ['headers ' ] ?? [] );
45
45
46
46
return $ envelope ;
47
47
}
You can’t perform that action at this time.
0 commit comments