composer update
This commit is contained in:
@@ -13,8 +13,6 @@ namespace Symfony\Component\Console\Tester;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
/**
|
||||
* Eases the testing of console applications.
|
||||
@@ -33,7 +31,6 @@ class ApplicationTester
|
||||
private $application;
|
||||
private $input;
|
||||
private $statusCode;
|
||||
private $captureStreamsIndependently = false;
|
||||
|
||||
public function __construct(Application $application)
|
||||
{
|
||||
@@ -69,36 +66,7 @@ class ApplicationTester
|
||||
putenv('SHELL_INTERACTIVE=1');
|
||||
}
|
||||
|
||||
$this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
|
||||
if (!$this->captureStreamsIndependently) {
|
||||
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
if (isset($options['decorated'])) {
|
||||
$this->output->setDecorated($options['decorated']);
|
||||
}
|
||||
if (isset($options['verbosity'])) {
|
||||
$this->output->setVerbosity($options['verbosity']);
|
||||
}
|
||||
} else {
|
||||
$this->output = new ConsoleOutput(
|
||||
isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL,
|
||||
isset($options['decorated']) ? $options['decorated'] : null
|
||||
);
|
||||
|
||||
$errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
$errorOutput->setFormatter($this->output->getFormatter());
|
||||
$errorOutput->setVerbosity($this->output->getVerbosity());
|
||||
$errorOutput->setDecorated($this->output->isDecorated());
|
||||
|
||||
$reflectedOutput = new \ReflectionObject($this->output);
|
||||
$strErrProperty = $reflectedOutput->getProperty('stderr');
|
||||
$strErrProperty->setAccessible(true);
|
||||
$strErrProperty->setValue($this->output, $errorOutput);
|
||||
|
||||
$reflectedParent = $reflectedOutput->getParentClass();
|
||||
$streamProperty = $reflectedParent->getProperty('stream');
|
||||
$streamProperty->setAccessible(true);
|
||||
$streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
|
||||
}
|
||||
$this->initOutput($options);
|
||||
|
||||
$this->statusCode = $this->application->run($this->input, $this->output);
|
||||
|
||||
@@ -106,28 +74,4 @@ class ApplicationTester
|
||||
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output written to STDERR by the application.
|
||||
*
|
||||
* @param bool $normalize Whether to normalize end of lines to \n or not
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorOutput($normalize = false)
|
||||
{
|
||||
if (!$this->captureStreamsIndependently) {
|
||||
throw new \LogicException('The error output is not available when the tester is run without "capture_stderr_separately" option set.');
|
||||
}
|
||||
|
||||
rewind($this->output->getErrorOutput()->getStream());
|
||||
|
||||
$display = stream_get_contents($this->output->getErrorOutput()->getStream());
|
||||
|
||||
if ($normalize) {
|
||||
$display = str_replace(PHP_EOL, "\n", $display);
|
||||
}
|
||||
|
||||
return $display;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user