diff --git a/src/Symfony/Component/Console/Tester/ApplicationTester.php b/src/Symfony/Component/Console/Tester/ApplicationTester.php index 2e57e1a35d..dd7c2a5dc0 100644 --- a/src/Symfony/Component/Console/Tester/ApplicationTester.php +++ b/src/Symfony/Component/Console/Tester/ApplicationTester.php @@ -32,6 +32,7 @@ class ApplicationTester private $application; private $input; private $output; + private $statusCode; /** * Constructor. @@ -72,7 +73,7 @@ class ApplicationTester $this->output->setVerbosity($options['verbosity']); } - return $this->application->run($this->input, $this->output); + return $this->statusCode = $this->application->run($this->input, $this->output); } /** @@ -114,4 +115,14 @@ class ApplicationTester { return $this->output; } + + /** + * Gets the status code returned by the last execution of the application. + * + * @return integer The status code + */ + public function getStatusCode() + { + return $this->statusCode; + } } diff --git a/src/Symfony/Component/Console/Tester/CommandTester.php b/src/Symfony/Component/Console/Tester/CommandTester.php index 23dae245d3..3d91aaff65 100644 --- a/src/Symfony/Component/Console/Tester/CommandTester.php +++ b/src/Symfony/Component/Console/Tester/CommandTester.php @@ -25,6 +25,7 @@ class CommandTester private $command; private $input; private $output; + private $statusCode; /** * Constructor. @@ -65,7 +66,7 @@ class CommandTester $this->output->setVerbosity($options['verbosity']); } - return $this->command->run($this->input, $this->output); + return $this->statusCode = $this->command->run($this->input, $this->output); } /** @@ -107,4 +108,14 @@ class CommandTester { return $this->output; } + + /** + * Gets the status code returned by the last execution of the application. + * + * @return integer The status code + */ + public function getStatusCode() + { + return $this->statusCode; + } } diff --git a/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php index 6ce30ab0fc..a8389dd186 100644 --- a/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php @@ -61,4 +61,9 @@ class ApplicationTesterTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('foo'.PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); } + + public function testGetStatusCode() + { + $this->assertSame(0, $this->tester->getStatusCode(), '->getStatusCode() returns the status code'); + } } diff --git a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php index da5bf84e22..1067e9ffc6 100644 --- a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php @@ -59,4 +59,9 @@ class CommandTesterTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('foo'.PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); } + + public function testGetStatusCode() + { + $this->assertSame(0, $this->tester->getStatusCode(), '->getStatusCode() returns the status code'); + } }