Fix errors not rethrown even if not handled by console.error listeners
This commit is contained in:
parent
2f1c28bbbc
commit
75f098fcb8
@ -129,7 +129,7 @@ class Application
|
||||
}
|
||||
|
||||
if (null !== $e) {
|
||||
if (!$this->catchExceptions) {
|
||||
if (!$this->catchExceptions || !$x instanceof \Exception) {
|
||||
throw $x;
|
||||
}
|
||||
|
||||
|
@ -1170,6 +1170,29 @@ class ApplicationTest extends TestCase
|
||||
|
||||
return $dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testErrorIsRethrownIfNotHandledByConsoleErrorEventWithCatchingEnabled()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->setDispatcher(new EventDispatcher());
|
||||
|
||||
$application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) {
|
||||
new \UnknownClass();
|
||||
});
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
|
||||
try {
|
||||
$tester->run(array('command' => 'dym'));
|
||||
$this->fail('->run() should rethrow PHP errors if not handled via ConsoleErrorEvent.');
|
||||
} catch (\Error $e) {
|
||||
$this->assertSame($e->getMessage(), 'Class \'UnknownClass\' not found');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CustomApplication extends Application
|
||||
|
Reference in New Issue
Block a user