Skip to content

Commit

Permalink
Merge branch '4.4' into 5.4
Browse files Browse the repository at this point in the history
* 4.4:
  Fix composer on appveyor
  [PropertyAccess] Fix typo in PropertyAccessor::readProperty() DocBlock
  [VarExporter] Fix exporting objects with readonly properties
  [ExpressionLanguage] Fix matches when the regexp is not valid
  [Messenger] Add mysql indexes back and work around deadlocks using soft-delete
  [Validator] Fix File constraint invalid max size exception message
  [Console] Fix exit status on uncaught exception with negative code
  • Loading branch information
nicolas-grekas committed Mar 31, 2022
2 parents 0a4f498 + bdcc66f commit 9002752
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Application.php
Expand Up @@ -179,7 +179,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
$exitCode = $e->getCode();
if (is_numeric($exitCode)) {
$exitCode = (int) $exitCode;
if (0 === $exitCode) {
if ($exitCode <= 0) {
$exitCode = 1;
}
} else {
Expand Down
19 changes: 19 additions & 0 deletions Tests/ApplicationTest.php
Expand Up @@ -1172,6 +1172,25 @@ public function testRunDispatchesExitCodeOneForExceptionCodeZero()
$this->assertTrue($passedRightValue, '-> exit code 1 was passed in the console.terminate event');
}

/**
* @testWith [-1]
* [-32000]
*/
public function testRunReturnsExitCodeOneForNegativeExceptionCode($exceptionCode)
{
$exception = new \Exception('', $exceptionCode);

$application = $this->getMockBuilder(Application::class)->setMethods(['doRun'])->getMock();
$application->setAutoExit(false);
$application->expects($this->once())
->method('doRun')
->willThrowException($exception);

$exitCode = $application->run(new ArrayInput([]), new NullOutput());

$this->assertSame(1, $exitCode, '->run() returns exit code 1 when exception code is '.$exceptionCode);
}

public function testAddingOptionWithDuplicateShortcut()
{
$this->expectException(\LogicException::class);
Expand Down

0 comments on commit 9002752

Please sign in to comment.