diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php index 04258131b539a..51cc1940b3a6a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php @@ -62,16 +62,14 @@ public function getKernel() */ public function doRun(InputInterface $input, OutputInterface $output) { - $this->kernel->boot(); - - $this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher')); - $this->registerCommands(); if ($this->registrationErrors) { $this->renderRegistrationErrors($input, $output); } + $this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher')); + return parent::doRun($input, $output); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php index 6ac413a226fd3..fe171ed6238c0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php @@ -204,6 +204,7 @@ public function testRunOnlyWarnsOnUnregistrableCommandAtTheEnd() $container->setParameter('console.command.ids', array(ThrowingCommand::class => ThrowingCommand::class)); $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); + $kernel->expects($this->once())->method('boot'); $kernel ->method('getBundles') ->willReturn(array($this->createBundleMock( @@ -256,6 +257,7 @@ private function getKernel(array $bundles, $useDispatcher = false) ; $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel->expects($this->once())->method('boot'); $kernel ->expects($this->any()) ->method('getBundles')