You are here

public function ConfigSingleImportExportTest::testExport in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php \Drupal\Tests\config\Functional\ConfigSingleImportExportTest::testExport()
  2. 10 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 253

Class

ConfigSingleImportExportTest
Tests the user interface for importing/exporting a single configuration.

Namespace

Drupal\Tests\config\Functional

Code

public function testExport() {
  $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');
  $this
    ->assertSession()
    ->fieldValueEquals('export', "toolkit: gd\n_core:\n  default_config_hash: durWHaKeBaq4d9Wpi4RqwADj1OufDepcnJuhVLmKN24\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 date format (fallback)');
  $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.');
}