summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2018-05-18 07:18:06 (GMT)
committerAlex Pott2018-05-18 07:18:06 (GMT)
commitf22c3b0952f9bedf5cacf0a6c5a8bd1142119d71 (patch)
tree16a13c1ee1b3e92014bbcbb11f15ab3abbb51447
parente551206954fe8ed16c9b0894c0cd17beeaf4335d (diff)
Issue #2949363 by vaplas, Mile23, timmillwood, alexpott, Lendude: Impossible to make trigger_error in some files without test fails
-rw-r--r--core/modules/simpletest/src/TestDiscovery.php2
-rw-r--r--core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php15
2 files changed, 16 insertions, 1 deletions
diff --git a/core/modules/simpletest/src/TestDiscovery.php b/core/modules/simpletest/src/TestDiscovery.php
index 1326946..219106e 100644
--- a/core/modules/simpletest/src/TestDiscovery.php
+++ b/core/modules/simpletest/src/TestDiscovery.php
@@ -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();
}
diff --git a/core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php b/core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php
index 625297e..8b00bb4 100644
--- a/core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php
+++ b/core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php
@@ -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 {