You are here

public function ModuleImplementsAlterTest::testModuleImplementsAlterNonExistingImplementation in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php \Drupal\KernelTests\Core\Extension\ModuleImplementsAlterTest::testModuleImplementsAlterNonExistingImplementation()
  2. 10 core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php \Drupal\KernelTests\Core\Extension\ModuleImplementsAlterTest::testModuleImplementsAlterNonExistingImplementation()

Tests what happens if hook_module_implements_alter() adds a non-existing function to the implementations.

See also

\Drupal\Core\Extension\ModuleHandler::buildImplementationInfo()

module_test_module_implements_alter()

File

core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php, line 75

Class

ModuleImplementsAlterTest
Tests hook_module_implements_alter().

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testModuleImplementsAlterNonExistingImplementation() {

  // Install the module_test module.
  \Drupal::service('module_installer')
    ->install([
    'module_test',
  ]);

  // Trigger hook discovery.
  $this
    ->expectException(\RuntimeException::class);
  $this
    ->expectExceptionMessage('An invalid implementation module_test_unimplemented_test_hook was added by hook_module_implements_alter()');
  \Drupal::moduleHandler()
    ->getImplementations('unimplemented_test_hook');
}