You are here

public function ModuleTestBase::assertModules in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Module/ModuleTestBase.php \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModules()
  2. 9 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.

10 calls to ModuleTestBase::assertModules()
DependencyTest::testCoreCompatibility in core/modules/system/tests/src/Functional/Module/DependencyTest.php
Tests enabling modules with different core version specifications.
DependencyTest::testEnableRequirementsFailureDependency in core/modules/system/tests/src/Functional/Module/DependencyTest.php
Tests enabling a module that depends on a module which fails hook_requirements().
DependencyTest::testEnableWithoutDependency in core/modules/system/tests/src/Functional/Module/DependencyTest.php
Attempts to enable the Content Translation module without Language enabled.
DependencyTest::testModuleEnableOrder in core/modules/system/tests/src/Functional/Module/DependencyTest.php
Tests that module dependencies are enabled in the correct order in the UI.
DependencyTest::testProjectNamespaceForDependencies in core/modules/system/tests/src/Functional/Module/DependencyTest.php
Checks functionality of project namespaces for dependencies.

... See full list

File

core/modules/system/tests/src/Functional/Module/ModuleTestBase.php, line 133

Class

ModuleTestBase
Helper class for module test cases.

Namespace

Drupal\Tests\system\Functional\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
      ->assertEquals($enabled, $this->container
      ->get('module_handler')
      ->moduleExists($module), new FormattableMarkup($message, [
      '@module' => $module,
    ]));
  }
}