function DrupalUnitTestBaseTest::testEnableModulesInstall

Tests expected installation behavior of enableModules().

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php, line 76
Contains Drupal\simpletest\Tests\DrupalUnitTestBaseTest.

Class

DrupalUnitTestBaseTest
Tests DrupalUnitTestBase functionality.

Namespace

Drupal\simpletest\Tests

Code

function testEnableModulesInstall() {
  $module = 'node';
  $table = 'node';

  // Verify that the module does not exist yet.
  $this
    ->assertFalse(module_exists($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 = module_implements('permission');
  $this
    ->assertFalse(in_array($module, $list), "{$module}_permission() in module_implements() not found.");
  $this
    ->assertFalse(db_table_exists($table), "'{$table}' database table not found.");
  $schema = drupal_get_schema($table);
  $this
    ->assertFalse($schema, "'{$table}' table schema not found.");

  // Install the module.
  module_enable(array(
    $module,
  ));

  // Verify that the enabled module exists.
  $this
    ->assertTrue(module_exists($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 = module_implements('permission');
  $this
    ->assertTrue(in_array($module, $list), "{$module}_permission() in module_implements() found.");
  $this
    ->assertTrue(db_table_exists($table), "'{$table}' database table found.");
  $schema = drupal_get_schema($table);
  $this
    ->assertTrue($schema, "'{$table}' table schema found.");
}