function ModuleImplementsAlterTest::testModuleImplementsAlterNonExistingImplementation

Same name 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');
}

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