Skip to content

Commit 4d671ab

Browse files
committed
Merge branch '4.4' into 5.4
* 4.4: Fix global state pollution between tests run with ApplicationTester µcs fix [Intl] Fix the IntlDateFormatter::formatObject signature
2 parents 56f40c9 + 8a2628d commit 4d671ab

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

Tester/ApplicationTester.php

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,37 @@ public function __construct(Application $application)
4949
*/
5050
public function run(array $input, array $options = [])
5151
{
52-
$this->input = new ArrayInput($input);
53-
if (isset($options['interactive'])) {
54-
$this->input->setInteractive($options['interactive']);
55-
}
52+
$prevShellVerbosity = getenv('SHELL_VERBOSITY');
5653

57-
if ($this->inputs) {
58-
$this->input->setStream(self::createStream($this->inputs));
59-
}
54+
try {
55+
$this->input = new ArrayInput($input);
56+
if (isset($options['interactive'])) {
57+
$this->input->setInteractive($options['interactive']);
58+
}
6059

61-
$this->initOutput($options);
60+
if ($this->inputs) {
61+
$this->input->setStream(self::createStream($this->inputs));
62+
}
6263

63-
return $this->statusCode = $this->application->run($this->input, $this->output);
64+
$this->initOutput($options);
65+
66+
return $this->statusCode = $this->application->run($this->input, $this->output);
67+
} finally {
68+
// SHELL_VERBOSITY is set by Application::configureIO so we need to unset/reset it
69+
// to its previous value to avoid one test's verbosity to spread to the following tests
70+
if (false === $prevShellVerbosity) {
71+
if (\function_exists('putenv')) {
72+
@putenv('SHELL_VERBOSITY');
73+
}
74+
unset($_ENV['SHELL_VERBOSITY']);
75+
unset($_SERVER['SHELL_VERBOSITY']);
76+
} else {
77+
if (\function_exists('putenv')) {
78+
@putenv('SHELL_VERBOSITY='.$prevShellVerbosity);
79+
}
80+
$_ENV['SHELL_VERBOSITY'] = $prevShellVerbosity;
81+
$_SERVER['SHELL_VERBOSITY'] = $prevShellVerbosity;
82+
}
83+
}
6484
}
6585
}

0 commit comments

Comments
 (0)