From 97e15fe1b514e4aca130f68f48b75b31a22395aa Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sun, 9 Dec 2018 20:16:27 +0100 Subject: [PATCH] [FrameworkBundle] Stop calling Kernel::boot() twice in cli --- src/Symfony/Bundle/FrameworkBundle/Console/Application.php | 6 ++---- .../FrameworkBundle/Tests/Console/ApplicationTest.php | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php index 04258131b539..51cc1940b3a6 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 6ac413a226fd..fe171ed6238c 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')