File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed 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()
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}
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments