function TestDiscovery::parseTestClassSummary
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\TestDiscovery::parseTestClassSummary()
- 10 core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\TestDiscovery::parseTestClassSummary()
- 11.x core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\TestDiscovery::parseTestClassSummary()
Parses the phpDoc summary line of a test class.
Parameters
string $doc_comment: The documentation comment.
Return value
string The parsed phpDoc summary line. An empty string is returned if no summary line can be parsed.
1 call to TestDiscovery::parseTestClassSummary()
- 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 398
Class
- TestDiscovery
- Discovers available tests.
Namespace
Drupal\Core\TestCode
public static function parseTestClassSummary($doc_comment) {
// Normalize line endings.
$doc_comment = preg_replace('/\\r\\n|\\r/', '\\n', $doc_comment);
// Strip leading and trailing doc block lines.
$doc_comment = substr($doc_comment, 4, -4);
$lines = explode("\n", $doc_comment);
$summary = [];
// Add every line to the summary until the first empty line or annotation
// is found.
foreach ($lines as $line) {
if (preg_match('/^[ ]*\\*$/', $line) || preg_match('/^[ ]*\\* \\@/', $line)) {
break;
}
$summary[] = trim($line, ' *');
}
return implode(' ', $summary);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.