Rector rule for updating getMockBuilder is not catching all instances

Created on 15 August 2023, over 1 year ago

Drupal version

^8.8 || ^9 || ^10

Drupal Rector version

Whatever the Project Update Bot is using.

Problem / Motivation

This Drupal 10 compatibility issue:

πŸ“Œ Automated Drupal 10 compatibility fixes Fixed

makes this change:

-    $fast404FactoryStackStub = $this->getMockBuilder('\Drupal\fast404\Fast404Factory')
-      ->disableOriginalConstructor()
-      ->getMock();
+    $fast404FactoryStackStub = $this->createMock('\Drupal\fast404\Fast404Factory');
     $subscriber = $this->getMockBuilder('\Drupal\fast404\EventSubscriber\Fast404EventSubscriber')
       ->setConstructorArgs([$requestStackStub, $fast404FactoryStackStub])
       ->getMock();

but, when I grep for getMockBuilder, I see more places this is used:

Kristens-MacBook-Pro:fast_404 kristenpol$ grep -r getMockBuilder .
./tests/src/Unit/Fast404Test.php:    $fast404 = $this->getMockBuilder('\Drupal\fast404\Fast404')
./tests/src/Unit/Fast404EventSubscriberTest.php:    $fast404FactoryStackStub = $this->getMockBuilder('\Drupal\fast404\Fast404Factory')
./tests/src/Unit/Fast404EventSubscriberTest.php:    $subscriber = $this->getMockBuilder('\Drupal\fast404\EventSubscriber\Fast404EventSubscriber')

Note this issue, though, where there is a fundamental question about whether the bot should be doing this in the first place:

πŸ› Unclear replacement of getMockBuilder() with createMock(). Active

πŸ› Bug report
Status

Closed: works as designed

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Kristen Pol Santa Cruz, CA, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024