|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\Console\Tests\Helper;
|
13 | 13 |
|
| 14 | +use Symfony\Component\Console\Exception\InvalidArgumentException; |
14 | 15 | use Symfony\Component\Console\Formatter\OutputFormatter;
|
15 | 16 | use Symfony\Component\Console\Helper\FormatterHelper;
|
16 | 17 | use Symfony\Component\Console\Helper\HelperSet;
|
@@ -783,6 +784,35 @@ public function testTraversableAutocomplete()
|
783 | 784 | $this->assertEquals('FooBundle', $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
|
784 | 785 | }
|
785 | 786 |
|
| 787 | + public function testDisableSttby() |
| 788 | + { |
| 789 | + if (!Terminal::hasSttyAvailable()) { |
| 790 | + $this->markTestSkipped('`stty` is required to test autocomplete functionality'); |
| 791 | + } |
| 792 | + |
| 793 | + $this->expectException(InvalidArgumentException::class); |
| 794 | + $this->expectExceptionMessage('invalid'); |
| 795 | + |
| 796 | + QuestionHelper::disableStty(); |
| 797 | + $dialog = new QuestionHelper(); |
| 798 | + $dialog->setHelperSet(new HelperSet([new FormatterHelper()])); |
| 799 | + |
| 800 | + $question = new ChoiceQuestion('Please select a bundle', [1 => 'AcmeDemoBundle', 4 => 'AsseticBundle']); |
| 801 | + $question->setMaxAttempts(1); |
| 802 | + |
| 803 | + // <UP ARROW><UP ARROW><NEWLINE><DOWN ARROW><DOWN ARROW><NEWLINE> |
| 804 | + // Gives `AcmeDemoBundle` with stty |
| 805 | + $inputStream = $this->getInputStream("\033[A\033[A\n\033[B\033[B\n"); |
| 806 | + |
| 807 | + try { |
| 808 | + $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question); |
| 809 | + } finally { |
| 810 | + $reflection = new \ReflectionProperty(QuestionHelper::class, 'stty'); |
| 811 | + $reflection->setAccessible(true); |
| 812 | + $reflection->setValue(null, true); |
| 813 | + } |
| 814 | + } |
| 815 | + |
786 | 816 | public function testTraversableMultiselectAutocomplete()
|
787 | 817 | {
|
788 | 818 | // <NEWLINE>
|
|
0 commit comments