You are here

function ConfigImportUITest::testImportLock in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/config/src/Tests/ConfigImportUITest.php \Drupal\config\Tests\ConfigImportUITest::testImportLock()

Tests concurrent importing of configuration.

File

core/modules/config/src/Tests/ConfigImportUITest.php, line 229
Contains \Drupal\config\Tests\ConfigImportUITest.

Class

ConfigImportUITest
Tests the user interface for importing/exporting configuration.

Namespace

Drupal\config\Tests

Code

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, array(), 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'));
}