function InstallTest::testModuleNameLength

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Module/InstallTest.php \Drupal\Tests\system\Functional\Module\InstallTest::testModuleNameLength()
  2. 8.9.x core/modules/system/tests/src/Functional/Module/InstallTest.php \Drupal\Tests\system\Functional\Module\InstallTest::testModuleNameLength()
  3. 11.x core/modules/system/tests/src/Kernel/Module/InstallTest.php \Drupal\Tests\system\Kernel\Module\InstallTest::testModuleNameLength()

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

File

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

Class

InstallTest
Tests the installation of modules.

Namespace

Drupal\Tests\system\Kernel\Module

Code

public function testModuleNameLength() : 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,
    ]);
}

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