[10.0] ModuleHandlerInterface::getImplementations() removed from core

Created on 9 March 2023, over 1 year ago

Changes to Drupal core have started to cause the Drupal 10 tests for Rules to start failing.

Most of the failures seem to be due to the change in All hook invocation delegated to Module Handler service β†’

Specifically, this change removed a method that Rules was using in test cases - namely \Drupal\Core\Extension\ModuleHandlerInterface::getImplementations()

This leads to about 100 test errors in Rules. And because we use this method in RulesEntityIntegrationTestBase, this also leads to D10 testing errors on many other contributed modules which provide Rules integrations.

The errors looks something like this:

Prophecy\Exception\Doubler\MethodNotFoundException: Method `Double\ModuleHandlerInterface\P1::getImplementations()` is not defined.

Rules uses the method like this:

    $this->moduleHandler->getImplementations('entity_type_build')
      ->willReturn([]);

I have done research, but there is no issue or discussion or code comments about what RulesEntityIntegrationTestBase is doing when it uses this method. I have two theories. First is that the test is just using this method to turn off hook_enitity_type_build(), since that's what it is literally doing. Why? I don't know. Second is that the test just needs to mock a return value for the internal getImplementations() method so that the Unit testing doesn't fail when trying to call a non-existent function. This could also be true.

Regardless, the quickest way to find out is to remove this line of code and see if it causes problems. If it does, we can re-invent the wheel and solve them in a different way than with this now-removed method.

Here is a patch that removes that line of code in RulesEntityIntegrationTestBase. We currently have 149 test errors - let's see how this patch changes that number.

πŸ“Œ Task
Status

Fixed

Version

3.0

Component

Tests

Created by

πŸ‡ΊπŸ‡ΈUnited States TR Cascadia

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

Comments & Activities

Production build 0.69.0 2024