bug #36660 [Messenger] Fix messenger:failed:remove can not remove single message (tienvx)
This PR was merged into the 5.1-dev branch.
Discussion
----------
[Messenger] Fix messenger:failed:remove can not remove single message
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #36659
| License | MIT
| Doc PR | -
Fix this error:
```
count(): Parameter must be an array or an object that implements Countable
```
When calling `messenger:failed:remove` command from other code with single id
Commits
-------
e66cd97ec3
[Messenger] Fix messenger:failed:remove can not remove single message
This commit is contained in:
commit
87a570185e
@ -61,7 +61,7 @@ EOF
|
|||||||
$receiver = $this->getReceiver();
|
$receiver = $this->getReceiver();
|
||||||
|
|
||||||
$shouldForce = $input->getOption('force');
|
$shouldForce = $input->getOption('force');
|
||||||
$ids = $input->getArgument('id');
|
$ids = (array) $input->getArgument('id');
|
||||||
$shouldDisplayMessages = $input->getOption('show-messages') || 1 === \count($ids);
|
$shouldDisplayMessages = $input->getOption('show-messages') || 1 === \count($ids);
|
||||||
$this->removeMessages($ids, $receiver, $io, $shouldForce, $shouldDisplayMessages);
|
$this->removeMessages($ids, $receiver, $io, $shouldForce, $shouldDisplayMessages);
|
||||||
|
|
||||||
|
@ -19,6 +19,23 @@ use Symfony\Component\Messenger\Transport\Receiver\ListableReceiverInterface;
|
|||||||
|
|
||||||
class FailedMessagesRemoveCommandTest extends TestCase
|
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()
|
public function testRemoveUniqueMessage()
|
||||||
{
|
{
|
||||||
$receiver = $this->createMock(ListableReceiverInterface::class);
|
$receiver = $this->createMock(ListableReceiverInterface::class);
|
||||||
|
Reference in New Issue
Block a user