[Messenger] Fix messenger:failed:remove can not remove single message

This commit is contained in:
tien.xuan.vo 2020-05-02 11:26:03 +07:00
parent c30d6f9e38
commit e66cd97ec3
2 changed files with 18 additions and 1 deletions

View File

@ -61,7 +61,7 @@ EOF
$receiver = $this->getReceiver();
$shouldForce = $input->getOption('force');
$ids = $input->getArgument('id');
$ids = (array) $input->getArgument('id');
$shouldDisplayMessages = $input->getOption('show-messages') || 1 === \count($ids);
$this->removeMessages($ids, $receiver, $io, $shouldForce, $shouldDisplayMessages);

View File

@ -19,6 +19,23 @@ use Symfony\Component\Messenger\Transport\Receiver\ListableReceiverInterface;
class FailedMessagesRemoveCommandTest extends TestCase
{
public function testRemoveSingleMessage()
{
$receiver = $this->createMock(ListableReceiverInterface::class);
$receiver->expects($this->once())->method('find')->with(20)->willReturn(new Envelope(new \stdClass()));
$command = new FailedMessagesRemoveCommand(
'failure_receiver',
$receiver
);
$tester = new CommandTester($command);
$tester->execute(['id' => 20, '--force' => true]);
$this->assertStringContainsString('Failed Message Details', $tester->getDisplay());
$this->assertStringContainsString('Message with id 20 removed.', $tester->getDisplay());
}
public function testRemoveUniqueMessage()
{
$receiver = $this->createMock(ListableReceiverInterface::class);