[Console] Fix question formatting using SymfonyStyle::ask()
This commit is contained in:
parent
0a4a92b05b
commit
9d46712103
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user