|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\Console\Tests\Helper;
|
13 | 13 |
|
| 14 | +use Symfony\Component\Console\Formatter\OutputFormatter; |
14 | 15 | use Symfony\Component\Console\Helper\QuestionHelper;
|
15 | 16 | use Symfony\Component\Console\Helper\HelperSet;
|
16 | 17 | use Symfony\Component\Console\Helper\FormatterHelper;
|
@@ -350,6 +351,34 @@ public function testNoInteraction()
|
350 | 351 | $this->assertEquals('not yet', $dialog->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question));
|
351 | 352 | }
|
352 | 353 |
|
| 354 | + public function testChoiceOutputFormattingQuestionForUtf8Keys() |
| 355 | + { |
| 356 | + $question = 'Lorem ipsum?'; |
| 357 | + $possibleChoices = array( |
| 358 | + 'foo' => 'foo', |
| 359 | + 'żółw' => 'bar', |
| 360 | + 'łabądź' => 'baz', |
| 361 | + ); |
| 362 | + $outputShown = array( |
| 363 | + $question, |
| 364 | + ' [<info>foo </info>] foo', |
| 365 | + ' [<info>żółw </info>] bar', |
| 366 | + ' [<info>łabądź</info>] baz', |
| 367 | + ); |
| 368 | + $output = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); |
| 369 | + $output->method('getFormatter')->willReturn(new OutputFormatter()); |
| 370 | + |
| 371 | + $dialog = new QuestionHelper(); |
| 372 | + $dialog->setInputStream($this->getInputStream("\n")); |
| 373 | + $helperSet = new HelperSet(array(new FormatterHelper())); |
| 374 | + $dialog->setHelperSet($helperSet); |
| 375 | + |
| 376 | + $output->expects($this->once())->method('writeln')->with($this->equalTo($outputShown)); |
| 377 | + |
| 378 | + $question = new ChoiceQuestion($question, $possibleChoices, 'foo'); |
| 379 | + $dialog->ask($this->createInputInterfaceMock(), $output, $question); |
| 380 | + } |
| 381 | + |
353 | 382 | protected function getInputStream($input)
|
354 | 383 | {
|
355 | 384 | $stream = fopen('php://memory', 'r+', false);
|
|
0 commit comments