Problem/Motivation

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

Some uses were removed as part of #3217904: [meta] Support PHPUnit 10 in Drupal 11, but there's a relevant number of places where this is still used.

Proposed resolution

- replace in class ControllerBaseTest

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3464271

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

Title: [meta] Method getMockForAbstractClass() of class PHPUnit\Framework\TestCase is deprecated in PHPUnit 10 - replace in class ControllerBaseTest » Method getMockForAbstractClass() of class PHPUnit\Framework\TestCase is deprecated in PHPUnit 10 - replace in class ControllerBaseTest
mondrake’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems straight forward

Wonder if there are other instances that could use StubControllerBase()?

mondrake’s picture

Status: Reviewed & tested by the community » Needs review

Wonder if there are other instances that could use StubControllerBase()?

Found one in the same test, but no further.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Nice!

catch’s picture

Status: Reviewed & tested by the community » Needs work

One question on the MR.

mondrake’s picture

Status: Needs work » Needs review

#8 copying here reply to the same comment in #3464213: Method getMockForAbstractClass() of class PHPUnit\Framework\TestCase is deprecated in PHPUnit 10 - replace in Plugin component tests:

I have seen multiple classes/namespaces in the same file having problems with Rector, see for instance here https://www.drupal.org/project/drupal/issues/3446693 where rector could not write 'use' imports, FQCN are written instead, and we'll be having to manage that manually.

So if it's not a big problem I'd rather go for a separate file, which IMHO is also more gentle to autoloading and readibility.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Believe 1 question has been answered.

  • catch committed 61622bbf on 11.0.x
    Issue #3464271 by mondrake, smustgrave: Method getMockForAbstractClass...

  • catch committed 5ac4f96a on 11.x
    Issue #3464271 by mondrake, smustgrave: Method getMockForAbstractClass...
catch’s picture

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

Yeah that's fair enough. I'm a bit concerned we'll eventually end up with classes for tests that have subsequently been refactored to not use the classes, but we'll eventually figure that out if it happens.

Committed/pushed to 11.x and cherry-picked to 11.0.x, thanks!

Status: Fixed » Closed (fixed)

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