Unclear replacement of getMockBuilder() with createMock().

Created on 29 July 2022, over 2 years ago
Updated 4 March 2024, about 1 year ago

Drupal version

10.0x

Drupal Rector version

0.13.0

Problem / Motivation

I am reviewing the automated changes proposed for the filelog module in πŸ“Œ Automated Drupal 10 compatibility fixes Needs review , and I notice that the bot has made several changes of the following form:

-    $this->token = $this
-      ->getMockBuilder(Token::class)
-      ->disableOriginalConstructor()
-      ->getMock();
+    $this->token = $this->createMock(Token::class);

These do not seem to follow from the change record 2907725 β†’ , which is the only one mentioned in rector in relation to ::createMock(). Specifically, ::getMock() was deprecated, but ::getMockBuilder() was not. Also the deprecation was in Drupal 8 and the removal in Drupal 9, so it shouldn't be relevant for updating Drupal 9-compatible code to Drupal 10, right?

Am I just missing something here, or was the code replacement pattern too broad?

πŸ› Bug report
Status

Active

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland cburschka

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

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

    Maybe this issue should be moved to a different queue like for infrastructure? Not sure which queue is where the Update Project Bot is managed and if that code is what is deciding which rules to run or if it's just running any rector rule.

  • πŸ‡³πŸ‡±Netherlands bbrala Netherlands

    Project update bot is managed in project/project_analysis

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

    Thanks. Switching projects but feel free to move back or elsewhere as appropriate.

  • πŸ‡³πŸ‡±Netherlands bbrala Netherlands

    With rector moving away from "UP_TO_XXX" sets, this should not happen anymore. This was a rule in phpunit_60, which is not in the current list. We do list the set for the actual phpunit version moved to so deprecations are handled.

    This issue is one for drupal rector btw :)

Production build 0.71.5 2024