Skip to content

[Messenger] pcntl PHP extension is required since v6.3.5 with test #52575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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());
Expand Down Expand Up @@ -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());
}
}
1 change: 1 addition & 0 deletions src/Symfony/Component/Messenger/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down