Skip to content

Commit caba8f4

Browse files
committed
minor #15280 [Console] Set QuestionHelper max attempts in tests (jakzal)
This PR was merged into the 2.7 branch. Discussion ---------- [Console] Set QuestionHelper max attempts in tests Otherwise the process will block if a test fails. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - QuestionHelper tests will block the phpunit process if any of tests fails. This is what's currently happening on 2.8 branch. As soon as this is merged to 2.7 and 2.8, I can work on fixing 2.8 tests. re #14638 Commits ------- 23bc264 [Console] Set QuestionHelper max attempts in tests
2 parents be4f2d5 + 23bc264 commit caba8f4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@ public function testAskChoice()
3636
$questionHelper->setInputStream($this->getInputStream("\n1\n 1 \nFabien\n1\nFabien\n1\n0,2\n 0 , 2 \n\n\n"));
3737

3838
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '2');
39+
$question->setMaxAttempts(1);
3940
// first answer is an empty answer, we're supposed to receive the default value
4041
$this->assertEquals('Spiderman', $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
4142

4243
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes);
44+
$question->setMaxAttempts(1);
4345
$this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
4446
$this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
4547

4648
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes);
4749
$question->setErrorMessage('Input "%s" is not a superhero!');
50+
$question->setMaxAttempts(2);
4851
$this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock(), $output = $this->createOutputInterface(), $question));
4952

5053
rewind($output->getStream());
@@ -61,18 +64,21 @@ public function testAskChoice()
6164
}
6265

6366
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, null);
67+
$question->setMaxAttempts(1);
6468
$question->setMultiselect(true);
6569

6670
$this->assertEquals(array('Batman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
6771
$this->assertEquals(array('Superman', 'Spiderman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
6872
$this->assertEquals(array('Superman', 'Spiderman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
6973

7074
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '0,1');
75+
$question->setMaxAttempts(1);
7176
$question->setMultiselect(true);
7277

7378
$this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
7479

7580
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, ' 0 , 1 ');
81+
$question->setMaxAttempts(1);
7682
$question->setMultiselect(true);
7783

7884
$this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
@@ -227,6 +233,7 @@ public function testSelectChoiceFromSimpleChoices($providedAnswer, $expectedValu
227233
$dialog->setHelperSet($helperSet);
228234

229235
$question = new ChoiceQuestion('Please select the environment to load', $possibleChoices);
236+
$question->setMaxAttempts(1);
230237
$answer = $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question);
231238

232239
$this->assertSame($expectedValue, $answer);

0 commit comments

Comments
 (0)