phpunit
phpunit copied to clipboard
Add (opt-in?) support for data providers returning an empty iterable
When the data provider generates test cases based on some external sources, it might happen that there is no cases to be tested.
As PHPUnit triggers an error when a data provider returns an empty iterable (technically when _all providers configured for a test do it, so that the merged result is empty, but most tests don't use multiple data providers), such projects end up doing hacks where the yield a single case in the data provider with special values that the test detects to call markTestSkipped.
Examples:
- async-aws having a test enforcing that modified services include updates to their changelog (a PR might not modify any of the files requiring changelog entries): https://github.com/async-aws/aws/pull/1983
- the
IntegrationTestCaseof Twig has a dedicated test running the "legacy" test cases, where deprecations are ignored. A project running Twig integration tests might not have any legacy tests: https://github.com/twigphp/Twig/blob/d58c8be15ddbda8532df7ba5de283b51dd8939d2/src/Test/IntegrationTestCase.php#L191
It would be great to have a way to opt-out of that error, marking the tests as skipped due to no provided data instead.