Issue #2491915 by Berdir, miro_dietiker: Test @group detection fails for test classes with non-standard indendation
parent
fe2eecace0
commit
684602eacc
|
@ -312,7 +312,9 @@ class TestDiscovery {
|
|||
'name' => $classname,
|
||||
);
|
||||
$annotations = array();
|
||||
preg_match_all('/^ \* \@([^\s]*) (.*$)/m', $doc_comment, $matches);
|
||||
// Look for annotations, allow an arbitrary amount of spaces before the
|
||||
// * but nothing else.
|
||||
preg_match_all('/^[ ]*\* \@([^\s]*) (.*$)/m', $doc_comment, $matches);
|
||||
if (isset($matches[1])) {
|
||||
foreach ($matches[1] as $key => $annotation) {
|
||||
if (!empty($annotations[$annotation])) {
|
||||
|
@ -369,8 +371,10 @@ class TestDiscovery {
|
|||
|
||||
$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 ($line == ' *' || preg_match('/^ \* \@/', $line)) {
|
||||
if (preg_match('/^[ ]*\*$/', $line) || preg_match('/^[ ]*\* \@/', $line)) {
|
||||
break;
|
||||
}
|
||||
$summary[] = trim($line, ' *');
|
||||
|
|
|
@ -76,6 +76,45 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
",
|
||||
];
|
||||
|
||||
// Test with a different amount of leading spaces.
|
||||
$tests[] = [
|
||||
// Expected result.
|
||||
[
|
||||
'name' => 'Drupal\field\Tests\BulkDeleteTest',
|
||||
'group' => 'field',
|
||||
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\field\Tests\BulkDeleteTest',
|
||||
// Doc block.
|
||||
"/**
|
||||
* Bulk delete storages and fields, and clean up afterwards.
|
||||
*
|
||||
* @group field
|
||||
*/
|
||||
",
|
||||
];
|
||||
|
||||
// Make sure that a "* @" inside a string does not get parsed as an
|
||||
// annotation.
|
||||
$tests[] = [
|
||||
// Expected result.
|
||||
[
|
||||
'name' => 'Drupal\field\Tests\BulkDeleteTest',
|
||||
'group' => 'field',
|
||||
'description' => 'Bulk delete storages and fields, and clean up afterwards. * @',
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\field\Tests\BulkDeleteTest',
|
||||
// Doc block.
|
||||
"/**
|
||||
* Bulk delete storages and fields, and clean up afterwards. * @
|
||||
*
|
||||
* @group field
|
||||
*/
|
||||
",
|
||||
];
|
||||
|
||||
// Multiple @group annotations.
|
||||
$tests[] = [
|
||||
// Expected result.
|
||||
|
|
Loading…
Reference in New Issue