function InstallTest::testModuleNameLengthWithoutDependencyCheck

Same name in other branches
  1. 10 core/modules/system/tests/src/Kernel/Module/InstallTest.php \Drupal\Tests\system\Kernel\Module\InstallTest::testModuleNameLengthWithoutDependencyCheck()

Tests that an exception is thrown when a module name is too long.

We do this without checking dependencies for the module to install.

File

core/modules/system/tests/src/Kernel/Module/InstallTest.php, line 118

Class

InstallTest
Tests the installation of modules.

Namespace

Drupal\Tests\system\Kernel\Module

Code

public function testModuleNameLengthWithoutDependencyCheck() : void {
    $module_name = 'invalid_module_name_over_the_maximum_allowed_character_length';
    $this->expectException(ExtensionNameLengthException::class);
    $this->expectExceptionMessage("Module name 'invalid_module_name_over_the_maximum_allowed_character_length' is over the maximum allowed length of 50 characters");
    $this->moduleInstaller
        ->install([
        $module_name,
    ], FALSE);
}

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