Unverified Commit 7c6f4aec authored by alexpott's avatar alexpott

Issue #2428753 by borisson_, daffie, dawehner, franksj: Do not allow PHPUnit...

Issue #2428753 by borisson_, daffie, dawehner, franksj: Do not allow PHPUnit tests to test an interface
parent f42257ba
......@@ -161,7 +161,7 @@ public function testDefaultRevision() {
}
/**
* @covers \Drupal\Core\Entity\RevisionableInterface::setNewRevision
* @covers \Drupal\Core\Entity\ContentEntityBase::setNewRevision
*/
public function testSetNewRevision() {
$user = $this->createUser();
......
......@@ -42,7 +42,7 @@ private function fail(TestCase $test, $message) {
* TRUE if the class exists, FALSE otherwise.
*/
private function classExists($class) {
return class_exists($class, TRUE) || trait_exists($class, TRUE) || interface_exists($class, TRUE);
return class_exists($class, TRUE) || trait_exists($class, TRUE);
}
/**
......@@ -71,7 +71,10 @@ private function checkValidCoversForTest(TestCase $test) {
$default_class = reset($annotations['class']['coversDefaultClass']);
// Check whether the default class exists.
$valid_default_class = $this->classExists($default_class);
if (!$valid_default_class) {
if (!$valid_default_class && interface_exists($default_class)) {
$this->fail($test, "@coversDefaultClass refers to an interface '$default_class' and those can not be tested.");
}
elseif (!$valid_default_class) {
$this->fail($test, "@coversDefaultClass does not exist '$default_class'");
}
}
......@@ -105,6 +108,9 @@ private function checkValidCoversForTest(TestCase $test) {
$this->fail($test, "@covers invalid syntax: Needs '::' or class does not exist in $covers");
return;
}
elseif (interface_exists($class)) {
$this->fail($test, "@covers refers to an interface '$class' and those can not be tested.");
}
else {
$this->fail($test, '@covers class does not exist ' . $class);
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment