コード例 #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;
     }
 }
 /**
  * Dynamically adds options to this task based on the current route.
  *
  * @param sfCommandManager $commandManager
  * @param array            $options        Options as read from commandline
  *
  * @return void
  * @see sfTask
  */
 protected function process(sfCommandManager $commandManager, $options)
 {
     $commandManager->process($options);
     if (array_key_exists('application', $commandManager->getArgumentValues()) && array_key_exists('sf_route', $commandManager->getArgumentValues())) {
         $application = $commandManager->getArgumentValue('application');
         $routeName = $commandManager->getArgumentValue('sf_route');
         $configuration = $this->createConfiguration($application, 'prod');
         $this->route = sfImageTransformExtraPluginConfiguration::getRoute($routeName, $configuration);
         $routeVariables = array_keys($this->route->getVariables());
         $this->options = array();
         $optionSet = new sfCommandOptionSet();
         foreach ($commandManager->getErrors() as $error) {
             if (preg_match('/"--([\\w-_]+)"/', $error, $matches) && in_array($matches[1], $routeVariables)) {
                 $option = new sfCommandOption($matches[1], null, sfCommandOption::PARAMETER_OPTIONAL, '', null);
                 $this->options[] = $option;
                 $optionSet->addOption($option);
             }
         }
         $commandManager->setOptionSet($optionSet);
     }
     parent::process($commandManager, $options);
 }
コード例 #3
0
ファイル: sfTask.class.php プロジェクト: JimmyVB/Symfony-v1.2
 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())));
     }
 }
コード例 #4
0
$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');