Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c71348a

Browse filesBrowse files
committed
minor #52897 [Messenger] Fix timing-out test on messenger:consume with --all option (alexandre-daubois)
This PR was merged into the 7.1 branch. Discussion ---------- [Messenger] Fix timing-out test on `messenger:consume` with `--all` option | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT CI times out since #52411, this aims to fix the test that causes this. Commits ------- 36307a0 [Messenger] Fix test on `messenger:consume` with `--all` option
2 parents dc330b0 + 36307a0 commit c71348a
Copy full SHA for c71348a

File tree

1 file changed

+19
-11
lines changed
Filter options

1 file changed

+19
-11
lines changed

‎src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php
+19-11Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,34 +220,42 @@ public function testRunWithAllOption()
220220
$envelope2 = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]);
221221

222222
$receiver1 = $this->createMock(ReceiverInterface::class);
223-
$receiver1->expects($this->once())->method('get')->willReturn([$envelope1]);
223+
$receiver1->method('get')->willReturn([$envelope1]);
224224
$receiver2 = $this->createMock(ReceiverInterface::class);
225-
$receiver2->expects($this->once())->method('get')->willReturn([$envelope2]);
225+
$receiver2->method('get')->willReturn([$envelope2]);
226226

227227
$receiverLocator = $this->createMock(ContainerInterface::class);
228-
$receiverLocator->expects($this->once())->method('has')->with('dummy-receiver1')->willReturn(true);
229-
$receiverLocator->expects($this->once())->method('get')->with('dummy-receiver1')->willReturn($receiver1);
230-
$receiverLocator->expects($this->once())->method('has')->with('dummy-receiver2')->willReturn(true);
231-
$receiverLocator->expects($this->once())->method('get')->with('dummy-receiver2')->willReturn($receiver2);
228+
$receiverLocator->expects($this->exactly(2))
229+
->method('has')
230+
->willReturnCallback(static fn (string $id): bool => \in_array($id, ['dummy-receiver1', 'dummy-receiver2'], true));
231+
232+
$receiverLocator->expects($this->exactly(2))
233+
->method('get')
234+
->willReturnCallback(static fn (string $id): ReceiverInterface => 'dummy-receiver1' === $id ? $receiver1 : $receiver2);
232235

233236
$bus = $this->createMock(MessageBusInterface::class);
234237
$bus->expects($this->exactly(2))->method('dispatch');
235238

236239
$busLocator = $this->createMock(ContainerInterface::class);
237-
$busLocator->expects($this->once())->method('has')->with('dummy-bus')->willReturn(true);
238-
$busLocator->expects($this->once())->method('get')->with('dummy-bus')->willReturn($bus);
240+
$busLocator->expects($this->exactly(2))->method('has')->with('dummy-bus')->willReturn(true);
241+
$busLocator->expects($this->exactly(2))->method('get')->with('dummy-bus')->willReturn($bus);
239242

240-
$command = new ConsumeMessagesCommand(new RoutableMessageBus($busLocator), $receiverLocator, new EventDispatcher());
243+
$command = new ConsumeMessagesCommand(
244+
new RoutableMessageBus($busLocator),
245+
$receiverLocator, new EventDispatcher(),
246+
receiverNames: ['dummy-receiver1', 'dummy-receiver2']
247+
);
241248

242249
$application = new Application();
243250
$application->add($command);
244251
$tester = new CommandTester($application->get('messenger:consume'));
245252
$tester->execute([
246-
'--all' => null,
253+
'--all' => true,
254+
'--limit' => 2,
247255
]);
248256

249257
$tester->assertCommandIsSuccessful();
250-
$this->assertStringContainsString('[OK] Consuming messages from transport "dummy-receiver1, dummy-receiver2"', $tester->getDisplay());
258+
$this->assertStringContainsString('[OK] Consuming messages from transports "dummy-receiver1, dummy-receiver2"', $tester->getDisplay());
251259
}
252260

253261
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.