Example #1
0
 function it_renders()
 {
     $command = new Command();
     $command->setHelp('help');
     $input = new Input();
     $output = new Output();
     $output->setEnableBuffering(true);
     $this->beConstructedWith($input, $output);
     $this->render($command);
 }
 function it_renders()
 {
     $command = new Command();
     $command->option(OptionType::SINGLE, '--name', '-a');
     $command->option(OptionType::INCREMENTAL, '--name', '-n');
     $input = new Input();
     $output = new Output();
     $output->setEnableBuffering(true);
     $this->beConstructedWith($input, $output);
     $this->render($command);
 }
Example #3
0
 function let()
 {
     $command = new Command('name');
     $command->argument(ArgumentType::SINGLE, 'arg1')->setValue('val1');
     $command->argument(ArgumentType::SINGLE, 'arg2');
     $command->option(ArgumentType::SINGLE, '--opt1')->setValue('val2');
     $command->option(ArgumentType::SINGLE, null, '-o')->setValue('val3');
     $command->option(ArgumentType::SINGLE, '--opt2');
     $this->beConstructedWith($command);
 }
 function it_renders()
 {
     $command = new Command();
     $command->argument(ArgumentType::SINGLE, 'single');
     $command->argument(ArgumentType::SINGLE_OPTIONAL, 'single_optional');
     $command->argument(ArgumentType::MULTIPLE, 'multiple');
     $command->argument(ArgumentType::MULTIPLE_OPTIONAL, 'multiple_optional');
     $input = new Input();
     $output = new Output();
     $output->setEnableBuffering(true);
     $this->beConstructedWith($input, $output);
     $this->render($command);
 }
Example #5
0
 function it_handles_command_errors()
 {
     $command = new ErrorCommand();
     $consoleCommand = new Command('error');
     $consoleCommand->setHandler($command);
     $this->addCommand($consoleCommand);
     $this->getOutput()->setEnableBuffering(true);
     $this->parseString('error');
 }
Example #6
0
 function it_renders()
 {
     $command = new Command();
     $command->argument(ArgumentType::SINGLE, 'arg1');
     $command->argument(ArgumentType::SINGLE_OPTIONAL, 'arg2');
     $command->argument(ArgumentType::MULTIPLE, 'arg3');
     $command->argument(ArgumentType::MULTIPLE_OPTIONAL, 'arg4');
     $command->option(OptionType::SINGLE, '--opt1', '-1');
     $command->option(OptionType::SINGLE_OPTIONAL, '--opt2', '-2');
     $command->option(OptionType::MULTIPLE, '--opt3', '-3');
     $command->option(OptionType::MULTIPLE_OPTIONAL, '--opt4', '-4');
     $command->option(OptionType::BOOLEAN, '--opt5', '-5');
     $command->option(OptionType::INCREMENTAL, '--opt6', '-6');
     $input = new Input();
     $output = new Output();
     $output->setEnableBuffering(true);
     $this->beConstructedWith($input, $output);
     $this->render($command);
 }
Example #7
0
 /**
  * @param object $command
  */
 public function addCommand($command)
 {
     if ($command instanceof ICommand) {
         $consoleCommand = $command;
         $command = $consoleCommand->getHandler();
     } else {
         $consoleCommand = new Command();
     }
     $this->validateCommand($command);
     if (!is_object($command)) {
         $command = $this->commandInvoker->create($command);
     }
     $consoleCommand->setHandler($command);
     $this->commandInvoker->setup($command, $consoleCommand);
     $this->commands[] = $consoleCommand;
 }
 function it_matches_a_command_with_options_without_values()
 {
     $option1 = new Option(OptionType::BOOLEAN, '--aa', null);
     $option2 = new Option(OptionType::BOOLEAN, '--bb', null);
     $option3 = new Option(OptionType::BOOLEAN, null, '-c');
     $option4 = new Option(OptionType::INCREMENTAL, null, '-d');
     $option5 = new Option(OptionType::INCREMENTAL, '--ee', '-e');
     $args = ['--aa' => [], '-c' => [], '-d' => [], '-e' => [], 'options' => ['-d' => 4, '-e' => 5]];
     $command = new Command('name');
     $command->addOptions([$option1, $option2, $option3, $option4, $option5]);
     $this->matchCommand($command, $args);
     it($option1->getValue())->shouldBe(true);
     it($option2->getValue())->shouldBe(false);
     it($option3->getValue())->shouldBe(true);
     it($option4->getValue())->shouldBe(4);
     it($option5->getValue())->shouldBe(5);
 }