public function KernelTestBaseTest::testEnableModulesInstall in SimpleTest 8.3
Tests expected installation behavior of enableModules().
File
- src/
Tests/ KernelTestBaseTest.php, line 106
Class
- KernelTestBaseTest
- Tests KernelTestBase functionality.
Namespace
Drupal\simpletest\TestsCode
public function testEnableModulesInstall() {
$module = 'module_test';
$table = 'module_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('hook_info');
$this
->assertFalse(in_array($module, $list), "{$module}_hook_info() in \\Drupal::moduleHandler()->getImplementations() not found.");
$this
->assertFalse(Database::getConnection()
->schema()
->tableExists($table), "'{$table}' database table not found.");
// Install the module.
\Drupal::service('module_installer')
->install([
$module,
]);
// Verify that the enabled 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('hook_info');
$this
->assertTrue(in_array($module, $list), "{$module}_hook_info() in \\Drupal::moduleHandler()->getImplementations() found.");
$this
->assertTrue(Database::getConnection()
->schema()
->tableExists($table), "'{$table}' database table found.");
$schema = drupal_get_module_schema($module, $table);
$this
->assertTrue($schema, "'{$table}' table schema found.");
}