You are here

function KernelTestBaseTest::testEnableModulesLoad in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/Tests/KernelTestBaseTest.php \Drupal\simpletest\Tests\KernelTestBaseTest::testEnableModulesLoad()

Tests expected load behavior of enableModules().

File

core/modules/simpletest/src/Tests/KernelTestBaseTest.php, line 84
Contains \Drupal\simpletest\Tests\KernelTestBaseTest.

Class

KernelTestBaseTest
Tests KernelTestBase functionality.

Namespace

Drupal\simpletest\Tests

Code

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(array(
    $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.");
}