Skip to content

Commit dd49822

Browse files
committed
[Console] Use console exception for missing input
1 parent 46a8ede commit dd49822

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private function doAsk(OutputInterface $output, Question $question)
149149
if (false === $ret) {
150150
$ret = fgets($inputStream, 4096);
151151
if (false === $ret) {
152-
throw new \RuntimeException('Aborted');
152+
throw new RuntimeException('Aborted');
153153
}
154154
$ret = trim($ret);
155155
}

src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,17 @@ public function testChoiceOutputFormattingQuestionForUtf8Keys()
393393
$dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream("\n")), $output, $question);
394394
}
395395

396+
/**
397+
* @expectedException \Symfony\Component\Console\Exception\RuntimeException
398+
* @expectedExceptionMessage Aborted
399+
*/
400+
public function testAskThrowsExceptionOnMissingInput()
401+
{
402+
$dialog = new QuestionHelper();
403+
404+
$dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new Question('What\'s your name?'));
405+
}
406+
396407
/**
397408
* @group legacy
398409
*/

0 commit comments

Comments
 (0)