"Empty data set provided by data provider"
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- php
- Domain
- testing-qa
Research direction
Start with the BarTest.php reproducer and run it against the PHPUnit 9, 10, 11, 12, and 13 versions shown in the report. Read the referenced DataProvider.php and TestBuilder.php paths to trace the empty-provider handling, then add regression coverage for the observed behavior; done means the case is consistently handled without the reported error.
Written by the indexing model from the issue text.
Description
Starting with PHPUnit 10 a dataprovider is not allowed to provide a empty array.
<?php
use PHPUnit\Framework\Attributes\DataProvider;
class BarTest extends PHPUnit\Framework\TestCase
{
/**
* @dataProvider provideData
*/
#[DataProvider("provideData")]
public function testBar() {
self::assertTrue(true);
}
static public function provideData(): iterable {
return [];
}
}
real world example in phpstan-doctrine
PHPUnit 9 skips and warns
➜ phpunit git:(9.6) ✗ php phpunit BarTest.php
PHPUnit 9.6.29-15-g3ee3d102e by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.27
Configuration: /Users/staabm/workspace/phpunit/phpunit.xml
S 1 / 1 (100%)
Time: 00:00.002, Memory: 6.00 MB
There was 1 skipped test:
1) BarTest::testBar
Test for BarTest::testBar skipped by data provider
PHPUnit\Framework\SkippedTestError: <no message>
/Users/staabm/workspace/phpunit/src/Util/Annotation/DocBlock.php:285
/Users/staabm/workspace/phpunit/src/Util/Test.php:329
/Users/staabm/workspace/phpunit/src/Framework/TestBuilder.php:72
/Users/staabm/workspace/phpunit/src/Framework/TestSuite.php:891
/Users/staabm/workspace/phpunit/src/Framework/TestSuite.php:232
/Users/staabm/workspace/phpunit/src/Runner/BaseTestRunner.php:133
/Users/staabm/workspace/phpunit/src/TextUI/Command.php:121
/Users/staabm/workspace/phpunit/src/TextUI/Command.php:99
/Users/staabm/workspace/phpunit/src/Framework/Assert.php:2895
/Users/staabm/workspace/phpunit/src/Framework/SkippedTestCase.php:66
/Users/staabm/workspace/phpunit/src/Framework/TestCase.php:1223
/Users/staabm/workspace/phpunit/src/Framework/TestResult.php:729
/Users/staabm/workspace/phpunit/src/Framework/TestCase.php:973
/Users/staabm/workspace/phpunit/src/Framework/TestSuite.php:685
/Users/staabm/workspace/phpunit/src/Framework/TestSuite.php:685
/Users/staabm/workspace/phpunit/src/TextUI/TestRunner.php:651
/Users/staabm/workspace/phpunit/src/TextUI/Command.php:146
/Users/staabm/workspace/phpunit/src/TextUI/Command.php:99
OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 0, Skipped: 1.
PHPUnit 10 errors
➜ phpunit git:(10.5) ✗ php phpunit BarTest.php
PHPUnit 10.5.58-15-gc66b7d664 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.27
Configuration: /Users/staabm/workspace/phpunit/phpunit.xml
There was 1 PHPUnit error:
1) BarTest::testBar
The data provider specified for BarTest::testBar is invalid
Empty data set provided by data provider
/Users/staabm/workspace/phpunit/src/Metadata/Api/DataProvider.php:76
/Users/staabm/workspace/phpunit/src/Framework/TestBuilder.php:44
/Users/staabm/workspace/phpunit/src/Framework/TestSuite.php:511
/Users/staabm/workspace/phpunit/src/Framework/TestSuite.php:139
/Users/staabm/workspace/phpunit/src/TextUI/Configuration/TestSuiteBuilder.php:122
/Users/staabm/workspace/phpunit/src/TextUI/Configuration/TestSuiteBuilder.php:58
/Users/staabm/workspace/phpunit/src/TextUI/Application.php:394
/Users/staabm/workspace/phpunit/src/TextUI/Application.php:114
/Users/staabm/workspace/phpunit/BarTest.php:11
--
There was 1 PHPUnit test runner warning:
1) No tests found in class "BarTest".
No tests executed!
PHPUnit11,12,13 errors
➜ phpunit git:(11.5) ✗ php phpunit BarTest.php
PHPUnit 11.5.42-27-g32e5fd8bc by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.27
Configuration: /Users/staabm/workspace/phpunit/phpunit.xml
There was 1 PHPUnit error:
1) BarTest::testBar
The data provider specified for BarTest::testBar is invalid
Empty data set provided by data provider
/Users/staabm/workspace/phpunit/src/Metadata/Api/DataProvider.php:75
/Users/staabm/workspace/phpunit/src/Framework/TestBuilder.php:47
/Users/staabm/workspace/phpunit/src/Framework/TestSuite.php:508
/Users/staabm/workspace/phpunit/src/Framework/TestSuite.php:109
/Users/staabm/workspace/phpunit/src/TextUI/Configuration/TestSuiteBuilder.php:121
/Users/staabm/workspace/phpunit/src/TextUI/Configuration/TestSuiteBuilder.php:58
/Users/staabm/workspace/phpunit/src/TextUI/Application.php:412
/Users/staabm/workspace/phpunit/src/TextUI/Application.php:182
/Users/staabm/workspace/phpunit/BarTest.php:11
--
There was 1 PHPUnit test runner warning:
1) No tests found in class "BarTest".
No tests executed!
- Dominant language
- PHP
- Stars
- 544
- Forks
- 58
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 5
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpstan/phpstan-phpunit
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
phpstan/phpstan-phpunit#332 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-phpunit#321 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-phpunit#309 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
phpstan/phpstan-phpunit#299 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
phpstan/phpstan-phpunit#292 · 3 comments ·
All issues in phpstan/phpstan-phpunit
Similar issues
-
jira-created
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
nunomaduro/phpinsights#745 ·
-
status/awaiting_triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
WordPress/plugin-check#1486 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
az-digital/az_quickstart#6019 ·