Having issue with Symfony 3 Unit testing that has session enabled

Solution 1:

Try removing

$output = $commandTester->getOutput();
$this->assertContains('valid',$output);

and add:

        $expected = 'valid
valid
valid
document_number_length_invalid
request_limit_exceeded
valid
document_is_expired
valid
document_type_is_invalid
valid
valid
document_number_invalid
valid
document_issue_date_invalid
';
        $testresult = $commandTester->getDisplay();

        $this->assertEquals($expected, $testresult);

see: http://www.inanzzz.com/index.php/post/c7jb/testing-symfony-console-command-with-phpunit