예제 #1
0
 protected function process(sfCommandManager $commandManager, $options)
 {
     $commandManager->process($options);
     if (!$commandManager->isValid()) {
         throw new sfCommandArgumentsException(sprintf("The execution of task \"%s\" failed.\n- %s", $this->getFullName(), implode("\n- ", $commandManager->getErrors())));
     }
 }
$manager->process('--foo');
$t->ok(!$manager->isValid(), '->isValid() returns false if the options are not valid');
$t->is(count($manager->getErrors()), 1, '->getErrors() returns an array of errors');

$optionSet = new sfCommandOptionSet(array(new sfCommandOption('foo', 'f', sfCommandOption::PARAMETER_REQUIRED)));
$manager = new sfCommandManager(null, $optionSet);
$manager->process('-f');
$t->ok(!$manager->isValid(), '->isValid() returns false if the options are not valid');
$t->is(count($manager->getErrors()), 1, '->getErrors() returns an array of errors');

$optionSet = new sfCommandOptionSet(array(new sfCommandOption('foo', null, sfCommandOption::PARAMETER_NONE)));
$manager = new sfCommandManager(null, $optionSet);
$manager->process('--foo="bar"');
$t->ok(!$manager->isValid(), '->isValid() returns false if the options are not valid');
$t->is(count($manager->getErrors()), 1, '->getErrors() returns an array of errors');

$manager = new sfCommandManager();
$manager->process('--bar');
$t->ok(!$manager->isValid(), '->isValid() returns false if the options are not valid');
$t->is(count($manager->getErrors()), 1, '->getErrors() returns an array of errors');

$manager = new sfCommandManager();
$manager->process('-b');
$t->ok(!$manager->isValid(), '->isValid() returns false if the options are not valid');
$t->is(count($manager->getErrors()), 1, '->getErrors() returns an array of errors');

$manager = new sfCommandManager();
$manager->process('--bar="foo"');
$t->ok(!$manager->isValid(), '->isValid() returns false if the options are not valid');
$t->is(count($manager->getErrors()), 1, '->getErrors() returns an array of errors');