function ConfigInstallTest::testModuleInstallation
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php \Drupal\KernelTests\Core\Config\ConfigInstallTest::testModuleInstallation()
- 10 core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php \Drupal\KernelTests\Core\Config\ConfigInstallTest::testModuleInstallation()
- 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php \Drupal\KernelTests\Core\Config\ConfigInstallTest::testModuleInstallation()
Tests module installation.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigInstallTest.php, line 38
Class
- ConfigInstallTest
- Tests installation of configuration objects in installation functionality.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testModuleInstallation() {
$default_config = 'config_test.system';
$default_configuration_entity = 'config_test.dynamic.dotted.default';
// Verify that default module config does not exist before installation yet.
$config = $this->config($default_config);
$this->assertIdentical($config->isNew(), TRUE);
$config = $this->config($default_configuration_entity);
$this->assertIdentical($config->isNew(), TRUE);
// Ensure that schema provided by modules that are not installed is not
// available.
$this->assertFalse(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.someschema'), 'Configuration schema for config_schema_test.someschema does not exist.');
// Install the test module.
$this->installModules([
'config_test',
]);
// Verify that default module config exists.
\Drupal::configFactory()->reset($default_config);
\Drupal::configFactory()->reset($default_configuration_entity);
$config = $this->config($default_config);
$this->assertIdentical($config->isNew(), FALSE);
$config = $this->config($default_configuration_entity);
$this->assertIdentical($config->isNew(), FALSE);
// Verify that config_test API hooks were invoked for the dynamic default
// configuration entity.
$this->assertFalse(isset($GLOBALS['hook_config_test']['load']));
$this->assertTrue(isset($GLOBALS['hook_config_test']['presave']));
$this->assertTrue(isset($GLOBALS['hook_config_test']['insert']));
$this->assertFalse(isset($GLOBALS['hook_config_test']['update']));
$this->assertFalse(isset($GLOBALS['hook_config_test']['predelete']));
$this->assertFalse(isset($GLOBALS['hook_config_test']['delete']));
// Install the schema test module.
$this->enableModules([
'config_schema_test',
]);
$this->installConfig([
'config_schema_test',
]);
// After module installation the new schema should exist.
$this->assertTrue(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.someschema'), 'Configuration schema for config_schema_test.someschema exists.');
// Test that uninstalling configuration removes configuration schema.
$this->config('core.extension')
->set('module', [])
->save();
\Drupal::service('config.manager')->uninstall('module', 'config_test');
$this->assertFalse(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.someschema'), 'Configuration schema for config_schema_test.someschema does not exist.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.