diff --git a/src/Illuminate/Testing/PendingCommand.php b/src/Illuminate/Testing/PendingCommand.php index 55ea307c82f3..3e08c53ccee7 100644 --- a/src/Illuminate/Testing/PendingCommand.php +++ b/src/Illuminate/Testing/PendingCommand.php @@ -157,12 +157,24 @@ public function doesntExpectOutput($output) */ public function expectsTable($headers, $rows, $tableStyle = 'default', array $columnStyles = []) { - $this->test->expectedTables[] = [ - 'headers' => (array) $headers, - 'rows' => $rows instanceof Arrayable ? $rows->toArray() : $rows, - 'tableStyle' => $tableStyle, - 'columnStyles' => $columnStyles, - ]; + $table = (new Table($output = new BufferedOutput)) + ->setHeaders((array) $headers) + ->setRows($rows instanceof Arrayable ? $rows->toArray() : $rows) + ->setStyle($tableStyle); + + foreach ($columnStyles as $columnIndex => $columnStyle) { + $table->setColumnStyle($columnIndex, $columnStyle); + } + + $table->render(); + + $lines = array_filter( + explode(PHP_EOL, $output->fetch()) + ); + + foreach ($lines as $line) { + $this->expectsOutput($line); + } return $this; } @@ -305,8 +317,6 @@ private function createABufferedOutputMock() ->shouldAllowMockingProtectedMethods() ->shouldIgnoreMissing(); - $this->applyTableOutputExpectations($mock); - foreach ($this->test->expectedOutput as $i => $output) { $mock->shouldReceive('doWrite') ->once() @@ -330,38 +340,6 @@ private function createABufferedOutputMock() return $mock; } - /** - * Apply the output table expectations to the mock. - * - * @param \Mockery\MockInterface $mock - * @return void - */ - private function applyTableOutputExpectations($mock) - { - foreach ($this->test->expectedTables as $i => $consoleTable) { - $table = (new Table($output = new BufferedOutput)) - ->setHeaders($consoleTable['headers']) - ->setRows($consoleTable['rows']) - ->setStyle($consoleTable['tableStyle']); - - foreach ($consoleTable['columnStyles'] as $columnIndex => $columnStyle) { - $table->setColumnStyle($columnIndex, $columnStyle); - } - - $table->render(); - - $lines = array_filter( - explode(PHP_EOL, $output->fetch()) - ); - - foreach ($lines as $line) { - $this->expectsOutput($line); - } - - unset($this->test->expectedTables[$i]); - } - } - /** * Flush the expectations from the test case. *