function ConfigDependencyTest::testConfigEntityUninstall
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php \Drupal\KernelTests\Core\Config\ConfigDependencyTest::testConfigEntityUninstall()
- 8.9.x core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php \Drupal\KernelTests\Core\Config\ConfigDependencyTest::testConfigEntityUninstall()
- 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php \Drupal\KernelTests\Core\Config\ConfigDependencyTest::testConfigEntityUninstall()
Tests ConfigManager::uninstall() and config entity dependency management.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigDependencyTest.php, line 193
Class
- ConfigDependencyTest
- Tests for configuration dependencies.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testConfigEntityUninstall() : void {
/** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
$config_manager = \Drupal::service('config.manager');
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */
$storage = $this->container
->get('entity_type.manager')
->getStorage('config_test');
// Test dependencies between modules.
$entity1 = $storage->create([
'id' => 'entity1',
'dependencies' => [
'enforced' => [
'module' => [
'node',
'config_test',
],
],
],
]);
$entity1->save();
$entity2 = $storage->create([
'id' => 'entity2',
'dependencies' => [
'enforced' => [
'config' => [
$entity1->getConfigDependencyName(),
],
],
],
]);
$entity2->save();
// Test that doing a config uninstall of the node module deletes entity2
// since it is dependent on entity1 which is dependent on the node module.
$config_manager->uninstall('module', 'node');
$this->assertNull($storage->load('entity1'), 'Entity 1 deleted');
$this->assertNull($storage->load('entity2'), 'Entity 2 deleted');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.