function PhpUnitTestDiscovery::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.
2 calls to PhpUnitTestDiscovery::getPhpunitTestSuite()
- PhpUnitTestDiscovery::getTestListLimitedToDirectory in core/
lib/ Drupal/ Core/ Test/ PhpUnitTestDiscovery.php - Returns a list of tests from a TestSuite object limited to a directory.
- TestDiscoveryTest::testGetPhpunitTestSuite in core/
tests/ Drupal/ Tests/ Core/ Test/ TestDiscoveryTest.php - Tests PhpUnitTestDiscovery::getPhpunitTestSuite().
File
-
core/
lib/ Drupal/ Core/ Test/ PhpUnitTestDiscovery.php, line 436
Class
- PhpUnitTestDiscovery
- Discovers available tests using the PHPUnit API.
Namespace
Drupal\Core\TestCode
public static function getPhpunitTestSuite(string $classname) : string|false {
if (preg_match('/Drupal\\\\Tests\\\\(\\w+)\\\\(\\w+)/', $classname, $matches)) {
if ($matches[1] === 'Component') {
return 'Unit-Component';
}
// 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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.