Skip to content

Commit a42df13

Browse files
committed
Fix missing command not matching namespace error message
1 parent 58f6cef commit a42df13

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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
}

Tests/ApplicationTest.php

Lines changed: 20 additions & 0 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;
@@ -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)