1111/**
1212 * @group tty
1313 */
14- class SymfonyQuestionHelperTest extends \PHPUnit_Framework_TestCase
14+ class SymfonyQuestionHelperTest extends AbstractQuestionHelperTest
1515{
1616 public function testAskChoice()
1717 {
@@ -22,29 +22,29 @@ public function testAskChoice()
2222
2323 $heroes = array('Superman', 'Batman', 'Spiderman');
2424
25- $questionHelper->setInputStream( $this->getInputStream("\n1\n 1 \nFabien\n1\nFabien\n1\n0,2\n 0 , 2 \n\n\n") );
25+ $inputStream = $this->getInputStream("\n1\n 1 \nFabien\n1\nFabien\n1\n0,2\n 0 , 2 \n\n\n");
2626
2727 $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '2');
2828 $question->setMaxAttempts(1);
2929 // first answer is an empty answer, we're supposed to receive the default value
30- $this->assertEquals('Spiderman', $questionHelper->ask($this->createInputInterfaceMock( ), $output = $this->createOutputInterface(), $question));
30+ $this->assertEquals('Spiderman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream ), $output = $this->createOutputInterface(), $question));
3131 $this->assertOutputContains('What is your favorite superhero? [Spiderman]', $output);
3232
3333 $question = new ChoiceQuestion('What is your favorite superhero?', $heroes);
3434 $question->setMaxAttempts(1);
35- $this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock( ), $this->createOutputInterface(), $question));
36- $this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock( ), $this->createOutputInterface(), $question));
35+ $this->assertEquals('Batman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream ), $this->createOutputInterface(), $question));
36+ $this->assertEquals('Batman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream ), $this->createOutputInterface(), $question));
3737
3838 $question = new ChoiceQuestion('What is your favorite superhero?', $heroes);
3939 $question->setErrorMessage('Input "%s" is not a superhero!');
4040 $question->setMaxAttempts(2);
41- $this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock( ), $output = $this->createOutputInterface(), $question));
41+ $this->assertEquals('Batman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream ), $output = $this->createOutputInterface(), $question));
4242 $this->assertOutputContains('Input "Fabien" is not a superhero!', $output);
4343
4444 try {
4545 $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '1');
4646 $question->setMaxAttempts(1);
47- $questionHelper->ask($this->createInputInterfaceMock( ), $output = $this->createOutputInterface(), $question);
47+ $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream ), $output = $this->createOutputInterface(), $question);
4848 $this->fail();
4949 } catch (\InvalidArgumentException $e) {
5050 $this->assertEquals('Value "Fabien" is invalid', $e->getMessage());
@@ -54,22 +54,22 @@ public function testAskChoice()
5454 $question->setMaxAttempts(1);
5555 $question->setMultiselect(true);
5656
57- $this->assertEquals(array('Batman'), $questionHelper->ask($this->createInputInterfaceMock( ), $this->createOutputInterface(), $question));
58- $this->assertEquals(array('Superman', 'Spiderman'), $questionHelper->ask($this->createInputInterfaceMock( ), $this->createOutputInterface(), $question));
59- $this->assertEquals(array('Superman', 'Spiderman'), $questionHelper->ask($this->createInputInterfaceMock( ), $this->createOutputInterface(), $question));
57+ $this->assertEquals(array('Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream ), $this->createOutputInterface(), $question));
58+ $this->assertEquals(array('Superman', 'Spiderman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream ), $this->createOutputInterface(), $question));
59+ $this->assertEquals(array('Superman', 'Spiderman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream ), $this->createOutputInterface(), $question));
6060
6161 $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '0,1');
6262 $question->setMaxAttempts(1);
6363 $question->setMultiselect(true);
6464
65- $this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createInputInterfaceMock( ), $output = $this->createOutputInterface(), $question));
65+ $this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream ), $output = $this->createOutputInterface(), $question));
6666 $this->assertOutputContains('What is your favorite superhero? [Superman, Batman]', $output);
6767
6868 $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, ' 0 , 1 ');
6969 $question->setMaxAttempts(1);
7070 $question->setMultiselect(true);
7171
72- $this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createInputInterfaceMock( ), $output = $this->createOutputInterface(), $question));
72+ $this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream ), $output = $this->createOutputInterface(), $question));
7373 $this->assertOutputContains('What is your favorite superhero? [Superman, Batman]', $output);
7474 }
7575
0 commit comments