Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[FrameworkBundle] [Console][DX] add a warning when command is not found #26290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
[FrameworkBundle] [Console] add a warning when command is not found
  • Loading branch information
Amrouche Hamza committed Feb 25, 2018
commit efd8f7fa3aa5492b7c3a326c5387f3bbf1daf190
2 changes: 2 additions & 0 deletions 2 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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.