public function ConfigSingleImportExportTest::testExport in Drupal 8
Same name and namespace in other branches
- 9 core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php \Drupal\Tests\config\Functional\ConfigSingleImportExportTest::testExport()
Tests exporting a single configuration file.
File
- core/
modules/ config/ tests/ src/ Functional/ ConfigSingleImportExportTest.php, line 243
Class
- ConfigSingleImportExportTest
- Tests the user interface for importing/exporting a single configuration.
Namespace
Drupal\Tests\config\FunctionalCode
public function testExport() {
$this
->drupalLogin($this
->drupalCreateUser([
'export configuration',
]));
$this
->drupalGet('admin/config/development/configuration/single/export/system.simple');
$this
->assertFieldByXPath('//select[@name="config_type"]//option[@selected="selected"]', t('Simple configuration'), 'The simple configuration option is selected when specified in the URL.');
// Spot check several known simple configuration files.
$element = $this
->xpath('//select[@name="config_name"]')[0];
$options = $element
->findAll('css', 'option');
$expected_options = [
'system.site',
'user.settings',
];
foreach ($options as &$option) {
$option = $option
->getValue();
}
$this
->assertIdentical($expected_options, array_intersect($expected_options, $options), 'The expected configuration files are listed.');
$this
->drupalGet('admin/config/development/configuration/single/export/system.simple/system.image');
$this
->assertEquals("toolkit: gd\n_core:\n default_config_hash: durWHaKeBaq4d9Wpi4RqwADj1OufDepcnJuhVLmKN24\n", $this
->xpath('//textarea[@name="export"]')[0]
->getValue(), 'The expected system configuration is displayed.');
$this
->drupalGet('admin/config/development/configuration/single/export/date_format');
$this
->assertFieldByXPath('//select[@name="config_type"]//option[@selected="selected"]', t('Date format'), 'The date format entity type is selected when specified in the URL.');
$this
->drupalGet('admin/config/development/configuration/single/export/date_format/fallback');
$this
->assertFieldByXPath('//select[@name="config_name"]//option[@selected="selected"]', t('Fallback date format (fallback)'), 'The fallback date format config entity is selected when specified in the URL.');
$fallback_date = \Drupal::entityTypeManager()
->getStorage('date_format')
->load('fallback');
$yaml_text = $this
->xpath('//textarea[@name="export"]')[0]
->getValue();
$this
->assertEquals(Yaml::decode($yaml_text), $fallback_date
->toArray(), 'The fallback date format config entity export code is displayed.');
}