public function testSend() { $envelope =
new Envelope(new DummyMessage('Oy'
));
$encoded =
['body' => '...', 'headers' =>
['type' => DummyMessage::
class]];
$connection =
$this->
createMock(Connection::
class);
$connection->
expects($this->
once())->
method('add'
)->
with($encoded['body'
],
$encoded['headers'
])->
willReturn('THE_MESSAGE_ID'
);
$serializer =
$this->
createMock(SerializerInterface::
class);
$serializer->
method('encode'
)->
with($envelope)->
willReturnOnConsecutiveCalls($encoded);
$sender =
new RedisSender($connection,
$serializer);
/** @var TransportMessageIdStamp $stamp */
$stamp =
$sender->
send($envelope)->
last(TransportMessageIdStamp::
class);
$this->
assertNotNull($stamp,
sprintf('A "%s" stamp should be added', TransportMessageIdStamp::
class));
$this->
assertSame('THE_MESSAGE_ID',
$stamp->
getId());
}}