function ConfigImporterTest::testIsSyncingInHooks
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testIsSyncingInHooks()
- 10 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testIsSyncingInHooks()
- 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testIsSyncingInHooks()
Tests the isSyncing flags.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigImporterTest.php, line 780
Class
- ConfigImporterTest
- Tests importing configuration from files into active configuration.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testIsSyncingInHooks() {
$dynamic_name = 'config_test.dynamic.dotted.default';
$storage = $this->container
->get('config.storage');
// Verify the default configuration values exist.
$config = $this->config($dynamic_name);
$this->assertSame('dotted.default', $config->get('id'));
// Delete the config so that create hooks will fire.
$storage->delete($dynamic_name);
\Drupal::state()->set('config_test.store_isSyncing', []);
$this->configImporter()
->import();
// The values of the syncing values should be stored in state by
// config_test_config_test_create().
$state = \Drupal::state()->get('config_test.store_isSyncing');
$this->assertTrue($state['global_state::create'], '\\Drupal::isConfigSyncing() returns TRUE');
$this->assertTrue($state['entity_state::create'], 'ConfigEntity::isSyncing() returns TRUE');
$this->assertTrue($state['global_state::presave'], '\\Drupal::isConfigSyncing() returns TRUE');
$this->assertTrue($state['entity_state::presave'], 'ConfigEntity::isSyncing() returns TRUE');
$this->assertTrue($state['global_state::insert'], '\\Drupal::isConfigSyncing() returns TRUE');
$this->assertTrue($state['entity_state::insert'], 'ConfigEntity::isSyncing() returns TRUE');
// Cause a config update so update hooks will fire.
$config = $this->config($dynamic_name);
$config->set('label', 'A new name')
->save();
\Drupal::state()->set('config_test.store_isSyncing', []);
$this->configImporter()
->import();
// The values of the syncing values should be stored in state by
// config_test_config_test_create().
$state = \Drupal::state()->get('config_test.store_isSyncing');
$this->assertTrue($state['global_state::presave'], '\\Drupal::isConfigSyncing() returns TRUE');
$this->assertTrue($state['entity_state::presave'], 'ConfigEntity::isSyncing() returns TRUE');
$this->assertTrue($state['global_state::update'], '\\Drupal::isConfigSyncing() returns TRUE');
$this->assertTrue($state['entity_state::update'], 'ConfigEntity::isSyncing() returns TRUE');
// Cause a config delete so delete hooks will fire.
$sync = $this->container
->get('config.storage.sync');
$sync->delete($dynamic_name);
\Drupal::state()->set('config_test.store_isSyncing', []);
$this->configImporter()
->import();
// The values of the syncing values should be stored in state by
// config_test_config_test_create().
$state = \Drupal::state()->get('config_test.store_isSyncing');
$this->assertTrue($state['global_state::predelete'], '\\Drupal::isConfigSyncing() returns TRUE');
$this->assertTrue($state['entity_state::predelete'], 'ConfigEntity::isSyncing() returns TRUE');
$this->assertTrue($state['global_state::delete'], '\\Drupal::isConfigSyncing() returns TRUE');
$this->assertTrue($state['entity_state::delete'], 'ConfigEntity::isSyncing() returns TRUE');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.