Issue #3130606: MockBuilder::setMethods is deprecated in PHPUnit8 and removed from PHPUnit10
Merge request reports
Activity
38 38 if (!$b instanceof BubbleableMetadata) { 39 39 $renderer = $this->getMockBuilder('Drupal\Core\Render\Renderer') 40 40 ->disableOriginalConstructor() 41 ->setMethods(['mergeAttachments']) mergeAttachments
is not (or no longer is) a method ofDrupal\Core\Render\Renderer
. When converting to usingonlyMethods
, the mock builder now checks if the method exists on the mocked object. If not, an error is thrown:PHPUnit\Framework\MockObject\CannotUseOnlyMethodsException: Trying to configure method "mergeAttachments" with onlyMethods(), but it does not exist in class "Drupal\Core\Render\Renderer". Use addMethods() for methods that do not exist in the class
see https://www.drupal.org/pift-ci-job/2175338.
Another method is added to the mock builder to manage 'extending' the mock with new methods,
addMethods
. But in this case apparently in the test there is no behavior set formergeAttachments
on the mock, so we just do not need to add it.@mondrake: thank you for the explanation.
This thread can be marked as resolved.