|
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;
|
@@ -1013,6 +1014,35 @@ public function testTraversableAutocomplete()
|
1013 | 1014 | $this->assertEquals('FooBundle', $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
|
1014 | 1015 | }
|
1015 | 1016 |
|
| 1017 | + public function testDisableSttby() |
| 1018 | + { |
| 1019 | + if (!Terminal::hasSttyAvailable()) { |
| 1020 | + $this->markTestSkipped('`stty` is required to test autocomplete functionality'); |
| 1021 | + } |
| 1022 | + |
| 1023 | + $this->expectException(InvalidArgumentException::class); |
| 1024 | + $this->expectExceptionMessage('invalid'); |
| 1025 | + |
| 1026 | + QuestionHelper::disableStty(); |
| 1027 | + $dialog = new QuestionHelper(); |
| 1028 | + $dialog->setHelperSet(new HelperSet([new FormatterHelper()])); |
| 1029 | + |
| 1030 | + $question = new ChoiceQuestion('Please select a bundle', [1 => 'AcmeDemoBundle', 4 => 'AsseticBundle']); |
| 1031 | + $question->setMaxAttempts(1); |
| 1032 | + |
| 1033 | + // <UP ARROW><UP ARROW><NEWLINE><DOWN ARROW><DOWN ARROW><NEWLINE> |
| 1034 | + // Gives `AcmeDemoBundle` with stty |
| 1035 | + $inputStream = $this->getInputStream("\033[A\033[A\n\033[B\033[B\n"); |
| 1036 | + |
| 1037 | + try { |
| 1038 | + $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question); |
| 1039 | + } finally { |
| 1040 | + $reflection = new \ReflectionProperty(QuestionHelper::class, 'stty'); |
| 1041 | + $reflection->setAccessible(true); |
| 1042 | + $reflection->setValue(null, true); |
| 1043 | + } |
| 1044 | + } |
| 1045 | + |
1016 | 1046 | public function testTraversableMultiselectAutocomplete()
|
1017 | 1047 | {
|
1018 | 1048 | // <NEWLINE>
|
|
0 commit comments