Skip to content

Commit e798b40

Browse files
author
Robin Chalas
committed
Merge branch '3.4' into 4.1
* 3.4: Ensure final input of CommandTester works with default [Intl] handle null date and time types Do not ignore the choice groups for caching
2 parents 97997c1 + a700b87 commit e798b40

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Tester/TesterTrait.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ private static function createStream(array $inputs)
9595
{
9696
$stream = fopen('php://memory', 'r+', false);
9797

98-
fwrite($stream, implode(PHP_EOL, $inputs));
98+
foreach ($inputs as $input) {
99+
fwrite($stream, $input.PHP_EOL);
100+
}
101+
99102
rewind($stream);
100103

101104
return $stream;

Tests/Tester/CommandTesterTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,31 @@ public function testCommandWithInputs()
112112
$this->assertEquals(implode('', $questions), $tester->getDisplay(true));
113113
}
114114

115+
public function testCommandWithDefaultInputs()
116+
{
117+
$questions = array(
118+
'What\'s your name?',
119+
'How are you?',
120+
'Where do you come from?',
121+
);
122+
123+
$command = new Command('foo');
124+
$command->setHelperSet(new HelperSet(array(new QuestionHelper())));
125+
$command->setCode(function ($input, $output) use ($questions, $command) {
126+
$helper = $command->getHelper('question');
127+
$helper->ask($input, $output, new Question($questions[0], 'Bobby'));
128+
$helper->ask($input, $output, new Question($questions[1], 'Fine'));
129+
$helper->ask($input, $output, new Question($questions[2], 'France'));
130+
});
131+
132+
$tester = new CommandTester($command);
133+
$tester->setInputs(array('', '', ''));
134+
$tester->execute(array());
135+
136+
$this->assertEquals(0, $tester->getStatusCode());
137+
$this->assertEquals(implode('', $questions), $tester->getDisplay(true));
138+
}
139+
115140
/**
116141
* @expectedException \RuntimeException
117142
* @expectedMessage Aborted

0 commit comments

Comments
 (0)