public function testCanReadLineWithEmptyAnswer() { $line = new Line('Where is Bryan ?', true); $line->setConsole($this->adapter); ob_start(); $response = $line->show(); $text = ob_get_clean(); $this->assertEquals($text, "Where is Bryan ?"); $this->assertEquals('', $response); }
/** * @param $question * @param ConsoleAdapter $console * * @return string|null */ private function askUrlQuestion($question, ConsoleAdapter $console) { $console->writeLine($question . ' (URL)', ColorInterface::CYAN); $prompt = new Line(''); $prompt->setConsole($console); $url = $prompt->show(); if (!(new Uri(['allowRelative' => false]))->isValid($url)) { $console->writeLine('The provided URL "' . $url . '" doesn\'t seem to be valid!', ColorInterface::RED); return null; } return $url; }
public function ask($promptText, $allowEmpty = false) { $prompt = new LinePrompt($promptText, $allowEmpty); $prompt->setConsole($this->console); return $prompt->show(); }