public function ConfigImporterTest::testDeleted in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testDeleted()
- 9 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testDeleted()
Tests deletion of configuration during import.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigImporterTest.php, line 99
Class
- ConfigImporterTest
- Tests importing configuration from files into active configuration.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testDeleted() {
$dynamic_name = 'config_test.dynamic.dotted.default';
$storage = $this->container
->get('config.storage');
$sync = $this->container
->get('config.storage.sync');
// Verify the default configuration values exist.
$config = $this
->config($dynamic_name);
$this
->assertSame('dotted.default', $config
->get('id'));
// Delete the file from the sync directory.
$sync
->delete($dynamic_name);
// Import.
$config_importer = $this
->configImporter();
$config_importer
->import();
// Verify the file has been removed.
$this
->assertFalse($storage
->read($dynamic_name));
$config = $this
->config($dynamic_name);
$this
->assertNull($config
->get('id'));
// Verify that appropriate module API hooks have been invoked.
$this
->assertTrue(isset($GLOBALS['hook_config_test']['load']));
$this
->assertFalse(isset($GLOBALS['hook_config_test']['presave']));
$this
->assertFalse(isset($GLOBALS['hook_config_test']['insert']));
$this
->assertFalse(isset($GLOBALS['hook_config_test']['update']));
$this
->assertTrue(isset($GLOBALS['hook_config_test']['predelete']));
$this
->assertTrue(isset($GLOBALS['hook_config_test']['delete']));
$this
->assertFalse($config_importer
->hasUnprocessedConfigurationChanges());
$logs = $config_importer
->getErrors();
$this
->assertCount(0, $logs);
}