Skip to content

Commit

Permalink
Merge branch '4.1' into 4.2
Browse files Browse the repository at this point in the history
* 4.1:
  Ensure final input of CommandTester works with default
  [Intl] handle null date and time types
  Do not ignore the choice groups for caching
  • Loading branch information
Robin Chalas committed Jan 4, 2019
2 parents bcc0658 + e798b40 commit b0a03c1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Tester/TesterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ private static function createStream(array $inputs)
{
$stream = fopen('php://memory', 'r+', false);

fwrite($stream, implode(PHP_EOL, $inputs));
foreach ($inputs as $input) {
fwrite($stream, $input.PHP_EOL);
}

rewind($stream);

return $stream;
Expand Down
25 changes: 25 additions & 0 deletions Tests/Tester/CommandTesterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,31 @@ public function testCommandWithInputs()
$this->assertEquals(implode('', $questions), $tester->getDisplay(true));
}

public function testCommandWithDefaultInputs()
{
$questions = array(
'What\'s your name?',
'How are you?',
'Where do you come from?',
);

$command = new Command('foo');
$command->setHelperSet(new HelperSet(array(new QuestionHelper())));
$command->setCode(function ($input, $output) use ($questions, $command) {
$helper = $command->getHelper('question');
$helper->ask($input, $output, new Question($questions[0], 'Bobby'));
$helper->ask($input, $output, new Question($questions[1], 'Fine'));
$helper->ask($input, $output, new Question($questions[2], 'France'));
});

$tester = new CommandTester($command);
$tester->setInputs(array('', '', ''));
$tester->execute(array());

$this->assertEquals(0, $tester->getStatusCode());
$this->assertEquals(implode('', $questions), $tester->getDisplay(true));
}

/**
* @expectedException \RuntimeException
* @expectedMessage Aborted
Expand Down

0 comments on commit b0a03c1

Please sign in to comment.