You are here

public static function TestDiscovery::parseTestClassAnnotations in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\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/lib/Drupal/Core/Test/TestDiscovery.php, line 427

Class

TestDiscovery
Discovers available tests.

Namespace

Drupal\Core\Test

Code

public static function parseTestClassAnnotations(\ReflectionClass $class) {
  $annotations = 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;
}