Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator yielding keys that are neither integer or string leads to hard-to-understand error message when used as data provider #4625

Closed
BackEndTea opened this issue Mar 17, 2021 · 0 comments · Fixed by #5942
Labels
feature/data-provider Data Providers feature/test-runner CLI test runner type/bug Something is broken

Comments

@BackEndTea
Copy link
Contributor

BackEndTea commented Mar 17, 2021

Q A
PHPUnit version 9.5.3
PHP version 7.4.16
Installation Method Composer

Summary

When a non int/string key is provided from a generator dataprovider you get an error. This is to be expected. However the error does not make it obvious what went wrong.

Current behavior

vendor/bin/phpunit --debug
Warning: array_key_exists(): The first argument should be either a string or an integer in /project/vendor/phpunit/phpunit/src/Util/Annotation/DocBlock.php on line 438

How to reproduce

Create a dataprovider that has a non int/string key. and use it in a test (This is valid in PHP btw https://3v4l.org/sbeOf)

Expected behavior

I'd expect to get an error with a clear message, telling me that i'm using a non int/string key in a dataprovider, which is not supported. Prehaps with the type i am using.

Because the error mentions Util/Annotation/DocBlock.php we initially though phpunit was failing due to a wrong annotation somewhere.

@BackEndTea BackEndTea added the type/bug Something is broken label Mar 17, 2021
@sebastianbergmann sebastianbergmann changed the title A non int/string key from a generator dataprovider gives a hard to bedug error Generator yielding key that are neither integer or string leads to hard-to-understand error message when used as data provider Sep 8, 2024
@sebastianbergmann sebastianbergmann changed the title Generator yielding key that are neither integer or string leads to hard-to-understand error message when used as data provider Generator yielding keys that are neither integer or string leads to hard-to-understand error message when used as data provider Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/data-provider Data Providers feature/test-runner CLI test runner type/bug Something is broken
Projects
None yet
2 participants