Reputation: 13987
When running PHPUnit tests that are testing an Artisan
command PHPUnit outputs any console ->info() or ->writeln()
function calls.
Tests to not fail due to this although its ugly.
Example:
see the progress bar? How can we disable output during testing?
Upvotes: 2
Views: 4499
Reputation: 8385
Some options come in mind all operate with verbosity of the command:
--quiet|-q
flag within call()
callSilent()
instead of call()
(from test itself)quiet
before using it: $cmd = resolve(Command::class); $cmd->setVerbosity('quiet'); $cmd->doWork();
$this->setVerbosity('quiet');
and obviously resolve/new up the dummy command insteadExample of the latest (yes in one file):
class TestCommand extends TestCase {
...
}
class DummyCommand extends RealCommand {
function __constructor() {
parent::__construct();
$this->setVerbosity('quiet');
}
}
Upvotes: 4