[Console] fixed PHP7 Errors when not using Dispatcher
This commit is contained in:
parent
5f4d8e9441
commit
899fa7936b
|
@ -843,7 +843,13 @@ class Application
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $this->dispatcher) {
|
if (null === $this->dispatcher) {
|
||||||
return $command->run($input, $output);
|
try {
|
||||||
|
return $command->run($input, $output);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
throw new FatalThrowableError($e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = new ConsoleCommandEvent($command, $input, $output);
|
$event = new ConsoleCommandEvent($command, $input, $output);
|
||||||
|
|
|
@ -951,6 +951,24 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertContains('before.foo.caught.after.', $tester->getDisplay());
|
$this->assertContains('before.foo.caught.after.', $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRunWithError()
|
||||||
|
{
|
||||||
|
$this->setExpectedException('Exception', 'dymerr');
|
||||||
|
|
||||||
|
$application = new Application();
|
||||||
|
$application->setAutoExit(false);
|
||||||
|
$application->setCatchExceptions(false);
|
||||||
|
|
||||||
|
$application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) {
|
||||||
|
$output->write('dym.');
|
||||||
|
|
||||||
|
throw new \Error('dymerr');
|
||||||
|
});
|
||||||
|
|
||||||
|
$tester = new ApplicationTester($application);
|
||||||
|
$tester->run(array('command' => 'dym'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \LogicException
|
* @expectedException \LogicException
|
||||||
* @expectedExceptionMessage caught
|
* @expectedExceptionMessage caught
|
||||||
|
|
Reference in New Issue