Skip to content

Commit e775d0d

Browse files
committed
Fix missing command not matching namespace error message
1 parent beaef9e commit e775d0d

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ public function doRun(InputInterface $input, OutputInterface $output)
298298

299299
return isset($event) ? $event->getExitCode() : 1;
300300
}
301+
302+
throw $e;
301303
} catch (NamespaceNotFoundException) {
302304
throw $e;
303305
}

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Console\Command\HelpCommand;
1919
use Symfony\Component\Console\Command\LazyCommand;
2020
use Symfony\Component\Console\Command\SignalableCommandInterface;
21+
use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
2122
use Symfony\Component\Console\CommandLoader\FactoryCommandLoader;
2223
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
2324
use Symfony\Component\Console\Event\ConsoleCommandEvent;
@@ -509,12 +510,12 @@ public function testDontRunAlternativeNamespaceName()
509510
$tester = new ApplicationTester($application);
510511
$tester->run(['command' => 'foos:bar1'], ['decorated' => false]);
511512
$this->assertSame('
512-
513-
There are no commands defined in the "foos" namespace.
514-
515-
Did you mean this?
516-
foo
517-
513+
514+
There are no commands defined in the "foos" namespace.
515+
516+
Did you mean this?
517+
foo
518+
518519
519520
', $tester->getDisplay(true));
520521
}
@@ -1466,6 +1467,25 @@ public function testRunWithError()
14661467
}
14671468
}
14681469

1470+
public function testRunWithFindError()
1471+
{
1472+
$this->expectException(\Error::class);
1473+
$this->expectExceptionMessage('Find exception');
1474+
1475+
$application = new Application();
1476+
$application->setAutoExit(false);
1477+
$application->setCatchExceptions(false);
1478+
1479+
// Throws an exception when find fails
1480+
$commandLoader = $this->createMock(CommandLoaderInterface::class);
1481+
$commandLoader->method('getNames')->willThrowException(new \Error('Find exception'));
1482+
$application->setCommandLoader($commandLoader);
1483+
1484+
// The exception should not be ignored
1485+
$tester = new ApplicationTester($application);
1486+
$tester->run(['command' => 'foo']);
1487+
}
1488+
14691489
public function testRunAllowsErrorListenersToSilenceTheException()
14701490
{
14711491
$dispatcher = $this->getDispatcher();

0 commit comments

Comments
 (0)