[Console] fix test using deprecated code

This commit is contained in:
Nicolas Grekas 2018-10-14 11:55:22 -07:00
parent 55978d793f
commit 2caee9435f

View File

@ -95,52 +95,52 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
$helperSet = new HelperSet(array(new FormatterHelper())); $helperSet = new HelperSet(array(new FormatterHelper()));
$questionHelper->setHelperSet($helperSet); $questionHelper->setHelperSet($helperSet);
$questionHelper->setInputStream($this->getInputStream("\n1\n 1 \nFabien\n1\nFabien\n1\n0,2\n 0 , 2 \n\n\n")); $inputStream = $this->getInputStream("\n1\n 1 \nFabien\n1\nFabien\n1\n0,2\n 0 , 2 \n\n\n");
$heroes = array('Superman', 'Batman', 'Spiderman'); $heroes = array('Superman', 'Batman', 'Spiderman');
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '0'); $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '0');
$this->assertSame('Superman', $questionHelper->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question)); $this->assertSame('Superman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, 'Batman'); $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, 'Batman');
$this->assertSame('Batman', $questionHelper->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question)); $this->assertSame('Batman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, null); $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, null);
$this->assertNull($questionHelper->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question)); $this->assertNull($questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '0'); $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '0');
$question->setValidator(null); $question->setValidator(null);
$this->assertSame('Superman', $questionHelper->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question)); $this->assertSame('Superman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
try { try {
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, null); $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, null);
$questionHelper->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question); $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question);
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
$this->assertSame('Value "" is invalid', $e->getMessage()); $this->assertSame('Value "" is invalid', $e->getMessage());
} }
$question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, '0, 1'); $question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, '0, 1');
$question->setMultiselect(true); $question->setMultiselect(true);
$this->assertSame(array('Superman', 'Batman'), $questionHelper->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question)); $this->assertSame(array('Superman', 'Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
$question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, '0, 1'); $question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, '0, 1');
$question->setMultiselect(true); $question->setMultiselect(true);
$question->setValidator(null); $question->setValidator(null);
$this->assertSame(array('Superman', 'Batman'), $questionHelper->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question)); $this->assertSame(array('Superman', 'Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
$question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, '0, Batman'); $question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, '0, Batman');
$question->setMultiselect(true); $question->setMultiselect(true);
$this->assertSame(array('Superman', 'Batman'), $questionHelper->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question)); $this->assertSame(array('Superman', 'Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
$question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, null); $question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, null);
$question->setMultiselect(true); $question->setMultiselect(true);
$this->assertNull($questionHelper->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question)); $this->assertNull($questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
try { try {
$question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, ''); $question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, '');
$question->setMultiselect(true); $question->setMultiselect(true);
$questionHelper->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question); $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question);
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
$this->assertSame('Value "" is invalid', $e->getMessage()); $this->assertSame('Value "" is invalid', $e->getMessage());
} }