Problem/Motivation
PHPUnit 10 deprecates use of non-static @dataProvider methods. This means that @dataProvider methods can no longer make calls to non-static methods. Any non-static call ($this->someMethod()) needs to be replaced by a call to a static alternative (static::someOtherMethod()), that would have to be implemented if not available.
In this issue, focus on replacing ConfigMapperManagerTest::providerTestHasTranslatable()
Proposed resolution
I cannot find an easy way to use PHPUnit mocks in data providers when they're static. Here I suggest to convers usage of a PHPUnit mocks to PHPSpec prophecies instead.
Let's see how this goes and then work on others.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3365331-2.patch | 6.21 KB | mondrake |
Comments
Comment #2
mondrakeComment #3
smustgrave commentedWoo, assuming since the tests were green your approach worked? I feel there could be a lot of these though. Should they be broken up across a few tickets? Might be easier to review and get in.
Comment #4
mondrake@smustgrave why NW then? What work is needed on this issue?
If this approach (replacing PHPUnit mocks with prophecies where possible) is endorsed, then this may become a recommended way forward that we could summarize in https://www.drupal.org/node/3365413. But that should happen after commit IMHO.
We need that endorsment and hopefully scope guidance on how to address the rest from a committer. Scope discussion in this type of things tend to take longer than doing the conversions themselves...
BTW, a list of dataprovider methods that need the conversion can be seen in the latest test runs of the MR in #3353210: [PHPUnit 10] @dataProvider methods must be declared static and public.
Comment #5
spokjeWould the tag
Needs framework manager reviewhelp here?If we have a blessing on the approach taken here, we can then either commit this one as the first of many others. or (which I see incoming) do multiple/all of them in one/multiple issues.
Comment #6
smustgrave commentedThat was my mistake didn’t mean to change the status
Comment #7
mondrakeNo worries
Comment #8
smustgrave commentedMarking this to get in front of committer eyes.
Comment #9
catchFor me this diff looks a lot cleaner than the original, so seems like a straightforward change.
Agreed we should document the pattern somewhere but shouldn't hold up the conversion.
Comment #11
mondrakeThanks! Filed #3368713: Change @dataprovider to static in CommentLinkBuilderTest to follow up with the rest.