diff --git a/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php index 0173052290047..eeca548fa3599 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php @@ -14,6 +14,10 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Exception\InvalidOptionException; +use Symfony\Component\Console\Exception\RuntimeException; +use Symfony\Component\Console\Helper\HelperSet; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Tester\CommandCompletionTester; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -42,23 +46,7 @@ public function testConfigurationWithDefaultReceiver() public function testBasicRun() { - $envelope = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]); - - $receiver = $this->createMock(ReceiverInterface::class); - $receiver->expects($this->once())->method('get')->willReturn([$envelope]); - - $receiverLocator = $this->createMock(ContainerInterface::class); - $receiverLocator->expects($this->once())->method('has')->with('dummy-receiver')->willReturn(true); - $receiverLocator->expects($this->once())->method('get')->with('dummy-receiver')->willReturn($receiver); - - $bus = $this->createMock(MessageBusInterface::class); - $bus->expects($this->once())->method('dispatch'); - - $busLocator = $this->createMock(ContainerInterface::class); - $busLocator->expects($this->once())->method('has')->with('dummy-bus')->willReturn(true); - $busLocator->expects($this->once())->method('get')->with('dummy-bus')->willReturn($bus); - - $command = new ConsumeMessagesCommand(new RoutableMessageBus($busLocator), $receiverLocator, new EventDispatcher()); + $command = $this->getConsumeMessagesCommand(); $application = new Application(); $application->add($command); @@ -72,6 +60,21 @@ public function testBasicRun() $this->assertStringContainsString('[OK] Consuming messages from transport "dummy-receiver"', $tester->getDisplay()); } + public function testBasicApplicationRun() + { + $command = $this->getConsumeMessagesCommand(); + $command->setHelperSet(new HelperSet()); + + $application = new Application(); + $doRunCommand = (new \ReflectionClass($application))->getMethod('doRunCommand'); + + $input = new ArrayInput([ + 'receivers' => ['dummy-receiver'], + '--limit' => 1, + ]); + $doRunCommand->invokeArgs($application, [$command, $input, new ConsoleOutput()]); + } + public function testRunWithBusOption() { $envelope = new Envelope(new \stdClass()); @@ -234,4 +237,25 @@ public static function provideCompletionSuggestions() yield 'receiver (no repeat)' => [['async', ''], ['async_high', 'failed']]; yield 'option --bus' => [['--bus', ''], ['messenger.bus.default']]; } + + private function getConsumeMessagesCommand(): ConsumeMessagesCommand + { + $envelope = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]); + + $receiver = $this->createMock(ReceiverInterface::class); + $receiver->expects($this->once())->method('get')->willReturn([$envelope]); + + $receiverLocator = $this->createMock(ContainerInterface::class); + $receiverLocator->expects($this->once())->method('has')->with('dummy-receiver')->willReturn(true); + $receiverLocator->expects($this->once())->method('get')->with('dummy-receiver')->willReturn($receiver); + + $bus = $this->createMock(MessageBusInterface::class); + $bus->expects($this->once())->method('dispatch'); + + $busLocator = $this->createMock(ContainerInterface::class); + $busLocator->expects($this->once())->method('has')->with('dummy-bus')->willReturn(true); + $busLocator->expects($this->once())->method('get')->with('dummy-bus')->willReturn($bus); + + return new ConsumeMessagesCommand(new RoutableMessageBus($busLocator), $receiverLocator, new EventDispatcher()); + } } diff --git a/src/Symfony/Component/Messenger/composer.json b/src/Symfony/Component/Messenger/composer.json index 7bbb47c4d26bf..1c97b37785af5 100644 --- a/src/Symfony/Component/Messenger/composer.json +++ b/src/Symfony/Component/Messenger/composer.json @@ -17,6 +17,7 @@ ], "require": { "php": ">=8.1", + "ext-pcntl": "*", "psr/log": "^1|^2|^3", "symfony/clock": "^6.3", "symfony/deprecation-contracts": "^2.5|^3"
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: