function ConfigSingleImportExportTest::testExport
Tests exporting a single configuration file.
File
- 
              core/modules/ config/ tests/ src/ Functional/ ConfigSingleImportExportTest.php, line 244 
Class
- ConfigSingleImportExportTest
- Tests the user interface for importing/exporting a single configuration.
Namespace
Drupal\Tests\config\FunctionalCode
public function testExport() : void {
  $this->drupalLogin($this->drupalCreateUser([
    'export configuration',
  ]));
  // Verify that the simple configuration option is selected when specified
  // in the URL.
  $this->drupalGet('admin/config/development/configuration/single/export/system.simple');
  $option_node = $this->assertSession()
    ->optionExists("config_type", 'Simple configuration');
  $this->assertTrue($option_node->isSelected());
  // Spot check several known simple configuration files.
  $this->assertSession()
    ->optionExists('config_name', 'system.site');
  $this->assertSession()
    ->optionExists('config_name', 'user.settings');
  $this->drupalGet('admin/config/development/configuration/single/export/system.simple/system.image');
  // cspell:disable-next-line
  $this->assertSession()
    ->fieldValueEquals('export', "_core:\n  default_config_hash: durWHaKeBaq4d9Wpi4RqwADj1OufDepcnJuhVLmKN24\ntoolkit: gd\n");
  // Verify that the date format entity type is selected when specified in
  // the URL.
  $this->drupalGet('admin/config/development/configuration/single/export/date_format');
  $option_node = $this->assertSession()
    ->optionExists("config_type", 'Date format');
  $this->assertTrue($option_node->isSelected());
  // Verify that the fallback date format config entity is selected when
  // specified in the URL.
  $this->drupalGet('admin/config/development/configuration/single/export/date_format/fallback');
  $option_node = $this->assertSession()
    ->optionExists("config_name", 'fallback (Fallback date format)');
  $this->assertTrue($option_node->isSelected());
  $fallback_date = \Drupal::entityTypeManager()->getStorage('date_format')
    ->load('fallback');
  $yaml_text = $this->assertSession()
    ->fieldExists('export')
    ->getValue();
  $this->assertEquals(Yaml::decode($yaml_text), $fallback_date->toArray(), 'The fallback date format config entity export code is displayed.');
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
