protected function DefaultConfigTest::doTestsOnConfigStorage in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php \Drupal\KernelTests\Config\DefaultConfigTest::doTestsOnConfigStorage()
- 10 core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php \Drupal\KernelTests\Config\DefaultConfigTest::doTestsOnConfigStorage()
Tests that default config matches the installed config.
Parameters
\Drupal\Core\Config\StorageInterface $default_config_storage: The default config storage to test.
string $module: The module that is being tested.
1 call to DefaultConfigTest::doTestsOnConfigStorage()
- DefaultConfigTest::assertExtensionConfig in core/
tests/ Drupal/ KernelTests/ Config/ DefaultConfigTest.php - Tests that the config provided by the extension is correct.
File
- core/
tests/ Drupal/ KernelTests/ Config/ DefaultConfigTest.php, line 142
Class
- DefaultConfigTest
- Tests that the installed config matches the default config.
Namespace
Drupal\KernelTests\ConfigCode
protected function doTestsOnConfigStorage(StorageInterface $default_config_storage, $module) {
/** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
$config_manager = $this->container
->get('config.manager');
// Just connect directly to the config table so we don't need to worry about
// the cache layer.
$active_config_storage = $this->container
->get('config.storage');
foreach ($default_config_storage
->listAll() as $config_name) {
if ($active_config_storage
->exists($config_name)) {
// If it is a config entity re-save it. This ensures that any
// recalculation of dependencies does not cause config change.
if ($entity_type = $config_manager
->getEntityTypeIdByName($config_name)) {
$entity_storage = $config_manager
->getEntityTypeManager()
->getStorage($entity_type);
$id = $entity_storage
->getIDFromConfigName($config_name, $entity_storage
->getEntityType()
->getConfigPrefix());
$entity_storage
->load($id)
->calculateDependencies()
->save();
}
$result = $config_manager
->diff($default_config_storage, $active_config_storage, $config_name);
// ::assertConfigDiff will throw an exception if the configuration is
// different.
$this
->assertNull($this
->assertConfigDiff($result, $config_name, static::$skippedConfig));
}
else {
$info = $this->container
->get('extension.list.module')
->getExtensionInfo($module);
if (!isset($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER]) || $info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] !== ExtensionLifecycle::EXPERIMENTAL) {
$this
->fail("{$config_name} provided by {$module} does not exist after installing all dependencies");
}
}
}
}