function ModuleHandlerTest::testInvokeWithNotMergeableClass

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testInvokeWithNotMergeableClass()

Tests invoke fails for multiple implementations that cannot be merged.

File

core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php, line 434

Class

ModuleHandlerTest
Tests ModuleHandler functionality.

Namespace

Drupal\Tests\system\Kernel\Extension

Code

public function testInvokeWithNotMergeableClass() : void {
  $this->moduleInstaller()
    ->install([
    'hook_single_invoke',
  ]);
  $expected_exception_message = 'Module hook_single_invoke should not implement custom_hook_invoke_class more than once.';
  $this->expectException(\LogicException::class);
  $this->expectExceptionMessage($expected_exception_message);
  $this->moduleHandler()
    ->invoke('hook_single_invoke', 'custom_hook_invoke_class', args: [
    TRUE,
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.