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 issues in translation modules: config_translation, content_translation, language, locale.

Ignore classes extending LocalTaskIntegrationTestBase and MigrateProcessTestCase because those will have to be tackled in base class-specific issues.

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-3567149

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

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Checked content_translation, locale, and config_translation as that seemed to be the scope of this ticket.

Confirmed all instances of ->any() were replaced.

Reviewing the MR of mocks to stubs and looks good. Actually looks cleaner too using ::class vs hardcoded paths.

LGTM

longwave’s picture

Status: Reviewed & tested by the community » Needs work

Added some feedback, it's not 100% clear which way to go to me, so feel free to push back on any of them!

dcam’s picture

Status: Needs work » Needs review

I made the recommended changes. They were good ideas.

The failing test is a recurring error today. This is at least the third separate issue on which I've seen it fail. So it's unrelated.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Believe feedback has been addressed by Dcam

dcam’s picture

Title: Convert expectation-less test mocks to stubs - batch 2 » Convert expectation-less test mocks to stubs - I18n modules

  • catch committed a1db96ad on main
    task: #3567149 Convert expectation-less test mocks to stubs - I18n...
catch’s picture

Status: Reviewed & tested by the community » Fixed

This looks good. I needed to change the permissions of core/.phpstanbaseline.php before commit from 755 to 644.

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.