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
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:
- 3433088-method-getmockforabstractclass-of
changes, plain diff MR !7174
Comments
Comment #2
mondrakeComment #4
mondrakeLet'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.
Comment #5
mondrakeComment #6
spokjeLike 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...Comment #7
mondrakeThanks @Spokje, the first two OK, indeed; the last three in fact are misleading since in each file
SqlContentEntityStorageTestEntityInterfaceis 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.
Comment #8
mondrakeComment #9
spokjeThanks @mondrake, I'll take a 50% success rate any day...
RTBC for me now.
Comment #10
alexpottCommitted 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.