Skip to content

Commit d13b2f6

Browse files
Closes #2392
1 parent ced3792 commit d13b2f6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

ChangeLog-4.8.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ All notable changes of the PHPUnit 4.8 release series are documented in this fil
99
* Fixed [#1983](https://github.com/sebastianbergmann/phpunit/pull/1983): Tests with `@expectedException` annotation cannot be skipped
1010
* Fixed [#2275](https://github.com/sebastianbergmann/phpunit/pull/2275): Invalid UTF-8 characters can lead to missing output
1111
* Fixed [#2331](https://github.com/sebastianbergmann/phpunit/issues/2331): Boolean environment variable values specified in XML get mangled
12+
* Fixed [#2392](https://github.com/sebastianbergmann/phpunit/issues/2392): Empty (but valid) data provider should skip the test
1213
* Fixed [#2431](https://github.com/sebastianbergmann/phpunit/issues/2431): `assertArraySubset()` does not support `ArrayAccess`
1314

1415
## [4.8.32] - 2017-01-22

src/Util/Test.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,15 @@ public static function getProvidedData($className, $methodName)
370370
{
371371
$reflector = new ReflectionMethod($className, $methodName);
372372
$docComment = $reflector->getDocComment();
373-
$data = null;
374373

375-
if ($dataProviderData = self::getDataFromDataProviderAnnotation($docComment, $className, $methodName)) {
376-
$data = $dataProviderData;
374+
$data = self::getDataFromDataProviderAnnotation($docComment, $className, $methodName);
375+
376+
if ($data === null) {
377+
$data = self::getDataFromTestWithAnnotation($docComment);
377378
}
378379

379-
if ($testWithData = self::getDataFromTestWithAnnotation($docComment)) {
380-
$data = $testWithData;
380+
if (is_array($data) && empty($data)) {
381+
throw new PHPUnit_Framework_SkippedTestError;
381382
}
382383

383384
if ($data !== null) {
@@ -463,6 +464,7 @@ private static function getDataFromDataProviderAnnotation($docComment, $classNam
463464
public static function getDataFromTestWithAnnotation($docComment)
464465
{
465466
$docComment = self::cleanUpMultiLineAnnotation($docComment);
467+
466468
if (preg_match(self::REGEX_TEST_WITH, $docComment, $matches, PREG_OFFSET_CAPTURE)) {
467469
$offset = strlen($matches[0][0]) + $matches[0][1];
468470
$annotationContent = substr($docComment, $offset);

0 commit comments

Comments
 (0)