function ConfigImportUITest::testImportDiff

Tests the screen that shows differences between active and staging.

File

drupal/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php, line 122
Definition of Drupal\config\Tests\ConfigImportUITest.

Class

ConfigImportUITest
Tests importing configuration from files into active store.

Namespace

Drupal\config\Tests

Code

function testImportDiff() {
  $active = $this->container
    ->get('config.storage');
  $staging = $this->container
    ->get('config.storage.staging');
  $config_name = 'config_test.system';
  $change_key = 'foo';
  $remove_key = '404';
  $add_key = 'biff';
  $add_data = 'bangpow';
  $change_data = 'foobar';
  $original_data = array(
    'foo' => 'bar',
    '404' => 'herp',
  );

  // Change a configuration value in staging.
  $staging_data = $original_data;
  $staging_data[$change_key] = $change_data;
  $staging_data[$add_key] = $add_data;
  $staging
    ->write($config_name, $staging_data);

  // Load the diff UI and verify that the diff reflects the change.
  $this
    ->drupalGet('admin/config/development/sync/diff/' . $config_name);
  $this
    ->assertTitle(format_string('View changes of @config_name | Drupal', array(
    '@config_name' => $config_name,
  )));

  // Reset data back to original, and remove a key
  $staging_data = $original_data;
  unset($staging_data[$remove_key]);
  $staging
    ->write($config_name, $staging_data);

  // Load the diff UI and verify that the diff reflects a removed key.
  $this
    ->drupalGet('admin/config/development/sync/diff/' . $config_name);

  // Reset data back to original and add a key
  $staging_data = $original_data;
  $staging_data[$add_key] = $add_data;
  $staging
    ->write($config_name, $staging_data);

  // Load the diff UI and verify that the diff reflects an added key.
  $this
    ->drupalGet('admin/config/development/sync/diff/' . $config_name);
}