Issue #2949363 by vaplas, Mile23, timmillwood, alexpott, Lendude: Impossible to make trigger_error in some files without test fails

8.6.x
Alex Pott 2018-05-18 08:18:06 +01:00
parent e551206954
commit f22c3b0952
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
2 changed files with 16 additions and 1 deletions

View File

@ -325,7 +325,7 @@ class TestDiscovery {
* If the class does not have a @group annotation.
*/
public static function getTestInfo($classname, $doc_comment = NULL) {
if (!$doc_comment) {
if ($doc_comment === NULL) {
$reflection = new \ReflectionClass($classname);
$doc_comment = $reflection->getDocComment();
}

View File

@ -385,6 +385,21 @@ EOF;
return $data;
}
/**
* Ensure that classes are not reflected when the docblock is empty.
*
* @covers ::getTestInfo
*/
public function testGetTestInfoEmptyDocblock() {
// If getTestInfo() performed reflection, it won't be able to find the
// class we asked it to analyze, so it will throw a ReflectionException.
// We want to make sure it didn't do that, because we already did some
// analysis and already have an empty docblock. getTestInfo() will throw
// MissingGroupException because the annotation is empty.
$this->setExpectedException(MissingGroupException::class);
TestDiscovery::getTestInfo('Drupal\Tests\simpletest\ThisTestDoesNotExistTest', '');
}
}
class TestTestDiscovery extends TestDiscovery {