[Console] Fix question formatting using SymfonyStyle::ask()

This commit is contained in:
Robin Chalas 2016-12-17 12:19:40 +01:00
parent 0a4a92b05b
commit 9d46712103
No known key found for this signature in database
GPG Key ID: 89672113756EE03B
2 changed files with 8 additions and 6 deletions

View File

@ -53,7 +53,7 @@ class SymfonyQuestionHelper extends QuestionHelper
*/
protected function writePrompt(OutputInterface $output, Question $question)
{
$text = OutputFormatter::escape($question->getQuestion());
$text = $question->getQuestion();
$default = $question->getDefault();
switch (true) {

View File

@ -79,7 +79,9 @@ class SymfonyQuestionHelperTest extends \PHPUnit_Framework_TestCase
$questionHelper = new SymfonyQuestionHelper();
$questionHelper->setInputStream($this->getInputStream("\n"));
$question = new Question('What is your favorite superhero?');
$question->setValidator(function ($value) { return $value; });
$question->setValidator(function ($value) {
return $value;
});
$this->assertNull($questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
}
@ -92,13 +94,13 @@ class SymfonyQuestionHelperTest extends \PHPUnit_Framework_TestCase
$this->assertOutputContains('Can I have a backslash? [\]', $output);
}
public function testAskEscapeLabel()
public function testAskEscapeAndFormatLabel()
{
$helper = new SymfonyQuestionHelper();
$helper->setInputStream($this->getInputStream('sure'));
$helper->ask($this->createInputInterfaceMock(), $output = $this->createOutputInterface(), new Question('Do you want a \?'));
$helper->setInputStream($this->getInputStream('Foo\\Bar'));
$helper->ask($this->createInputInterfaceMock(), $output = $this->createOutputInterface(), new Question('Do you want to use Foo\\Bar <comment>or</comment> Foo\\Baz\\?', 'Foo\\Baz'));
$this->assertOutputContains('Do you want a \?', $output);
$this->assertOutputContains('Do you want to use Foo\\Bar or Foo\\Baz\\? [Foo\\Baz]:', $output);
}
/**