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
Fix ignored test with duplicate key in dataprovider #3444
Conversation
1074f9b
to
e885a77
Compare
Codecov Report
@@ Coverage Diff @@
## master #3444 +/- ##
=========================================
Coverage 82.15% 82.15%
- Complexity 3579 3580 +1
=========================================
Files 143 143
Lines 9395 9395
=========================================
Hits 7718 7718
Misses 1677 1677
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #3444 +/- ##
============================================
+ Coverage 82.15% 82.16% +0.01%
- Complexity 3580 3581 +1
============================================
Files 143 143
Lines 9398 9404 +6
============================================
+ Hits 7721 7727 +6
Misses 1677 1677
Continue to review full report at Codecov.
|
IMHO, it should throw an exception, as this is certainly a mistake and it is currently not working. |
0654c1d
to
b43d0a2
Compare
reverted to exception instead of fallback |
Some people in this PHPStan issue think having the same key twice in a Generator is perfectly valid and that therefore, it's a bug in PHPUnit if it's not working properly. |
It's indeed a PHPUnit bug that it silently drops provided entries with duplicate names. |
Also I think expeption is not the solution, at least when duplicate keys come from different data providers. It should be fixed (i.e. by constraining origin data provider), not prevented. |
The key in the dataprovider is used to help the developer to find quickly which datset is responsible of a test failure. If you have 2 dataproviders with the same Key (or the same key repeated twice in a dataprovider) How would that key help you to find the responsible of the failure? Each time I had one, it was a typo or a copy/paste from an other rule. Do you have a valid usecase? I'm agree with the phpstan thread, that duplicate key are valid in PHP. But in the case of phpunit dataprovider, it don't make sense and should be reported to the developer. |
d7c3499
to
887793b
Compare
@jderusse You can show both data provider name and key. |
@Majkl578 Concatening the dataprovider with the key in order to, both, give extra information and allowing duplicate keys accross dataproviders is not the purpose of that PR (warn the developer about silently ignored tests), and could be addressed in a dedicated PR as it won't fixes duplicate keys in the same dataprovider. |
887793b
to
6ab71b2
Compare
I only answered your own question. |
Merged manually, thanks. |
With generators dataProvider may have duplicate keys.
This PR throws an exception when the dataprovider contains duplicate keys.