diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b4255a..883c0cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# `dev-master` + +## Bugfix + +* [#98](https://github.com/atoum/AtoumBundle/pull/98) Fix atoum command exit codes ([@jubianchi]) + 1.4.0 ===== @@ -37,3 +43,5 @@ * Move the bundle to atoum vendor namespace * Add ControllerTest class + +[@jubianchi]: https://github.com/jubianchi diff --git a/Command/AtoumCommand.php b/Command/AtoumCommand.php index fba18ca..1cd174d 100644 --- a/Command/AtoumCommand.php +++ b/Command/AtoumCommand.php @@ -121,7 +121,27 @@ protected function execute(InputInterface $input, OutputInterface $output) $reportCli->addWriter($writerCli); } - $runner->run($this->getAtoumArguments()); + try { + $score = $runner->run($this->getAtoumArguments())->getRunner()->getScore(); + + $isSuccess = $score->getFailNumber() <= 0 && $score->getErrorNumber() <= 0 && $score->getExceptionNumber() <= 0; + + if ($runner->shouldFailIfVoidMethods() && $score->getVoidMethodNumber() > 0) + { + $isSuccess = false; + } + + if ($runner->shouldFailIfSkippedMethods() && $score->getSkippedMethodNumber() > 0) + { + $isSuccess = false; + } + + return $isSuccess ? 0 : 1; + } catch (\Exception $exception) { + $this->getApplication()->renderException($exception, $output); + + return 2; + } } /** diff --git a/tests/units/Test/Units/CommandTestCase.php b/tests/units/Test/Units/CommandTestCase.php index c8253f3..ebce366 100644 --- a/tests/units/Test/Units/CommandTestCase.php +++ b/tests/units/Test/Units/CommandTestCase.php @@ -18,14 +18,13 @@ public function testCreateCommandTester() $this ->given( $command = new \mock\Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand($commandName = uniqid()), - $command->getMockController()->run = $status = uniqid() - ) - ->given( $kernel = new \mock\Symfony\Component\HttpKernel\KernelInterface(), - $application = new \mock\Symfony\Bundle\FrameworkBundle\Console\Application($kernel) - ) - ->given( + $container = new \mock\Symfony\Component\DependencyInjection\ContainerInterface(), + $application = new \mock\Symfony\Bundle\FrameworkBundle\Console\Application($kernel), $object = new \mock\atoum\AtoumBundle\Test\Units\CommandTestCase(), + $command->getMockController()->run = $status = uniqid(), + $kernel->getMockController()->getBundles = array(), + $kernel->getMockController()->getContainer = $container, $object->getMockController()->getKernel = $kernel ) ->if($commandTester = $object->createCommandTester($command))