Skip to content

Commit b0a03c1

Browse files
author
Robin Chalas
committed
Merge branch '4.1' into 4.2
* 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
2 parents bcc0658 + e798b40 commit b0a03c1

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
@@ -162,7 +162,10 @@ private static function createStream(array $inputs)
162162
{
163163
$stream = fopen('php://memory', 'r+', false);
164164

165-
fwrite($stream, implode(PHP_EOL, $inputs));
165+
foreach ($inputs as $input) {
166+
fwrite($stream, $input.PHP_EOL);
167+
}
168+
166169
rewind($stream);
167170

168171
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)