You are here

public function ConfigImportUITest::testImportSiteUuidValidation in Drupal 9

Same name and namespace in other branches
  1. 8 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 259

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
    ->assertSession()
    ->pageTextContains('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
    ->assertSession()
    ->buttonNotExists('Import all');
}