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.
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 notices in the package_manager 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-3569426
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:
- 3569426-stub-conversion
changes, plain diff MR !14486
Comments
Comment #3
dcam commentedComment #4
dcam commentedComment #5
smustgrave commentedSo I reviewed this one check that all instances of any() are gone (which they are) and reviewed remaining createMock() to see if they should be stubs but the 6 instances in this module all call specific methods. Believe this one is good
Comment #7
longwaveBackported to 11.x to keep things in sync.
Committed and pushed d275b6f1a42 to main and a732961cbe7 to 11.x. Thanks!