You are here

protected function KernelTestBase::enableModules in Zircon Profile 8

Same name in this branch
  1. 8 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::enableModules()
  2. 8 core/modules/simpletest/src/KernelTestBase.php \Drupal\simpletest\KernelTestBase::enableModules()
Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/KernelTestBase.php \Drupal\simpletest\KernelTestBase::enableModules()

Enables modules for this test.

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. The new modules are only added to the active module list and loaded.

42 calls to KernelTestBase::enableModules()
CKEditorPluginManagerTest::testEnabledPlugins in core/modules/ckeditor/src/Tests/CKEditorPluginManagerTest.php
Tests the enabling of plugins.
CKEditorTest::testBuildContentsCssJSSetting in core/modules/ckeditor/src/Tests/CKEditorTest.php
Tests CKEditor::buildContentsCssJSSetting().
CKEditorTest::testBuildToolbarJSSetting in core/modules/ckeditor/src/Tests/CKEditorTest.php
Tests CKEditor::buildToolbarJSSetting().
CKEditorTest::testGetJSSettings in core/modules/ckeditor/src/Tests/CKEditorTest.php
Tests CKEditor::getJSSettings().
CKEditorTest::testJSTranslation in core/modules/ckeditor/src/Tests/CKEditorTest.php
Tests that CKEditor plugins participate in JS translation.

... See full list

File

core/modules/simpletest/src/KernelTestBase.php, line 493
Contains \Drupal\simpletest\KernelTestBase.

Class

KernelTestBase
Base class for integration tests.

Namespace

Drupal\simpletest

Code

protected function enableModules(array $modules) {

  // Perform an ExtensionDiscovery scan as this function may receive a
  // profile that is not the current profile, and we don't yet have a cached
  // way to receive inactive profile information.
  // @todo Remove as part of https://www.drupal.org/node/2186491
  $listing = new ExtensionDiscovery(\Drupal::root());
  $module_list = $listing
    ->scan('module');

  // In ModuleHandlerTest we pass in a profile as if it were a module.
  $module_list += $listing
    ->scan('profile');

  // Set the list of modules in the extension handler.
  $module_handler = $this->container
    ->get('module_handler');

  // Write directly to active storage to avoid early instantiation of
  // the event dispatcher which can prevent modules from registering events.
  $active_storage = \Drupal::service('config.storage');
  $extensions = $active_storage
    ->read('core.extension');
  foreach ($modules as $module) {
    $module_handler
      ->addModule($module, $module_list[$module]
      ->getPath());

    // Maintain the list of enabled modules in configuration.
    $extensions['module'][$module] = 0;
  }
  $active_storage
    ->write('core.extension', $extensions);

  // Update the kernel to make their services available.
  $module_filenames = $module_handler
    ->getModuleList();
  $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.
  $this->container
    ->get('module_handler')
    ->reload();
  $this
    ->pass(format_string('Enabled modules: %modules.', array(
    '%modules' => implode(', ', $modules),
  )));
}