merged branch Stelian/2.2 (PR #8183)
This PR was submitted for the 2.2 branch but it was merged into the 2.1 branch instead (closes #8183). Discussion ---------- Fixed exit code for exceptions with error code 0 Covers https://github.com/symfony/symfony/issues/8180 Commits ------- 48e77f8 Fixed exit code for exceptions with error code 0
This commit is contained in:
commit
28a900150e
@ -115,7 +115,7 @@ class Application
|
||||
}
|
||||
$statusCode = $e->getCode();
|
||||
|
||||
$statusCode = $statusCode ? (is_numeric($statusCode) ? (int) $statusCode : 1) : 0;
|
||||
$statusCode = is_numeric($statusCode) && $statusCode ? (int) $statusCode : 1;
|
||||
}
|
||||
|
||||
if ($this->autoExit) {
|
||||
|
@ -516,6 +516,21 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame(4, $exitCode, '->run() returns integer exit code extracted from raised exception');
|
||||
}
|
||||
|
||||
public function testRunReturnsExitCodeOneForExceptionCodeZero()
|
||||
{
|
||||
$exception = new \Exception('', 0);
|
||||
|
||||
$application = $this->getMock('Symfony\Component\Console\Application', array('doRun'));
|
||||
$application->setAutoExit(false);
|
||||
$application->expects($this->once())
|
||||
->method('doRun')
|
||||
->will($this->throwException($exception));
|
||||
|
||||
$exitCode = $application->run(new ArrayInput(array()), new NullOutput());
|
||||
|
||||
$this->assertSame(1, $exitCode, '->run() returns exit code 1 when exception code is 0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @dataProvider getAddingAlreadySetDefinitionElementData
|
||||
|
Reference in New Issue
Block a user