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.

Also, the $this->any() expectation is deprecated - a change that will be released in version 12.5.5. This is because the any() expectation is equivalent to having no expectation. Instances of expects($this->any()) should be removed, either by deletion or conversion to a more specific number of expectations.

Steps to reproduce

  1. Require PHPUnit 12 with Composer.
  2. Fix compatibility issues with PHPUnit 12 by applying this patch.
  3. Run the Unit tests for a module with --display-phpunit-notices.
  4. Observe the PHPUnit notices that occur.

Proposed resolution

Fix instances in the Serialization module.

Remaining tasks

Information on how to review these issues and the types of changes you're likely to find in them is included in the parent issue's comments.

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3567157

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

dcam created an issue. See original summary.

dcam’s picture

Status: Active » Needs review

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.

dcam’s picture

Issue summary: View changes
smustgrave’s picture

Left a question on the MR.

dcam’s picture

I responded to the question.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Rest of the changes LGTM, following the same script I did for the other ones..

dcam’s picture

Serialization is not affected by the new deprecation in PHPUnit 12.5.11. This issue can stay RTBC.

godotislate’s picture

Status: Reviewed & tested by the community » Needs work

1 comment on the MR.

dcam’s picture

Status: Needs work » Needs review

Feedback was addressed. The failing test is in the list of known, intermittent test failures.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Feedback from godoislate appears to be addressed

catch’s picture

Status: Reviewed & tested by the community » Fixed

As with other MRs, this is exposing some test oddities that we might want to revisit later, but I'm happy that it's improving things overall, so we shouldn't block PHPUnit 12 on further refactoring. Would also make the MRs harder to review.

Committed/pushed to main, 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.

  • catch committed 4f48e30a on main
    task: #3567157 Convert expectation-less test mocks to stubs -...

Status: Fixed » Closed (fixed)

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