Problem/Motivation

PHPUnit 13 deprecates usage of with*() without expects() in mocks.

See pipeline raw logs in #3574681: [Nov 2026] Introduce support for PHPUnit 13.5 for full report.

Proposed resolution

Before adopting PHPUnit 13, fix the usages, either converting the mocks to stubs, or adding explicit expectations on the calls to the mocked method.

In this issue, do a second round with a limited number of fixes.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3592112

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
dcam’s picture

Status: Needs review » Needs work

I found a few expectations that I think can be removed since they're unused. I left comments on the MR.

mondrake’s picture

Status: Needs work » Needs review

Thanks for review

dcam’s picture

Status: Needs review » Reviewed & tested by the community

My feedback was addressed. The MR follows the patterns for fixing these issues that were established in phase 1. It looks good to me.

quietone’s picture

All in order here, I updated credit.

longwave’s picture

Status: Reviewed & tested by the community » Needs work

I think almost all of these can be stubs instead of mocks? I only looked at a few but each one that I did check it seems that we don't really care about whether the mock is called at all, we just care that it returns something specific, so we can use stubs? That simplifies the tests and means we don't need to add additional setup methods or data provider arguments in some places.

mondrake’s picture

Status: Needs work » Needs review

#8 added a new MR with the feedback from @longwave. I just focused on that, preferred to do baby steps. The original intent was to stick to mocks, but of course if we can change to stubs even better. Also if you believe additional refactoring could do please comment.

dcam’s picture

Status: Needs review » Needs work

I found a couple of classes that I think need attention. Please check my comments and let me know what you think.

mondrake’s picture

Status: Needs work » Needs review

all correct, tx

dcam’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for considering my comments. This looks good to me now.

catch’s picture

Status: Reviewed & tested by the community » Needs work

Needs a rebase.

mondrake’s picture

Status: Needs work » Reviewed & tested by the community

Merged with main head, no conflicts.

  • catch committed 87bfa8bc on main
    task: #3592112 Fix usage of with*() without expects() in mocks - round 2...
catch’s picture

Status: Reviewed & tested by the community » Fixed

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.

Status: Fixed » Closed (fixed)

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