function ModuleHandlerTest::testInvalidGetName

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleHandlerTest.php \Drupal\KernelTests\Core\Extension\ModuleHandlerTest::testInvalidGetName()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Extension/ModuleHandlerTest.php \Drupal\KernelTests\Core\Extension\ModuleHandlerTest::testInvalidGetName()
  3. 10 core/tests/Drupal/KernelTests/Core/Extension/ModuleHandlerTest.php \Drupal\KernelTests\Core\Extension\ModuleHandlerTest::testInvalidGetName()

Tests requesting the name of an invalid module.

@covers ::getName

File

core/tests/Drupal/KernelTests/Core/Extension/ModuleHandlerTest.php, line 22

Class

ModuleHandlerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Extension%21ModuleHandler.php/class/ModuleHandler/11.x" title="Class that manages modules in a Drupal installation." class="local">\Drupal\Core\Extension\ModuleHandler</a>

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testInvalidGetName() : void {
    $this->expectException(UnknownExtensionException::class);
    $this->expectExceptionMessage('The module module_nonsense does not exist.');
    $module_handler = $this->container
        ->get('module_handler');
    $module_handler->getModule('module_nonsense');
}

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