|
18 | 18 | use Symfony\Component\Console\Command\HelpCommand;
|
19 | 19 | use Symfony\Component\Console\Command\LazyCommand;
|
20 | 20 | use Symfony\Component\Console\Command\SignalableCommandInterface;
|
| 21 | +use Symfony\Component\Console\CommandLoader\CommandLoaderInterface; |
21 | 22 | use Symfony\Component\Console\CommandLoader\FactoryCommandLoader;
|
22 | 23 | use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
|
23 | 24 | use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
@@ -509,12 +510,12 @@ public function testDontRunAlternativeNamespaceName()
|
509 | 510 | $tester = new ApplicationTester($application);
|
510 | 511 | $tester->run(['command' => 'foos:bar1'], ['decorated' => false]);
|
511 | 512 | $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 | +
|
518 | 519 |
|
519 | 520 | ', $tester->getDisplay(true));
|
520 | 521 | }
|
@@ -1466,6 +1467,25 @@ public function testRunWithError()
|
1466 | 1467 | }
|
1467 | 1468 | }
|
1468 | 1469 |
|
| 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 | + |
1469 | 1489 | public function testRunAllowsErrorListenersToSilenceTheException()
|
1470 | 1490 | {
|
1471 | 1491 | $dispatcher = $this->getDispatcher();
|
|
0 commit comments