Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CommandTester ignores options --help and others from Application::getDefaultInputDefinition #59765

Open
@kubawerlos

Description

@kubawerlos

Symfony version(s) affected

Latest 6 and 7, probably more

Description

Using CommandTester with --help options is not working.

How to reproduce

This test is passing (see here):

// src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php
    public function testHelpDisplays()
    {
        $command = new Command('foo');
        $command->setCode(function (OutputInterface $output) { $output->writeln('Hello foo!'); });

        $application = new Application();
        $application->setAutoExit(false);
        $application->add($command);

        $tester = new CommandTester($application->find('foo'));
        $tester->execute(['--help' => true]);

        $this->assertStringContainsString('Hello foo!', $tester->getDisplay());
        $this->assertEquals('Hello foo!'.\PHP_EOL, $tester->getDisplay());
    }

If --help is replaced with --silent or --quiet the test is still passing.

Possible Solution

No response

Additional Context

No response

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