PHPUnit_Util_Test::getGroups PHP Method

getGroups() public static method

Returns the groups for a test class or method.
public static getGroups ( string $className, string $methodName = '' ) : array
$className string
$methodName string
return array
    public static function getGroups($className, $methodName = '')
    {
        $annotations = self::parseTestMethodAnnotations($className, $methodName);
        $groups = [];
        if (isset($annotations['method']['author'])) {
            $groups = $annotations['method']['author'];
        } elseif (isset($annotations['class']['author'])) {
            $groups = $annotations['class']['author'];
        }
        if (isset($annotations['class']['group'])) {
            $groups = array_merge($groups, $annotations['class']['group']);
        }
        if (isset($annotations['method']['group'])) {
            $groups = array_merge($groups, $annotations['method']['group']);
        }
        if (isset($annotations['class']['ticket'])) {
            $groups = array_merge($groups, $annotations['class']['ticket']);
        }
        if (isset($annotations['method']['ticket'])) {
            $groups = array_merge($groups, $annotations['method']['ticket']);
        }
        foreach (['method', 'class'] as $element) {
            foreach (['small', 'medium', 'large'] as $size) {
                if (isset($annotations[$element][$size])) {
                    $groups[] = $size;
                    break 2;
                }
            }
        }
        return array_unique($groups);
    }

Usage Example

 /**
  * @param ReflectionClass $theClass
  * @param Stagehand_TestRunner_Config $config
  * @return boolean
  */
 protected function shouldExclude(ReflectionClass $class, ReflectionMethod $method)
 {
     if (is_null($this->config->phpunitConfigFile)) {
         return false;
     }
     $groups = PHPUnit_Util_Test::getGroups($class->getName(), $method->getName());
     $shouldExclude = false;
     $groupConfiguration = PHPUnit_Util_Configuration::getInstance($this->config->phpunitConfigFile)->getGroupConfiguration();
     if (array_key_exists('include', $groupConfiguration) && count($groupConfiguration['include'])) {
         $shouldExclude = true;
         foreach ($groups as $group) {
             if (in_array($group, $groupConfiguration['include'])) {
                 $shouldExclude = false;
                 break;
             }
         }
     }
     if (array_key_exists('exclude', $groupConfiguration) && count($groupConfiguration['exclude'])) {
         foreach ($groups as $group) {
             if (in_array($group, $groupConfiguration['exclude'])) {
                 $shouldExclude = true;
                 break;
             }
         }
     }
     return $shouldExclude;
 }
All Usage Examples Of PHPUnit_Util_Test::getGroups