Change record status: 
Project: 
Introduced in branch: 
11.3.x
Introduced in version: 
11.3.0
Description: 

For any plugin used in a kernel test, all modules that have code that the plugin's class inherits from must be explicitly installed in the kernel test in order for the plugin to be discovered.

Using Node entity type as an example, any kernel test that uses nodes must have both the node and user modules installed.

Before

class NodeExampleTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = ['node'];
  ...

  public function testExample(): void {
    $node = \Drupal::entitTypeManager()->loadStorage('node')->create([
      ...
    ]);
    ...
  }
  
}

After

class NodeExampleTest extends KernelTestBase {

 /**
   * {@inheritdoc}
   */
  protected static $modules = ['node', 'user'];
  ...

  public function testExample(): void {
    $node = \Drupal::entitTypeManager()->loadStorage('node')->create([
      ...
    ]);
    ...
  }
  
}

Adding user to $modules in this example is necessary because the Node entity type class uses Drupal\user\EntityOwnerTrait in the user module. And while the node module has drupal:text defined as a dependency in node.info.yml, and thus drupal:filter and drupal:user as part of the dependency chain, in kernel tests, modules listed in the $modules property are installed without implicitly installing their dependencies.

Impacts: 
Module developers