8000 [Console] Fix bug with utf-8 bug, change writePrompt to use one function prepareChoices by proggga · Pull Request #33911 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] Fix bug with utf-8 bug, change writePrompt to use one function prepareChoices #33911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test that fix previous problem
  • Loading branch information
proggga committed Oct 24, 2019
commit fe8ae78d1186945dc866f9e711b6ab748c49b6ee
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Formatter\OutputFormatter;

/**
* @group tty
Expand Down Expand Up @@ -113,6 +114,33 @@ public function testAskEscapeAndFormatLabel()
$this->assertOutputContains('Do you want to use Foo\\Bar or Foo\\Baz? [Foo\\Baz]:', $output);
}

public function testForUtf8Keys()
{
$question = 'Lorem ipsum?';
$possibleChoices = [
'foo' => 'foo',
'żółw' => 'bar',
'łabądź' => 'baz',
];
$question_result = ' <info>Lorem ipsum?</info> [<comment>foo</comment>]:';
$outputShown = [
' [<comment>foo </comment>] foo',
' [<comment>żółw </comment>] bar',
' [<comment>łabądź</comment>] baz',
];

$dialog = new SymfonyQuestionHelper();

$question = new ChoiceQuestion($question, $possibleChoices, 'foo');

$output = $this->getMockBuilder('\Symfony\Component\Console\Output\OutputInterface')->getMock();
$output->method('getFormatter')->willReturn(new OutputFormatter());

$input = $this->createStreamableInputInterfaceMock($this->getInputStream('foo'));
$output->expects($this->exactly(2))->method('writeln')->withConsecutive([$question_result], [$outputShown]);
$dialog->ask($input, $output, $question);
}

public function testAskDefaultPrompt()
{
$helper = new SymfonyQuestionHelper();
Expand Down
0