Problem/Motivation

PHPUnit 12.5.0 started throwing notices when mocks do not configure expectations, e.g.

* No expectations were configured for the mock object for \Drupal\comment\CommentManagerInterface. You should refactor your test code and use a test stub instead.

Proposed resolution

In this issue, fix tests in the unit-component suite.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3561844

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

Status: Active » Needs review
mondrake’s picture

Replied inline.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

I don't have any feedback. This is a pretty small collection of changes and they're pretty straightforward. The response to the earlier feedback is accurate in my opinion. So, since the tests are still passing with the changes I'm going to set this as RTBC.

mondrake’s picture

dcam’s picture

I've pre-emptively directed people to switch to stubs in one or two reviews over the last couple of weeks so we have fewer to convert later on.

mondrake’s picture

The two blog posts indicated in the upstream issue enlighten about the rationale. Alas, there are about 1.7k calls to createMock() in current tests, and that means a lot of work ahead...

geek-merlin’s picture

Maybe work for Rector?

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Reviewed & tested by the community

rebased

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new1.86 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: +no-needs-review-bot

bot fluke

longwave’s picture

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

Committed and pushed ec6a5fb5aed to main and 57c568c5dd3 to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • longwave committed 57c568c5 on 11.x
    test: #3561844 Refactor tests to use stubs instead of mocks where mocks...

  • longwave committed ec6a5fb5 on main
    test: #3561844 Refactor tests to use stubs instead of mocks where mocks...

Status: Fixed » Closed (fixed)

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