function GenericModuleTestBase::testModuleGenericIssues

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Functional/Module/GenericModuleTestBase.php \Drupal\Tests\system\Functional\Module\GenericModuleTestBase::testModuleGenericIssues()

Checks some generic things about a module.

File

core/modules/system/tests/src/Functional/Module/GenericModuleTestBase.php, line 40

Class

GenericModuleTestBase
Runs a series of generic tests for one module.

Namespace

Drupal\Tests\system\Functional\Module

Code

public function testModuleGenericIssues() : void {
  $module = $this->getModule();
  \Drupal::service('module_installer')->install([
    $module,
  ]);
  $info = \Drupal::service('extension.list.module')->getExtensionInfo($module);
  if (!empty($info['required']) && !empty($info['hidden'])) {
    $this->markTestSkipped('Nothing to assert for hidden, required modules.');
  }
  $this->drupalLogin($this->createUser([
    'access help pages',
  ]));
  $this->assertHookHelp($module);
  if (empty($info['required'])) {
    $connection = Database::getConnection();
    // When the database driver is provided by a module, then that module
    // cannot be uninstalled.
    if ($module !== $connection->getProvider()) {
      // Check that the module can be uninstalled and then re-installed again.
      $this->preUnInstallSteps();
      $this->assertTrue(\Drupal::service('module_installer')->uninstall([
        $module,
      ]), "Failed to uninstall '{$module}' module");
      $this->assertTrue(\Drupal::service('module_installer')->install([
        $module,
      ]), "Failed to install '{$module}' module");
    }
  }
}

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