protected function DrupalUnitTestBase::disableModules

Disables modules for this test.

Parameters

array $modules: A list of modules to disable. Dependencies are not resolved; i.e., multiple modules have to be specified with dependent modules first. Code of previously active modules is still loaded. The modules are only removed from the active module list.

1 call to DrupalUnitTestBase::disableModules()
DrupalUnitTestBaseTest::testEnableModulesTheme in drupal/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
Tests that theme() works right after loading a module.

File

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

Class

DrupalUnitTestBase
Base test case class for Drupal unit tests.

Namespace

Drupal\simpletest

Code

protected function disableModules(array $modules) {

  // Unset the list of modules in the extension handler.
  $module_handler = $this->container
    ->get('module_handler');
  $module_filenames = $module_handler
    ->getModuleList();
  foreach ($modules as $module) {
    unset($module_filenames[$module]);
  }
  $module_handler
    ->setModuleList($module_filenames);
  $module_handler
    ->resetImplementations();

  // Update the kernel to remove their services.
  $this->kernel
    ->updateModules($module_filenames, $module_filenames);

  // Ensure isLoaded() is TRUE in order to make theme() work.
  // Note that the kernel has rebuilt the container; this $module_handler is
  // no longer the $module_handler instance from above.
  $module_handler = $this->container
    ->get('module_handler');
  $module_handler
    ->reload();
  $this
    ->pass(format_string('Disabled modules: %modules.', array(
    '%modules' => implode(', ', $modules),
  )));
}