You are here

public function ConfigImportUITest::testImportLock 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::testImportLock()

Tests concurrent importing of configuration.

File

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

Class

ConfigImportUITest
Tests the user interface for importing configuration.

Namespace

Drupal\Tests\config\Functional

Code

public function testImportLock() {

  // Create updated configuration object.
  $new_site_name = 'Config import test ' . $this
    ->randomString();
  $this
    ->prepareSiteNameUpdate($new_site_name);

  // Verify that there are configuration differences to import.
  $this
    ->drupalGet('admin/config/development/configuration');
  $this
    ->assertNoText(t('There are no configuration changes to import.'));

  // Acquire a fake-lock on the import mechanism.
  $config_importer = $this
    ->configImporter();
  $this->container
    ->get('lock.persistent')
    ->acquire($config_importer::LOCK_NAME);

  // Attempt to import configuration and verify that an error message appears.
  $this
    ->drupalPostForm(NULL, [], t('Import all'));
  $this
    ->assertText(t('Another request may be synchronizing configuration already.'));

  // Release the lock, just to keep testing sane.
  $this->container
    ->get('lock.persistent')
    ->release($config_importer::LOCK_NAME);

  // Verify site name has not changed.
  $this
    ->assertNotEqual($new_site_name, $this
    ->config('system.site')
    ->get('name'));
}