function ConfigSingleImportExportTest::testImportSimpleConfiguration
Same name in other branches
- 9 core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php \Drupal\Tests\config\Functional\ConfigSingleImportExportTest::testImportSimpleConfiguration()
- 10 core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php \Drupal\Tests\config\Functional\ConfigSingleImportExportTest::testImportSimpleConfiguration()
- 11.x core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php \Drupal\Tests\config\Functional\ConfigSingleImportExportTest::testImportSimpleConfiguration()
Tests importing a simple configuration file.
File
-
core/
modules/ config/ tests/ src/ Functional/ ConfigSingleImportExportTest.php, line 203
Class
- ConfigSingleImportExportTest
- Tests the user interface for importing/exporting a single configuration.
Namespace
Drupal\Tests\config\FunctionalCode
public function testImportSimpleConfiguration() {
$this->drupalLogin($this->drupalCreateUser([
'import configuration',
]));
$config = $this->config('system.site')
->set('name', 'Test simple import');
// Place branding block with site name into header region.
$this->drupalPlaceBlock('system_branding_block', [
'region' => 'header',
]);
$edit = [
'config_type' => 'system.simple',
'config_name' => $config->getName(),
'import' => Yaml::encode($config->get()),
];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertRaw(t('Are you sure you want to update the %name @type?', [
'%name' => $config->getName(),
'@type' => 'simple configuration',
]));
$this->drupalPostForm(NULL, [], t('Confirm'));
$this->drupalGet('');
$this->assertText('Test simple import');
// Ensure that ConfigImporter validation is running when importing simple
// configuration.
$config_data = $this->config('core.extension')
->get();
// Simulate uninstalling the Config module.
unset($config_data['module']['config']);
$edit = [
'config_type' => 'system.simple',
'config_name' => 'core.extension',
'import' => Yaml::encode($config_data),
];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertText(t('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'));
// Try to import without any values.
$this->drupalPostForm('admin/config/development/configuration/single/import', [], t('Import'));
$this->assertText('Configuration type field is required.');
$this->assertText('Paste your configuration here field is required.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.