You are here

public function ConfigImportUITest::testImportSiteUuidValidation in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/config/tests/src/Functional/ConfigImportUITest.php \Drupal\Tests\config\Functional\ConfigImportUITest::testImportSiteUuidValidation()
  2. 10 core/modules/config/tests/src/Functional/ConfigImportUITest.php \Drupal\Tests\config\Functional\ConfigImportUITest::testImportSiteUuidValidation()

Tests verification of site UUID before importing configuration.

File

core/modules/config/tests/src/Functional/ConfigImportUITest.php, line 261

Class

ConfigImportUITest
Tests the user interface for importing configuration.

Namespace

Drupal\Tests\config\Functional

Code

public function testImportSiteUuidValidation() {
  $sync = \Drupal::service('config.storage.sync');

  // Create updated configuration object.
  $config_data = $this
    ->config('system.site')
    ->get();

  // Generate a new site UUID.
  $config_data['uuid'] = \Drupal::service('uuid')
    ->generate();
  $sync
    ->write('system.site', $config_data);

  // Verify that there are configuration differences to import.
  $this
    ->drupalGet('admin/config/development/configuration');
  $this
    ->assertText(t('The staged configuration cannot be imported, because it originates from a different site than this site. You can only synchronize configuration between cloned instances of this site.'));
  $this
    ->assertNoFieldById('edit-submit', t('Import all'));
}