[FrameworkBundle] [Console] add a warning when command is not found
This commit is contained in:
parent
4271fecbea
commit
efd8f7fa3a
@ -65,6 +65,8 @@ class Application extends BaseApplication
|
||||
|
||||
$this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher'));
|
||||
|
||||
$this->registerCommands();
|
||||
|
||||
if ($this->registrationErrors) {
|
||||
$this->renderRegistrationErrors($input, $output);
|
||||
}
|
||||
|
@ -165,6 +165,33 @@ class ApplicationTest extends TestCase
|
||||
$this->assertContains('fine', $output);
|
||||
}
|
||||
|
||||
public function testRegistrationErrorsAreDisplayedOnCommandNotFound()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('event_dispatcher', EventDispatcher::class);
|
||||
|
||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
||||
$kernel
|
||||
->method('getBundles')
|
||||
->willReturn(array($this->createBundleMock(
|
||||
array((new Command(null))->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('fine'); }))
|
||||
)));
|
||||
$kernel
|
||||
->method('getContainer')
|
||||
->willReturn($container);
|
||||
|
||||
$application = new Application($kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'fine'));
|
||||
$output = $tester->getDisplay();
|
||||
|
||||
$this->assertSame(1, $tester->getStatusCode());
|
||||
$this->assertContains('Some commands could not be registered:', $output);
|
||||
$this->assertContains('Command "fine" is not defined.', $output);
|
||||
}
|
||||
|
||||
private function getKernel(array $bundles, $useDispatcher = false)
|
||||
{
|
||||
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||
|
Reference in New Issue
Block a user