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 global state pollution between tests run with ApplicationTester
  µcs fix
  [Intl] Fix the IntlDateFormatter::formatObject signature
  • Loading branch information
fabpot committed Jun 26, 2022
2 parents 56f40c9 + 8a2628d commit 4d671ab
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions Tester/ApplicationTester.php
Expand Up @@ -49,17 +49,37 @@ public function __construct(Application $application)
*/
public function run(array $input, array $options = [])
{
$this->input = new ArrayInput($input);
if (isset($options['interactive'])) {
$this->input->setInteractive($options['interactive']);
}
$prevShellVerbosity = getenv('SHELL_VERBOSITY');

if ($this->inputs) {
$this->input->setStream(self::createStream($this->inputs));
}
try {
$this->input = new ArrayInput($input);
if (isset($options['interactive'])) {
$this->input->setInteractive($options['interactive']);
}

$this->initOutput($options);
if ($this->inputs) {
$this->input->setStream(self::createStream($this->inputs));
}

return $this->statusCode = $this->application->run($this->input, $this->output);
$this->initOutput($options);

return $this->statusCode = $this->application->run($this->input, $this->output);
} finally {
// SHELL_VERBOSITY is set by Application::configureIO so we need to unset/reset it
// to its previous value to avoid one test's verbosity to spread to the following tests
if (false === $prevShellVerbosity) {
if (\function_exists('putenv')) {
@putenv('SHELL_VERBOSITY');
}
unset($_ENV['SHELL_VERBOSITY']);
unset($_SERVER['SHELL_VERBOSITY']);
} else {
if (\function_exists('putenv')) {
@putenv('SHELL_VERBOSITY='.$prevShellVerbosity);
}
$_ENV['SHELL_VERBOSITY'] = $prevShellVerbosity;
$_SERVER['SHELL_VERBOSITY'] = $prevShellVerbosity;
}
}
}
}

0 comments on commit 4d671ab

Please sign in to comment.