Skip to content

Commit

Permalink
Merge d2694e2 into ff47fda
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Mar 9, 2020
2 parents ff47fda + d2694e2 commit 2e21120
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/TestSuite/ConsoleIntegrationTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Cake\TestSuite\Stub\ConsoleInput;
use Cake\TestSuite\Stub\ConsoleOutput;
use Cake\TestSuite\Stub\MissingConsoleInputException;
use RuntimeException;

/**
* A test case class intended to make integration tests of cake console commands
Expand Down Expand Up @@ -90,15 +91,25 @@ trait ConsoleIntegrationTestTrait
*
* @param string $command Command to run
* @param array $input Input values to pass to an interactive shell
* @throws \Cake\TestSuite\Stub\MissingConsoleInputException
* @throws \RuntimeException
* @return void
*/
public function exec(string $command, array $input = []): void
{
$runner = $this->makeRunner();

$this->_out = new ConsoleOutput();
$this->_err = new ConsoleOutput();
$this->_in = new ConsoleInput($input);
if ($this->_out === null) {
$this->_out = new ConsoleOutput();
}
if ($this->_err === null) {
$this->_err = new ConsoleOutput();
}
if ($this->_in === null) {
$this->_in = new ConsoleInput($input);
} elseif ($input) {
throw new RuntimeException('You can use $input only if $_in property is null and will be reset.');
}

$args = $this->commandStringToArgs("cake $command");
$io = new ConsoleIo($this->_out, $this->_err, $this->_in);
Expand Down

0 comments on commit 2e21120

Please sign in to comment.