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
- Require PHPUnit 12 with Composer.
- Fix compatibility issues with PHPUnit 12 by applying this patch.
- Run the Unit tests for a module with
--display-phpunit-notices. - 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
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:
- 3567149-stub-conversion
changes, plain diff MR !14315
Comments
Comment #3
dcam commentedComment #5
dcam commentedComment #6
smustgrave commentedChecked 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
Comment #7
smustgrave commentedComment #8
longwaveAdded some feedback, it's not 100% clear which way to go to me, so feel free to push back on any of them!
Comment #9
dcam commentedI 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.
Comment #10
smustgrave commentedBelieve feedback has been addressed by Dcam
Comment #11
dcam commentedComment #13
catchThis looks good. I needed to change the permissions of core/.phpstanbaseline.php before commit from 755 to 644.
Committed/pushed to main, thanks!