Skip to content

CommandTester getDisplay has not output from monolog #483

@gianiaz

Description

@gianiaz

Preconditions

Updated from 2.0.0-alpha8 to 2.0.0-alpha12 (it was present in 2.0.0-alpha10).

Steps to reproduce

In a symfony 3.4 application I'm testing a command that receives a LoggerInterface with DI (it is a monolog logger handler with type console - https://symfony.com/doc/current/logging/monolog_console.html).
Via Monolog Bridge logs are sent to OutputInterface.

Handler is configured in this way:

qworker:
      type: console
      level: info
      channels: ['qworker']
      formatter: monolog.formatter.line
      verbosity_levels:
        VERBOSITY_NORMAL: info

In previous version I was testing in this way:

Expected result

        $output = $this->runCommand(
            WorkerManagerConsumerCommand::NAME,
            [
                'data' => $this->encodePayload($data),
            ]
        );

        $this->assertContains('ERROR', $output);

Actual result

In latest version (2.0.0-alpha-12) I have changed my code to this:

        $commandTester = $this->runCommand(
            WorkerManagerConsumerCommand::NAME,
            [
                'data' => $this->encodePayload($data),
            ]
        );

        $output = $commandTester->getDisplay();

        $this->assertContains('ERROR', $output);

But the $output var now contains an empty string instead of the logged value.

In my integration test the output is always the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions