diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php index b34777910ea7..60095a6c2fa6 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php @@ -22,6 +22,13 @@ trait InteractsWithConsole */ public $expectedOutput = []; + /** + * All of the output lines that are expected to never be output. + * + * @var array + */ + public $expectedOutputNever = []; + /** * All of the expected ouput tables. * diff --git a/src/Illuminate/Testing/PendingCommand.php b/src/Illuminate/Testing/PendingCommand.php index 9eb5a328b133..64738811044e 100644 --- a/src/Illuminate/Testing/PendingCommand.php +++ b/src/Illuminate/Testing/PendingCommand.php @@ -133,6 +133,19 @@ public function expectsOutput($output) return $this; } + /** + * Specify output that should never be printed when the command runs. + * + * @param string $output + * @return $this + */ + public function expectsOutputNever($output) + { + $this->test->expectedOutputNever[$output] = false; + + return $this; + } + /** * Specify a table that should be printed when the command runs. * @@ -238,6 +251,10 @@ protected function verifyExpectations() if (count($this->test->expectedOutput)) { $this->test->fail('Output "'.Arr::first($this->test->expectedOutput).'" was not printed.'); } + + if ($output = array_search(true, $this->test->expectedOutputNever)) { + $this->test->fail('Output "'.$output.'" was printed.'); + } } /** @@ -299,6 +316,16 @@ private function createABufferedOutputMock() }); } + foreach ($this->test->expectedOutputNever as $output => $displayed) { + $mock->shouldReceive('doWrite') + ->once() + ->ordered() + ->with($output, Mockery::any()) + ->andReturnUsing(function () use ($output) { + $this->test->expectedOutputNever[$output] = true; + }); + } + return $mock; }