Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TestDiscovery.php

function TestDiscovery::getPhpunitTestSuite

Determines the phpunit testsuite for a given classname, based on namespace.

Parameters

string $classname: The test classname.

Return value

string|false The testsuite name or FALSE if its not a phpunit test.

1 call to TestDiscovery::getPhpunitTestSuite()
TestDiscovery::getTestInfo in core/lib/Drupal/Core/Test/TestDiscovery.php
Retrieves information about a test class for UI purposes.

File

core/lib/Drupal/Core/Test/TestDiscovery.php, line 400

Class

TestDiscovery
Discovers available tests.

Namespace

Drupal\Core\Test

Code

public static function getPhpunitTestSuite($classname) {
    if (preg_match('/Drupal\\\\Tests\\\\(\\w+)\\\\(\\w+)/', $classname, $matches)) {
        // This could be an extension test, in which case the first match will be
        // the extension name. We assume that lower-case strings are module names.
        if (strtolower($matches[1]) == $matches[1]) {
            return $matches[2];
        }
        return 'Unit';
    }
    elseif (preg_match('/Drupal\\\\(\\w*)Tests\\\\/', $classname, $matches)) {
        if ($matches[1] == '') {
            return 'Unit';
        }
        return $matches[1];
    }
    return FALSE;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal