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

Skip to content

[Console] Test SymfonyQuestionhelper::ask() allows validating null #20142

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
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