I have a command listener that outputs some text to command line.
class CommandListener
{
//...
public function onConsoleCommand(ConsoleCommandEvent $event)
{
//...
$event->getOutput()->writeln(
sprintf(
'<info>%s@%s:</info> ',
$user->getUsername(),
$connection
)
);
}
}
While this command provides expected output when I run command in console, in test it does not.
class CommandListenerTest extends WebTestCase
{
/** @test **/
public function listener_adds_parameter_and_description_to_allowed_commands(): void
{
$kernel = static::createKernel();
$application = new Application($kernel);
$application->setAutoExit(false);
$command = $application->find('doctrine:database:drop');
$commandTester = new CommandTester($command);
$commandTester->execute([
'command' => $command->getName(),
'--help' => true
]);
$this->assertContains('default', $commandTester->getDisplay()));
}
}
In test it provides output without the output from command listener. Command listener is being called.
Aucun commentaire:
Enregistrer un commentaire