Problem/Motivation
TestCase::getMockClass() is removed from PHPUnit 10.
In PHPUnit 9.6, using getMockClass() will yield a deprecation error,
Therefore the use of the method needs to be replaced.
See https://github.com/sebastianbergmann/phpunit/issues/5064
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3322784-10.patch | 6.11 KB | mondrake |
| #7 | 3322784-7.patch | 5.05 KB | longwave |
| #6 | 3322784-6.patch | 4.23 KB | mondrake |
Comments
Comment #2
mondrakeComment #3
mondrakeComment #4
mondrakeHere's a patch replacing the deprecated method.
Comment #5
spokjeLook great, but you might have missed one occurence in
\Drupal\Tests\Core\Entity\EntityFieldManagerTest::setUpEntityTypeDefinitions()?Comment #6
mondrakeWoah. Thanks @Spokje.
Note to @mondrake: if you save the files after editing, your chances to get proper diffs increase...
Comment #7
longwaveSeems like a lot of this code isn't needed?
Comment #8
longwaveIn fact it seems that in some of the tests setUpEntityTypeManager() doesn't need to be called at all!
Comment #9
spokjeCould do with slightly less PHPCS errors, but seems like a nice clean-up :)
Comment #10
mondrakeComment #12
mondrakeComment #13
spokje- Reason why we're doing this is clearly stated in the IS.
- All issues were addressed.
- No remaining occurrences of
TestCase::getMockClass()found after applying the patch.- Green TestBot.
- Added Bonus: Code clean-up.
RTBC for me.
Comment #17
xjmWhen I see seemingly unnecessary test coverage like this I always wonder "why is it that way"? For all these tests, that's #2337191-9: Split up EntityManager into many services. The
getMockClass()usage as it stands was added in the original prototype in that issue, and it appears to have been copied to all those tests from the original one:I reviewed each instance and confirmed that
EntityTypeManagerTestdoes actually use it for something other than testinggetMockClass()itself, but that the others don't.Committed to 10.1.x, and cherry-picked to 10.0.x and 9.5.x as mostly a dead test code cleanup. Thanks!