Problem/Motivation

Method getMockForAbstractClass() of class PHPUnit\Framework\TestCase is deprecated in PHPUnit 10

Proposed resolution

In this issue, do a first step and target the usage of the method to create mocks against interfaces.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3433088

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:

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Version: 10.3.x-dev » 11.x-dev

mondrake’s picture

Title: Method getMockForAbstractClass() of class PHPUnit\Framework\TestCase is deprecated in PHPUnit 10 » Method getMockForAbstractClass() of class PHPUnit\Framework\TestCase is deprecated in PHPUnit 10 - Step 1 interfaces
Status: Active » Needs review

Let's do a first step and target the usage of the method to create mocks against interfaces - which is nonsense (probably leftover from earlier conversions/creation of interfaces): when you mock an interface you create anyway doubles for all the methods declared on the interface. No abstract classes here, really.

mondrake’s picture

Issue summary: View changes
spokje’s picture

Status: Needs review » Needs work

Like the approach, like the MR, but we've might have a few stragglers (at least, if I understand the scope correctly):

- \Drupal\Tests\Component\Plugin\Discovery\StaticDiscoveryDecoratorTest::testGetDefinition: https://git.drupalcode.org/project/drupal/blob/b73c68de45491739c0752d859... and https://git.drupalcode.org/project/drupal/blob/b73c68de45491739c0752d859...
- \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testLoadMultiplePersistentCached: https://git.drupalcode.org/project/drupal/blob/654b1f2074ea90b75a8750f2b...
- \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testLoadMultipleNoPersistentCache: https://git.drupalcode.org/project/drupal/blob/654b1f2074ea90b75a8750f2b...
- \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testLoadMultiplePersistentCacheMiss: https://git.drupalcode.org/project/drupal/blob/654b1f2074ea90b75a8750f2b...

mondrake’s picture

Assigned: Unassigned » mondrake

Thanks @Spokje, the first two OK, indeed; the last three in fact are misleading since in each file SqlContentEntityStorageTestEntityInterface is an abstract class defined at the end of each file... very confusing, for that one we need an issue of its own.

Fixing the first two.

mondrake’s picture

Assigned: mondrake » Unassigned
Status: Needs work » Needs review
spokje’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @mondrake, I'll take a 50% success rate any day...

RTBC for me now.

alexpott’s picture

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

Committed and pushed 35a8fc6dec to 11.x and dd091490e5 to 10.3.x and 5d04815308 to 10.2.x. Thanks!

Backported to 10.2.x to keep tests aligned.

  • alexpott committed 5d048153 on 10.2.x
    Issue #3433088 by mondrake, Spokje: Method getMockForAbstractClass() of...

  • alexpott committed dd091490 on 10.3.x
    Issue #3433088 by mondrake, Spokje: Method getMockForAbstractClass() of...

  • alexpott committed 35a8fc6d on 11.x
    Issue #3433088 by mondrake, Spokje: Method getMockForAbstractClass() of...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.