function ModuleTestBase::assertModules

Same name in this branch
  1. 8.9.x core/modules/system/tests/src/Functional/Module/ModuleTestBase.php \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModules()
Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Module/ModuleTestBase.php \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModules()
  2. 10 core/modules/system/tests/src/Functional/Module/ModuleTestBase.php \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModules()
  3. 11.x core/modules/system/tests/src/Functional/Module/ModuleTestBase.php \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModules()

Assert the list of modules are enabled or disabled.

Parameters

$modules: Module list to check.

$enabled: Expected module state.

File

core/modules/system/src/Tests/Module/ModuleTestBase.php, line 161

Class

ModuleTestBase
Helper class for module test cases.

Namespace

Drupal\system\Tests\Module

Code

public function assertModules(array $modules, $enabled) {
    $this->rebuildContainer();
    foreach ($modules as $module) {
        if ($enabled) {
            $message = 'Module "@module" is enabled.';
        }
        else {
            $message = 'Module "@module" is not enabled.';
        }
        $this->assertEqual($this->container
            ->get('module_handler')
            ->moduleExists($module), $enabled, new FormattableMarkup($message, [
            '@module' => $module,
        ]));
    }
}

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