10BC0 [Console] Test SymfonyQuestionhelper::ask() allows validating null by chalasr · Pull Request #20142 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Question\ChoiceQuestion;

/**
Expand Down Expand Up @@ -73,6 +74,17 @@ public function testAskChoice()
$this->assertOutputContains('What is your favorite superhero? [Superman, Batman]', $output);
}

public function testAskReturnsNullIfValidatorAllowsIt()
{
$questionHelper = new SymfonyQuestionHelper();
$questionHelper->setHelperSet(new HelperSet(array(new FormatterHelper())));

$question = new Question('What is your favorite superhero?');
$question->setValidator(function ($value) { return $value; });

$this->assertNull($questionHelper->ask($this->createStreamableInputInterfaceMock($this->getInputStream("\n")), $this->createOutputInterface(), $question));
}

protected function getInputStream($input)
{
$stream = fopen('php://memory', 'r+', false);
Expand Down
0