function KernelTestBaseTest::testEnableModulesInstall in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/simpletest/src/Tests/KernelTestBaseTest.php \Drupal\simpletest\Tests\KernelTestBaseTest::testEnableModulesInstall()
Tests expected installation behavior of enableModules().
File
- core/
modules/ simpletest/ src/ Tests/ KernelTestBaseTest.php, line 108 - Contains \Drupal\simpletest\Tests\KernelTestBaseTest.
Class
- KernelTestBaseTest
- Tests KernelTestBase functionality.
Namespace
Drupal\simpletest\TestsCode
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(db_table_exists($table), "'{$table}' database table not found.");
// Install the module.
\Drupal::service('module_installer')
->install(array(
$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(db_table_exists($table), "'{$table}' database table found.");
$schema = drupal_get_module_schema($module, $table);
$this
->assertTrue($schema, "'{$table}' table schema found.");
}