- Issue created by @quietone
- 🇳🇿New Zealand quietone
Björn Brala (bbrala) commented in the coding standards meeting, #3456119: Coding Standards Meeting Tuesday 2024-06-18 2100 UTC → , that there is a rector for removing test from dataproviders, https://github.com/rectorphp/rector-phpunit/blob/main/docs/rector_rules_...
- 🇬🇧United Kingdom jonathan1055
The agreement and documenting of this standard has become more urgent in the last few weeks, because the PHPStan in contrib pipelines running 'next minor' (which is currently 11.2-dev) now report errors such as
----- --------------------------------------------------------------- Line tests/src/Functional/SchedulerTokenReplaceTest.php ------ --------------------------------------------------------------- 17 @dataProvider dataSchedulerTokenReplacement() related method not found. 🪪 phpunit.dataProviderMethod
I don't know what method name it is expecting, but whatever it is I guess this should be our new standard, to be documented in the Coding ld be. Probably it would be a new paragraph in php/php-coding-standards#naming →
- 🇬🇧United Kingdom jonathan1055
The link in #2 is broken. Any ideas where it was meant to point?
- 🇬🇧United Kingdom jonathan1055
I found the core issue that fixed the names - 📌 Fix PHPStan L1 errors "@dataProvider Foo related method not found." Fixed
But actually, PHPStan at level 1 is not actually checking any expected name of the data provider function. The warning above is when checking that the test function contains the expected tag
@dataProvider whateverYouCalledIt
but without the()
after the name.This could also be added into the new section of the standards page.
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Strong -1 from me
We don't enforce method names anywhere else, so I don't think enforcing one for data providers is appropriate - 🇬🇧United Kingdom jonathan1055
Yes, the urgency which I stated in #3 was in fact not the case. The PHPStan warning is only complaining about the matching
@dataProvider
tag in the test function's doc block. - 🇳🇿New Zealand quietone
We do have a standard for method/function names and class names which core violates. I am not convinced that Drupal should not enforce it's own standard.
As for core, they are not enforced because a core committer has pushed back on implementing the naming standard for methods 📌 Use 'Drupal.NamingConventions.ValidFunctionName' in core/tests RTBC . Instead of discussing that I chose to work on implementing other standards.