[!!!][TASK] Avoid setMethods() on mocks #449
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
setMethods() has been removed with phpunit 10.
$this->getAccessibleMock() used this to only
partially mock a test subject. The patch switches
to onlyMethods() now.
There is one difference: onlyMethods() fails if
a methods that should be mocked does not exist,
while setMethods() did not fail on this.
So this is more strict now. It was frequently used in core tests mocking ['dummy'] to say "mock no method". Those have to be switched to use 'null' as argument to $this->getAccessibleMock() now. Also, when a class is refactored, and a method that has been previously mocked is removed with the refactoring, the mock has to be adapted to remove the method-mock request from the test as well now, otherwise the test will fail.
Rules for the second argument of getAccessibleMock():
Releases: main, 7
Resolves: #444
Changes proposed in this pull request
Steps to test the solution
Results
Fixes: #