예제 #1
0
 /**
  *
  * @param array $arguments
  * @param array $options
  *
  * @return void
  */
 protected function execute($arguments = array(), $options = array())
 {
     if (null === ($atoumPath = \sfConfig::get('sf_atoum_path'))) {
         $atoumPath = dirname(__FILE__) . '/../../../lib/vendor/atoum/';
     }
     if (defined(__NAMESPACE__ . '\\running') === false) {
         require_once $atoumPath . '/classes/autoloader.php';
     }
     if (defined(__NAMESPACE__ . '\\autorun') === false) {
         define(__NAMESPACE__ . '\\autorun', true);
         $commandManager = new \sfCommandManager();
         $commandManager->getArgumentSet()->addArguments($this->getArguments());
         $commandManager->getOptionSet()->addOptions($this->getOptions());
         $options = $this->processOptions($options);
         $parser = new \sfAtoumPlugin\arguments\parser($commandManager);
         $runnerPath = $atoumPath . '/scripts/runner.php';
         $runner = new \mageekguy\atoum\scripts\runner($runnerPath);
         $runner->setArguments($parser->toAtoumArguments($arguments, $options));
         $runner->run();
         $score = $runner->getRunner()->getScore();
         return $score->getFailNumber() <= 0 && $score->getErrorNumber() <= 0 && $score->getExceptionNumber() <= 0 ? 0 : 1;
     }
 }
예제 #2
0
 /**
  * Runs the task from the CLI.
  *
  * @param sfCommandManager $commandManager  An sfCommandManager instance
  * @param mixed            $options         The command line options
  */
 public function runFromCLI(sfCommandManager $commandManager, $options = null)
 {
     $commandManager->getArgumentSet()->addArguments($this->getArguments());
     $commandManager->getOptionSet()->addOptions($this->getOptions());
     return $this->doRun($commandManager, $options);
 }
$t->isa_ok($manager->getArgumentSet(), 'sfCommandArgumentSet', '__construct() creates a new sfCommandArgumentsSet if none given');
$t->isa_ok($manager->getOptionSet(), 'sfCommandOptionSet', '__construct() creates a new sfCommandOptionSet if none given');

$manager = new sfCommandManager($argumentSet);
$t->is($manager->getArgumentSet(), $argumentSet, '__construct() takes a sfCommandArgumentSet as its first argument');
$t->isa_ok($manager->getOptionSet(), 'sfCommandOptionSet', '__construct() takes a sfCommandArgumentSet as its first argument');

$manager = new sfCommandManager($argumentSet, $optionSet);
$t->is($manager->getOptionSet(), $optionSet, '__construct() can take a sfCommandOptionSet as its second argument');

// ->setArgumentSet() ->getArgumentSet()
$t->diag('->setArgumentSet() ->getArgumentSet()');
$manager = new sfCommandManager(new sfCommandArgumentSet());
$argumentSet = new sfCommandArgumentSet();
$manager->setArgumentSet($argumentSet);
$t->is($manager->getArgumentSet(), $argumentSet, '->setArgumentSet() sets the manager argument set');

// ->setOptionSet() ->getOptionSet()
$t->diag('->setOptionSet() ->getOptionSet()');
$manager = new sfCommandManager(new sfCommandArgumentSet());
$optionSet = new sfCommandOptionSet();
$manager->setOptionSet($optionSet);
$t->is($manager->getOptionSet(), $optionSet, '->setOptionSet() sets the manager option set');

// ->process()
$t->diag('->process()');
$argumentSet = new sfCommandArgumentSet(array(
  new sfCommandArgument('foo1', sfCommandArgument::REQUIRED),
  new sfCommandArgument('foo2', sfCommandArgument::OPTIONAL | sfCommandArgument::IS_ARRAY),
));
$optionSet = new sfCommandOptionSet(array(