@@ -157,12 +157,24 @@ public function doesntExpectOutput($output)
157157 */ 
158158 public  function  expectsTable ($ headers , $ rows , $ tableStyle  = 'default ' , array  $ columnStyles  = [])
159159 {
160-  $ this  ->test ->expectedTables [] = [
161-  'headers '  => (array ) $ headers ,
162-  'rows '  => $ rows  instanceof  Arrayable ? $ rows ->toArray () : $ rows ,
163-  'tableStyle '  => $ tableStyle ,
164-  'columnStyles '  => $ columnStyles ,
165-  ];
160+  $ table  = (new  Table ($ output  = new  BufferedOutput ))
161+  ->setHeaders ((array ) $ headers )
162+  ->setRows ($ rows  instanceof  Arrayable ? $ rows ->toArray () : $ rows )
163+  ->setStyle ($ tableStyle );
164+ 
165+  foreach  ($ columnStyles  as  $ columnIndex  => $ columnStyle ) {
166+  $ table ->setColumnStyle ($ columnIndex , $ columnStyle );
167+  }
168+ 
169+  $ table ->render ();
170+ 
171+  $ lines  = array_filter (
172+  explode (PHP_EOL , $ output ->fetch ())
173+  );
174+ 
175+  foreach  ($ lines  as  $ line ) {
176+  $ this  ->expectsOutput ($ line );
177+  }
166178
167179 return  $ this  ;
168180 }
@@ -305,8 +317,6 @@ private function createABufferedOutputMock()
305317 ->shouldAllowMockingProtectedMethods ()
306318 ->shouldIgnoreMissing ();
307319
308-  $ this  ->applyTableOutputExpectations ($ mock );
309- 
310320 foreach  ($ this  ->test ->expectedOutput  as  $ i  => $ output ) {
311321 $ mock ->shouldReceive ('doWrite ' )
312322 ->once ()
@@ -330,38 +340,6 @@ private function createABufferedOutputMock()
330340 return  $ mock ;
331341 }
332342
333-  /** 
334-  * Apply the output table expectations to the mock. 
335-  * 
336-  * @param \Mockery\MockInterface $mock 
337-  * @return void 
338-  */ 
339-  private  function  applyTableOutputExpectations ($ mock )
340-  {
341-  foreach  ($ this  ->test ->expectedTables  as  $ i  => $ consoleTable ) {
342-  $ table  = (new  Table ($ output  = new  BufferedOutput ))
343-  ->setHeaders ($ consoleTable ['headers ' ])
344-  ->setRows ($ consoleTable ['rows ' ])
345-  ->setStyle ($ consoleTable ['tableStyle ' ]);
346- 
347-  foreach  ($ consoleTable ['columnStyles ' ] as  $ columnIndex  => $ columnStyle ) {
348-  $ table ->setColumnStyle ($ columnIndex , $ columnStyle );
349-  }
350- 
351-  $ table ->render ();
352- 
353-  $ lines  = array_filter (
354-  explode (PHP_EOL , $ output ->fetch ())
355-  );
356- 
357-  foreach  ($ lines  as  $ line ) {
358-  $ this  ->expectsOutput ($ line );
359-  }
360- 
361-  unset($ this  ->test ->expectedTables [$ i ]);
362-  }
363-  }
364- 
365343 /** 
366344 * Flush the expectations from the test case. 
367345 * 
0 commit comments