Update command unit tests to use helper functions
This commit is contained in:
parent
8df5d5beaf
commit
6e5b0b8027
13 changed files with 615 additions and 100 deletions
|
@ -31,6 +31,23 @@ use Symfony\Component\Console\Tester\CommandTester;
|
|||
|
||||
abstract class CommandTestCase extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $commandIsInteractive = true;
|
||||
|
||||
/**
|
||||
* Set a command to be non-interactive for testing purposes.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withoutInteraction()
|
||||
{
|
||||
$this->commandIsInteractive = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the display from running a command.
|
||||
*
|
||||
|
@ -48,6 +65,8 @@ abstract class CommandTestCase extends TestCase
|
|||
|
||||
$response = new CommandTester($command);
|
||||
$response->setInputs($inputs);
|
||||
|
||||
$opts = array_merge($opts, ['interactive' => $this->commandIsInteractive]);
|
||||
$response->execute($args, $opts);
|
||||
|
||||
return $response->getDisplay();
|
||||
|
|
Reference in a new issue