You are here

trait CacheTestTrait in MongoDB 7

Class CacheTest provides getInfo() replacement.

@package Drupal\mongodb_cache

Hierarchy

File

mongodb_cache/src/Tests/CacheTestTrait.php, line 10

Namespace

Drupal\mongodb_cache\Tests
View source
trait CacheTestTrait {

  /**
   * Declare the test to Simpletest.
   *
   * @return string[]
   *   The test information as expected by Simpletest for Drupal 7.
   *
   * @throws \ReflectionException
   *   Unlikely.
   */
  public static function getInfo() {
    $class = get_called_class();
    $reflected = new \ReflectionClass($class);
    $name = $reflected
      ->getShortName();
    $comment = $reflected
      ->getDocComment();
    $matches = [];
    $error_arg = [
      '@class' => $class,
    ];
    $sts = preg_match('/^\\/\\*\\*[\\s]*\\n[\\s]*\\*[\\s]([^\\n]*)/s', $comment, $matches);
    $description = $sts ? $matches[1] : strtr("MongoDB: FIXME Missing name for class @class", $error_arg);
    $sts = preg_match('/^[\\s]+\\*[\\s]+@group[\\s]+(.*)$/m', $comment, $matches);
    $group = $sts ? $matches[1] : strtr("MongoDB: FIXME Missing group for class @class.", $error_arg);
    return [
      'name' => $name,
      'description' => $description,
      'group' => $group,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheTestTrait::getInfo public static function Declare the test to Simpletest.