You are here

public static function TestDiscovery::parseTestClassAnnotations in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/TestDiscovery.php \Drupal\simpletest\TestDiscovery::parseTestClassAnnotations()

Parses annotations in the phpDoc of a test class.

Parameters

\ReflectionClass $class: The reflected test class.

Return value

array An associative array that contains all annotations on the test class; typically including:

  • group: A list of @group values.
  • requires: An associative array of @requires values; e.g.:
    • module: A list of Drupal module dependencies that are required to exist.

See also

PHPUnit_Util_Test::parseTestMethodAnnotations()

http://phpunit.de/manual/current/en/incomplete-and-skipped-tests.html#in...

File

core/modules/simpletest/src/TestDiscovery.php, line 397
Contains \Drupal\simpletest\TestDiscovery.

Class

TestDiscovery
Discovers available tests.

Namespace

Drupal\simpletest

Code

public static function parseTestClassAnnotations(\ReflectionClass $class) {
  $annotations = PHPUnit_Util_Test::parseTestMethodAnnotations($class
    ->getName())['class'];

  // @todo Enhance PHPUnit upstream to allow for custom @requires identifiers.
  // @see PHPUnit_Util_Test::getRequirements()
  // @todo Add support for 'PHP', 'OS', 'function', 'extension'.
  // @see https://www.drupal.org/node/1273478
  if (isset($annotations['requires'])) {
    foreach ($annotations['requires'] as $i => $value) {
      list($type, $value) = explode(' ', $value, 2);
      if ($type === 'module') {
        $annotations['requires']['module'][$value] = $value;
        unset($annotations['requires'][$i]);
      }
    }
  }
  return $annotations;
}