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

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave created an issue. See original summary.

longwave’s picture

Title: [PHPUnit 10] Provide a static alternative to @dataproviders using PHPUnit mocks in CommentLinkBuilderTest and MailHandlerTest » [PHPUnit 10] Provide a static alternative to @dataproviders using PHPUnit mocks in MailHandlerTest

longwave’s picture

Status: Active » Needs review
Issue tags: -Needs followup

This 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.

longwave’s picture

...and managed to refactor it further from here to make the dataprovider much easier to follow.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

This 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

alexpott’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 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.

  • alexpott committed 37818989 on 10.2.x
    Issue #3441660 by longwave: [PHPUnit 10] Provide a static alternative to...

  • alexpott committed d404c50e on 10.3.x
    Issue #3441660 by longwave: [PHPUnit 10] Provide a static alternative to...

  • alexpott committed 54da9865 on 11.x
    Issue #3441660 by longwave: [PHPUnit 10] Provide a static alternative to...