protected function DrupalUnitTestBase::enableModules

Enables modules for this test.

Callbacks invoked by module_enable() may need to access information provided by info hooks of the new modules already. However, module_enable() enables the new modules in the system.module configuration only, but that has no effect, since we are operating with a fixed module list.

@todo Remove this method as soon as there is an Extensions service implementation that is able to manage a fixed module list.

Parameters

array $modules: A list of modules to enable. Dependencies are not resolved; i.e., multiple modules have to be specified with dependent modules first.

bool $install: (optional) Whether to install the list of modules via module_enable(). Defaults to TRUE. If FALSE, the new modules are only added to the fixed module list and loaded.

21 calls to DrupalUnitTestBase::enableModules()
AreaTextTest::setUp in drupal/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php
Sets up Drupal unit test environment.
ConfigInstallTest::testModuleInstallation in drupal/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php
Tests module installation.
DrupalUnitTestBase::setUp in drupal/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
Sets up Drupal unit test environment.
DrupalUnitTestBaseTest::testEnableModulesInstall in drupal/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
Tests expected installation behavior of enableModules().
DrupalUnitTestBaseTest::testEnableModulesInstallContainer in drupal/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
Tests installing modules via enableModules() with DepedencyInjection services.

... See full list

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php, line 204
Contains Drupal\simpletest\DrupalUnitTestBase.

Class

DrupalUnitTestBase
Base test case class for Drupal unit tests.

Namespace

Drupal\simpletest

Code

protected function enableModules(array $modules, $install = TRUE) {

  // Set the modules in the fixed module_list().
  $new_enabled = array();
  foreach ($modules as $module) {
    $this->moduleList[$module]['filename'] = drupal_get_filename('module', $module);
    $new_enabled[$module] = dirname($this->moduleList[$module]['filename']);
    module_list(NULL, $this->moduleList);

    // Call module_enable() to enable (install) the new module.
    if ($install) {
      module_enable(array(
        $module,
      ), FALSE);
    }
  }

  // Otherwise, only ensure that the new modules are loaded.
  if (!$install) {
    module_load_all(FALSE, TRUE);
    module_implements_reset();
  }
}