$command =
new ConsumeMessagesCommand($bus,
$receiverLocator,
new EventDispatcher(), null,
[],
new ResetServicesListener($servicesResetter));
$application =
new Application();
$application->
add($command);
$tester =
new CommandTester($application->
get('messenger:consume'
));
$tester->
execute(array_merge([ 'receivers' =>
['dummy-receiver'
],
'--sleep' => '0.001', // do not sleep too long
'--limit' =>
$msgCount,
],
$shouldReset ?
[] :
['--no-reset' => null
]));
$this->
assertEquals($shouldReset,
$receiver->
hasBeenReset(), '$receiver->reset() should have been called'
);
$tester->
assertCommandIsSuccessful();
$this->
assertStringContainsString('[OK] Consuming messages from transport "dummy-receiver"',
$tester->
getDisplay());
} /**
* @dataProvider getInvalidOptions
*/
public function testRunWithInvalidOption(string
$option, string
$value, string
$expectedMessage) { $receiverLocator =
$this->
createMock(ContainerInterface::
class);
$receiverLocator->
expects($this->
once())->
method('has'
)->
with('dummy-receiver'
)->
willReturn(true
);