merged branch lyrixx/console-tester-status-code (PR #8023)
This PR was merged into the master branch.
Discussion
----------
[2.4][Console] Added status code to CommandTester and ApplicationTester
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes, but not on travis (segfault)
| Fixed tickets | -
| License | MIT
| Doc PR | -
Theses classes are already statefull. They contain the input and the
output data. So we can safely add the last status code to the class.
Commits
-------
6526166
[Console] Added status code to CommandTester and ApplicationTester
This commit is contained in:
commit
a8929762bc
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user