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 = 'filter';
  $table = 'filter';

  // @todo Remove after configuration system conversion.
  $this
    ->enableModules(array(
    'system',
  ), FALSE);
  $this
    ->installSchema('system', 'variable');

  // Verify that the module does not exist yet.
  $this
    ->assertFalse(module_exists($module), "{$module} module not found.");
  $list = module_list();
  $this
    ->assertFalse(in_array($module, $list), "{$module} module in module_list() not found.");
  $list = module_list('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.");

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

  // Verify that the enabled module exists.
  $this
    ->assertTrue(module_exists($module), "{$module} module found.");
  $list = module_list();
  $this
    ->assertTrue(in_array($module, $list), "{$module} module in module_list() found.");
  $list = module_list('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.");
}