getTestInfo example

// Prevent expensive class loader lookups for each reflected test class by     // registering the complete classmap of test classes to the class loader.     // This also ensures that test classes are loaded from the discovered     // pathnames; a namespace/classname mismatch will throw an exception.     $this->classLoader->addClassMap($classmap);

    foreach ($classmap as $classname => $pathname) {
      $finder = MockFileFinder::create($pathname);
      $parser = new StaticReflectionParser($classname$finder, TRUE);
      try {
        $info = static::getTestInfo($classname$parser->getDocComment());
      }
      catch (MissingGroupException $e) {
        // If the class name ends in Test and is not a migrate table dump.         if (preg_match('/Test$/', $classname) && !str_contains($classname, 'migrate_drupal\Tests\Table')) {
          throw $e;
        }
        // If the class is @group annotation just skip it. Most likely it is an         // abstract class, trait or test fixture.         continue;
      }
      foreach ($info['groups'] as $group) {
        
/** * @coversDefaultClass \Drupal\Core\Test\TestDiscovery * @group Test */
class TestDiscoveryTest extends UnitTestCase {

  /** * @covers ::getTestInfo * @dataProvider infoParserProvider */
  public function testTestInfoParser($expected$classname$doc_comment = NULL) {
    $info = TestDiscovery::getTestInfo($classname$doc_comment);
    $this->assertEquals($expected$info);
  }

  public function infoParserProvider() {
    // A module provided unit test.     $tests[] = [
      // Expected result.       [
        'name' => static::class,
        'group' => 'Test',
        'groups' => ['Test'],
        
Home | Imprint | This part of the site doesn't use cookies.