@@ -37,6 +37,18 @@ public function testConstructWithNonBufferedOutput()
3737 $ this ->assertInstanceOf (Table::class, $ table );
3838 }
3939
40+ public function testShowOutput ()
41+ {
42+ $ output = Mockery::mock (ConsoleOutputInterface::class);
43+ $ table = new Table ($ output );
44+
45+ $ this ->assertTrue ($ table ->isShowOutput ());
46+
47+ $ table ->setShowOutput (false );
48+
49+ $ this ->assertFalse ($ table ->isShowOutput ());
50+ }
51+
4052 public function testSpinnerLoop ()
4153 {
4254 $ this ->output ->setVerbosity (OutputInterface::VERBOSITY_VERBOSE );
@@ -91,33 +103,37 @@ public function testSpinnerLoop()
91103 * @dataProvider outputData
92104 *
93105 * @param int $verbosity OutputInterface::VERBOSITY_*
106+ * @param bool $showOutput Should it display some output text
94107 * @param bool[] $processStates an entry for each process to run, true = success, false = failure
95108 * @param string[][] $outputs Regex patterns for the output string
96109 *
97110 * @throws \Exception
98- * @throws mixed
99111 */
100- public function testOutput ($ verbosity , array $ processStates , array $ outputs )
112+ public function testOutput ($ verbosity , $ showOutput , array $ processStates , array $ outputs )
101113 {
102114 $ this ->output ->setVerbosity ($ verbosity );
115+ $ this ->table ->setShowOutput ($ showOutput );
103116
104117 $ oneFails = false ;
105118
106119 for ($ i = 0 ; $ i < count ($ processStates ); $ i ++) {
107120 $ process = Mockery::mock (Process::class);
108121 $ process ->shouldReceive ('stop ' );
109- $ process ->shouldReceive ('start ' )->once ();
122+ $ process ->shouldReceive ('start ' )->with (Mockery::on (function ($ closure ) {
123+ call_user_func ($ closure , Process::OUT , 'some text ' );
124+ return true ;
125+ }))->once ();
110126 $ process ->shouldReceive ('isStarted ' )->andReturn (false , true );
111127 $ process ->shouldReceive ('isRunning ' )->andReturn (false , true , false ); // add, start, check, check
112128 $ process ->shouldReceive ('isSuccessful ' )->atLeast ()->once ()->andReturn ($ processStates [$ i ]);
129+ $ process ->shouldReceive ('getOutput ' )->andReturn ('some text ' );
113130
114131 if (!$ processStates [$ i ]) {
115132 $ process ->shouldReceive ('getCommandLine ' )->andReturn ('test ' );
116133 $ process ->shouldReceive ('getExitCode ' )->andReturn (1 );
117134 $ process ->shouldReceive ('getExitCodeText ' )->andReturn ('failed ' );
118135 $ process ->shouldReceive ('getWorkingDirectory ' )->andReturn ('/tmp ' );
119136 $ process ->shouldReceive ('isOutputDisabled ' )->andReturn (false );
120- $ process ->shouldReceive ('getOutput ' )->andReturn ('some text ' );
121137 $ process ->shouldReceive ('getErrorOutput ' )->andReturn ('some error text ' );
122138 $ oneFails = true ;
123139 }
@@ -165,6 +181,7 @@ public function outputData()
165181 return [
166182 [ // verbose with single valid run
167183 OutputInterface::VERBOSITY_VERBOSE ,
184+ false ,
168185 [true ],
169186 [
170187 ['%<info>key</info>: value <info>run</info>: 0 \(<comment> 0.00s</comment>\) % ' ],
@@ -174,13 +191,15 @@ public function outputData()
174191 ],
175192 [ // normal verbosity only writes a single line
176193 OutputInterface::VERBOSITY_NORMAL ,
194+ false ,
177195 [true ],
178196 [
179197 ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>% ' ],
180198 ],
181199 ],
182200 [
183201 OutputInterface::VERBOSITY_NORMAL ,
202+ false ,
184203 [true , true ],
185204 [
186205 ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>% ' ],
@@ -189,6 +208,7 @@ public function outputData()
189208 ],
190209 [ // multiple runs with verbosity will update each item one at a time
191210 OutputInterface::VERBOSITY_VERBOSE ,
211+ false ,
192212 [true , true ],
193213 [
194214 [
@@ -215,6 +235,7 @@ public function outputData()
215235 ],
216236 [ // errors will display an error
217237 OutputInterface::VERBOSITY_VERBOSE ,
238+ false ,
218239 [false ],
219240 [
220241 ['%<info>key</info>: value <info>run</info>: 0 \(<comment> 0.00s</comment>\) % ' ],
@@ -236,11 +257,13 @@ public function outputData()
236257================
237258some error text%
238259DOC
239- ]
260+ ,
261+ ],
240262 ],
241263 ],
242264 [ // errors will display an error
243265 OutputInterface::VERBOSITY_NORMAL ,
266+ false ,
244267 [false ],
245268 [
246269 ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <error>x</error>% ' ],
@@ -260,11 +283,13 @@ public function outputData()
260283================
261284some error text%
262285DOC
263- ]
286+ ,
287+ ],
264288 ],
265289 ],
266290 [ // multiple runs with verbosity will update each item one at a time
267291 OutputInterface::VERBOSITY_VERBOSE ,
292+ false ,
268293 [true , false ],
269294 [
270295 [
@@ -303,7 +328,18 @@ public function outputData()
303328================
304329some error text%
305330DOC
306- ]
331+ ,
332+ ],
333+ ],
334+ ],
335+ [ // include output
336+ OutputInterface::VERBOSITY_VERBOSE ,
337+ true ,
338+ [true ],
339+ [
340+ ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment> 0.00s</comment>\) % ' ],
341+ ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏] some text% ' ],
342+ ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info> some text% ' ],
307343 ],
308344 ],
309345 ];
0 commit comments