parseLongOption() protected static method

protected static parseLongOption ( $arg, $long_options, &$opts, &$args )
 /**
  * Parse the options to see if we are running the uninstall group.
  *
  * @since 0.1.0
  *
  * @param array $argv The commandline arguments.
  */
 public function __construct($argv)
 {
     array_shift($argv);
     $options = array();
     while (list($i, $arg) = each($argv)) {
         try {
             if (strlen($arg) > 1 && $arg[0] === '-' && $arg[1] === '-') {
                 PHPUnit_Util_Getopt::parseLongOption(substr($arg, 2), $this->longOptions, $options, $argv);
             }
         } catch (PHPUnit_Framework_Exception $e) {
             // Right now we don't really care what the arguments are like.
             continue;
         }
     }
     foreach ($options as $option) {
         switch ($option[0]) {
             case '--group':
                 $groups = explode(',', $option[1]);
                 $this->uninstall_group = in_array('uninstall', $groups);
                 break 2;
         }
     }
     if (!$this->uninstall_group) {
         echo 'Not running plugin install/uninstall tests... To execute these, use --group uninstall.' . PHP_EOL;
     }
 }
Example #2
0
 function __construct($argv)
 {
     array_shift($argv);
     $options = array();
     while (list($i, $arg) = each($argv)) {
         try {
             if (strlen($arg) > 1 && $arg[0] === '-' && $arg[1] === '-') {
                 PHPUnit_Util_Getopt::parseLongOption(substr($arg, 2), $this->longOptions, $options, $argv);
             }
         } catch (PHPUnit_Framework_Exception $e) {
             // Enforcing recognized arguments or correctly formed arguments is
             // not really the concern here.
             continue;
         }
     }
     $ajax_message = true;
     foreach ($options as $option) {
         switch ($option[0]) {
             case '--exclude-group':
                 $ajax_message = false;
                 continue 2;
             case '--group':
                 $groups = explode(',', $option[1]);
                 foreach ($groups as $group) {
                     if (is_numeric($group) || preg_match('/^(UT|Plugin)\\d+$/', $group)) {
                         WP_UnitTestCase::forceTicket($group);
                     }
                 }
                 $ajax_message = !in_array('ajax', $groups);
                 continue 2;
         }
     }
     if ($ajax_message) {
         echo "Not running ajax tests... To execute these, use --group ajax." . PHP_EOL;
     }
 }
 function __construct($argv)
 {
     array_shift($argv);
     $options = array();
     while (list($i, $arg) = each($argv)) {
         try {
             if (strlen($arg) > 1 && $arg[0] === '-' && $arg[1] === '-') {
                 PHPUnit_Util_Getopt::parseLongOption(substr($arg, 2), $this->longOptions, $options, $argv);
             }
         } catch (PHPUnit_Framework_Exception $e) {
             // Enforcing recognized arguments or correctly formed arguments is
             // not really the concern here.
             continue;
         }
     }
     $skipped_groups = array('ajax' => true, 'ms-files' => true, 'external-http' => true);
     foreach ($options as $option) {
         switch ($option[0]) {
             case '--exclude-group':
                 foreach ($skipped_groups as $group_name => $skipped) {
                     $skipped_groups[$group_name] = false;
                 }
                 continue 2;
             case '--group':
                 $groups = explode(',', $option[1]);
                 foreach ($groups as $group) {
                     if (is_numeric($group) || preg_match('/^(UT|Plugin)\\d+$/', $group)) {
                         WP_UnitTestCase::forceTicket($group);
                     }
                 }
                 foreach ($skipped_groups as $group_name => $skipped) {
                     if (in_array($group_name, $groups)) {
                         $skipped_groups[$group_name] = false;
                     }
                 }
                 continue 2;
         }
     }
     $skipped_groups = array_filter($skipped_groups);
     foreach ($skipped_groups as $group_name => $skipped) {
         echo sprintf('Not running %1$s tests. To execute these, use --group %1$s.', $group_name) . PHP_EOL;
     }
     if (!isset($skipped_groups['external-http'])) {
         echo PHP_EOL;
         echo 'External HTTP skipped tests can be caused by timeouts.' . PHP_EOL;
         echo 'If this changeset includes changes to HTTP, make sure there are no timeouts.' . PHP_EOL;
         echo PHP_EOL;
     }
 }