Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public function doRun(InputInterface $input, OutputInterface $output)

$this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher'));

$this->registerCommands();

if ($this->registrationErrors) {
$this->renderRegistrationErrors($input, $output);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,33 @@ public function testRunOnlyWarnsOnUnregistrableCommand()
$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();
Expand Down