Skip to content

Commit 8cd8ff0

Browse files
Allow @Covers annotation on interfaces.
1 parent d481a7e commit 8cd8ff0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

PHP/CodeCoverage/Util.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,12 @@ protected static function resolveCoversToReflectionObjects($coveredElement)
184184
$classes = array($className);
185185

186186
foreach ($classes as $className) {
187-
if (!class_exists($className)) {
188-
throw new RuntimeException(
187+
if (!class_exists($className) &&
188+
!interface_exists($className)) {
189+
throw new PHPUnit_Framework_Exception(
189190
sprintf(
190-
'Trying to @cover not existing class "%s".',
191+
'Trying to @cover not existing class or ' .
192+
'interface "%s".',
191193
$className
192194
)
193195
);
@@ -223,9 +225,10 @@ protected static function resolveCoversToReflectionObjects($coveredElement)
223225
$classes = array($className);
224226

225227
foreach ($classes as $className) {
226-
if (!(class_exists($className) &&
228+
if (!((class_exists($className) ||
229+
interface_exists($className)) &&
227230
method_exists($className, $methodName))) {
228-
throw new RuntimeException(
231+
throw new PHPUnit_Framework_Exception(
229232
sprintf(
230233
'Trying to @cover not existing method "%s::%s".',
231234
$className,
@@ -261,10 +264,12 @@ class_parents($coveredElement)
261264
}
262265

263266
foreach ($classes as $className) {
264-
if (!class_exists($className)) {
265-
throw new RuntimeException(
267+
if (!class_exists($className) &&
268+
!interface_exists($className)) {
269+
throw new PHPUnit_Framework_Exception(
266270
sprintf(
267-
'Trying to @cover not existing class "%s".',
271+
'Trying to @cover not existing class or ' .
272+
'interface "%s".',
268273
$className
269274
)
270275
);

0 commit comments

Comments
 (0)