Skip to content

symfony/console CommandTester does not use ConsoleOutputInterface #27422

@cdekok

Description

@cdekok

Symfony version(s) affected: 3 / 4

Description
CommandTester https://github.com/symfony/console/blob/master/Tester/CommandTester.php#L71
Creates an instance of StreamOutput this makes it difficult to test ->getErrorOutput as that is only implemented in ConsoleOutputInterface

In the ApplicationTester there is a option to enable it https://github.com/symfony/console/blob/master/Tester/ApplicationTester.php#L51
It would be nice if the same option was available in CommandTester.

How to reproduce

$cmd = new CommandTester($cmd);
if (!$cmd->getOutput() instanceof \Symfony\Component\Console\Output\ConsoleOutputInterface) {
 throw new \Exception('Nope');
}

Possible Solution
Make it configurable the same as in ApplicationTester

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions