Closed
Description
In symfony 3.0.2 and before you could test a console command with mocks like:
$application = new Application($kernel);
$application->add(new MyConsoleCommand($myMockedRepository));
// we check it's properly registered :)
$command = $application->find('namespace:my-command');
$commandTester = new CommandTester($command);
// execute command
But since 3.0.3 the mocked object is not set in the console command when it is executed.
A way to work around it is:
$myCommand = new MyConsoleCommand($myMockedRepository);
$application = new Application($kernel);
$application->add($myCommand);
$commandTester = new CommandTester($command);
// execute command
But then I cannot use the $application->find()
method.
Was this a desired change? I cannot seem to find it in the change log.