/** @test */ public function it_opens_a_dialog_to_select_the_entity_and_count_if_no_entity_given() { /** @var SymfonyQuestionHelper $question */ $question = $this->command->getHelper('question'); $question->setInputStream($this->getInputStream("1\n5\n")); $this->commandTester->execute(['command' => $this->command->getName()]); $count = $this->getDatabaseCount(App::class, []); $this->assertEquals(5, $count); $this->assertContains(sprintf('%s seeded.', App::class), $this->commandTester->getDisplay()); }
public function createPlayerDialog(Command $command, OutputInterface $output) { /** @var $dialog DialogHelper */ $dialog = $command->getHelperSet()->get("dialog"); /** @var $translations TranslationsHelperInterface */ $translations = $command->getHelper("translations"); $player = new PlayerDataHelper(); $player->name = $dialog->ask($output, $translations->getLine("player_name") . ": "); $player->sex = $dialog->ask($output, $translations->getLine("player_sex_cmd") . ": "); $player->class = $dialog->ask($output, $translations->getLine("player_class_cmd") . ": "); $player->race = $dialog->ask($output, $translations->getLine("player_race_cmd") . ": "); return $player; }
public function render($results, Command $command) { $phpVersion = $this->getOption('phpVersion'); $checksCount = $this->getOption('checksCount'); $failCount = $this->getOption('failCount'); $output = $this->getOutput(); $output->writeLn('Executing against version: ' . $phpVersion); $table = $command->getHelper('table'); $table->setHeaders(array('Status', 'CVE ID', 'Risk', 'Summary')); $columnSize = 100; for ($i = 0, $length = count($results); $i < $length; $i++) { $results[$i]['status'] = 'fail' ? '<fg=red>FAIL</fg=red>' : '<fg=green>PASS</fg=green>'; $results[$i]['summary'] = !$output->isVerbose() && strlen($results[$i]['summary']) > $columnSize ? substr($results[$i]['summary'], 0, $columnSize - 3) . '...' : $results[$i]['summary']; } $table->setRows($results); $table->render($output); $output->writeLn(sprintf("\nScan complete\n%s\nTotal checks: %s\n<fg=red>Failures: %s</fg=red>\n", str_repeat('-', 20), $checksCount, $failCount)); }
/** * {@inheritdoc} */ public function getHelper($name) { return $this->decoratedCommand->getHelper($name); }
/** * @expectedException \RuntimeException * @expectedMessage Aborted */ public function testCommandWithWrongInputsNumber() { $questions = array('What\'s your name?', 'How are you?', 'Where do you come from?'); $command = new Command('foo'); $command->setHelperSet(new HelperSet(array(new QuestionHelper()))); $command->setCode(function ($input, $output) use($questions, $command) { $helper = $command->getHelper('question'); $helper->ask($input, $output, new Question($questions[0])); $helper->ask($input, $output, new Question($questions[1])); $helper->ask($input, $output, new Question($questions[2])); }); $tester = new CommandTester($command); $tester->setInputs(array('Bobby', 'Fine')); $tester->execute(array()); }
/** * @return DestinationHelper */ private function getDestinationHelper() : DestinationHelper { return parent::getHelper('link.destination'); }
public function getHelper($name) { return $this->innerCommand->getHelper($name); }
public function getHelper($name) { return parent::getHelper($name); }
/** * @param Command $command * @param array|string $input */ protected function setExpectedCommandInput(Command $command, $input) { if (is_array($input)) { $input = implode("\n", $input); } $helper = $command->getHelper('gush_question'); $helper->setInputStream($this->getInputStream($input)); }
/** * {@inheritdoc} */ public function getHelper($name) { $helper = parent::getHelper($name); if ($this->input !== null && $helper instanceof InputAwareInterface) { $helper->setInput($this->input); } if ($this->output !== null && $helper instanceof OutputAwareInterface) { $helper->setOutput($this->output); } return $helper; }