You are here

public function KernelTestBaseTest::testEnableModulesLoad in Drupal 8

Tests expected load behavior of enableModules().

File

core/modules/simpletest/src/Tests/KernelTestBaseTest.php, line 82

Class

KernelTestBaseTest
Tests KernelTestBase functionality.

Namespace

Drupal\simpletest\Tests

Code

public function testEnableModulesLoad() {
  $module = 'field_test';

  // Verify that the module does not exist yet.
  $this
    ->assertFalse(\Drupal::moduleHandler()
    ->moduleExists($module), "{$module} module not found.");
  $list = array_keys(\Drupal::moduleHandler()
    ->getModuleList());
  $this
    ->assertFalse(in_array($module, $list), "{$module} module not found in the extension handler's module list.");
  $list = \Drupal::moduleHandler()
    ->getImplementations('entity_display_build_alter');
  $this
    ->assertFalse(in_array($module, $list), "{$module}_entity_display_build_alter() in \\Drupal::moduleHandler()->getImplementations() not found.");

  // Enable the module.
  $this
    ->enableModules([
    $module,
  ]);

  // Verify that the module exists.
  $this
    ->assertTrue(\Drupal::moduleHandler()
    ->moduleExists($module), "{$module} module found.");
  $list = array_keys(\Drupal::moduleHandler()
    ->getModuleList());
  $this
    ->assertTrue(in_array($module, $list), "{$module} module found in the extension handler's module list.");
  $list = \Drupal::moduleHandler()
    ->getImplementations('query_efq_table_prefixing_test_alter');
  $this
    ->assertTrue(in_array($module, $list), "{$module}_query_efq_table_prefixing_test_alter() in \\Drupal::moduleHandler()->getImplementations() found.");
}