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 usage of PHPUnit mocks in MailHandlerTest
Proposed resolution
Following up on #3365331: [PHPUnit 10] Provide a static alternative to ConfigMapperManagerTest::providerTestHasTranslatable, replace usage of PHPUnit mocks with PHPSpec prophecies instead, wherever possible.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3441660
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3441660-phpunit-10-provide changes, plain diff MR !7573
Comments
Comment #2
longwaveComment #4
longwaveThis one was quite fiddly but got there in the end.
The change to ::getAuthenticatedMockMessage() is strange and I can't quite explain it. The mocked ContactFormInterface now fails its expectations if you leave it in place, but when I traced the code through
::getContactForm()
was never called in the authenticated user case, so the expectations were never met in the first place, unsure how this was passing before.Comment #5
longwave...and managed to refactor it further from here to make the dataprovider much easier to follow.
Comment #6
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis one was a little more but updates to use booleans and arrays vs MessageInterface does appear much cleaner. Will lean on the tests showing green that nothing broke.
LGTM
Comment #7
alexpottCommitted and pushed 54da986560 to 11.x and d404c50e5c to 10.3.x and 3781898992 to 10.2.x. Thanks!
Backported to 10.2.x to keep test coverage aligned.