You are here

public function ConfigSingleImportExportTest::testExport in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/src/Tests/ConfigSingleImportExportTest.php \Drupal\config\Tests\ConfigSingleImportExportTest::testExport()

Tests exporting a single configuration file.

File

core/modules/config/src/Tests/ConfigSingleImportExportTest.php, line 190
Contains \Drupal\config\Tests\ConfigSingleImportExportTest.

Class

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

Namespace

Drupal\config\Tests

Code

public function testExport() {
  $this
    ->drupalLogin($this
    ->drupalCreateUser(array(
    '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"]');
  $options = $this
    ->getAllOptions($element[0]);
  $expected_options = array(
    'system.site',
    'user.settings',
  );
  foreach ($options as &$option) {
    $option = (string) $option;
  }
  $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
    ->assertFieldByXPath('//textarea[@name="export"]', "toolkit: gd\n", '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'), 'The fallback date format config entity is selected when specified in the URL.');
  $fallback_date = \Drupal::entityManager()
    ->getStorage('date_format')
    ->load('fallback');
  $data = Yaml::encode($fallback_date
    ->toArray());
  $this
    ->assertFieldByXPath('//textarea[@name="export"]', $data, 'The fallback date format config entity export code is displayed.');
}