@@ -54,17 +54,37 @@ public function __construct(Application $application)
54
54
*/
55
55
public function run (array $ input , $ options = [])
56
56
{
57
- $ this ->input = new ArrayInput ($ input );
58
- if (isset ($ options ['interactive ' ])) {
59
- $ this ->input ->setInteractive ($ options ['interactive ' ]);
60
- }
57
+ $ prevShellVerbosity = getenv ('SHELL_VERBOSITY ' );
61
58
62
- if ($ this ->inputs ) {
63
- $ this ->input ->setStream (self ::createStream ($ this ->inputs ));
64
- }
59
+ try {
60
+ $ this ->input = new ArrayInput ($ input );
61
+ if (isset ($ options ['interactive ' ])) {
62
+ $ this ->input ->setInteractive ($ options ['interactive ' ]);
63
+ }
65
64
66
- $ this ->initOutput ($ options );
65
+ if ($ this ->inputs ) {
66
+ $ this ->input ->setStream (self ::createStream ($ this ->inputs ));
67
+ }
67
68
68
- return $ this ->statusCode = $ this ->application ->run ($ this ->input , $ this ->output );
69
+ $ this ->initOutput ($ options );
70
+
71
+ return $ this ->statusCode = $ this ->application ->run ($ this ->input , $ this ->output );
72
+ } finally {
73
+ // SHELL_VERBOSITY is set by Application::configureIO so we need to unset/reset it
74
+ // to it's previous value to avoid one test's verbosity to spread to the following tests
75
+ if (false === $ prevShellVerbosity ) {
76
+ if (\function_exists ('putenv ' )) {
77
+ @putenv ('SHELL_VERBOSITY ' );
78
+ }
79
+ unset($ _ENV ['SHELL_VERBOSITY ' ]);
80
+ unset($ _SERVER ['SHELL_VERBOSITY ' ]);
81
+ } else {
82
+ if (\function_exists ('putenv ' )) {
83
+ @putenv ('SHELL_VERBOSITY= ' .$ prevShellVerbosity );
84
+ }
85
+ $ _ENV ['SHELL_VERBOSITY ' ] = $ prevShellVerbosity ;
86
+ $ _SERVER ['SHELL_VERBOSITY ' ] = $ prevShellVerbosity ;
87
+ }
88
+ }
69
89
}
70
90
}
0 commit comments