[Console] ChoiceQuestion must have choices
This commit is contained in:
parent
103414623c
commit
96e307fd5c
@ -32,6 +32,10 @@ class ChoiceQuestion extends Question
|
||||
*/
|
||||
public function __construct($question, array $choices, $default = null)
|
||||
{
|
||||
if (!$choices) {
|
||||
throw new \LogicException('Choice question must have at least 1 choice available.');
|
||||
}
|
||||
|
||||
parent::__construct($question, $default);
|
||||
|
||||
$this->choices = $choices;
|
||||
|
@ -434,6 +434,15 @@ class QuestionHelperTest extends TestCase
|
||||
$dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Choice question must have at least 1 choice available.
|
||||
*/
|
||||
public function testEmptyChoices()
|
||||
{
|
||||
new ChoiceQuestion('Question', array(), 'irrelevant');
|
||||
}
|
||||
|
||||
protected function getInputStream($input)
|
||||
{
|
||||
$stream = fopen('php://memory', 'r+', false);
|
||||
|
Reference in New Issue
Block a user