function ConfigImportUITest::testImportLock

Tests concurrent importing of configuration.

File

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

Class

ConfigImportUITest
Tests importing configuration from files into active store.

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/sync');
  $this
    ->assertNoText(t('There are no configuration changes.'));

  // Acquire a fake-lock on the import mechanism.
  lock()
    ->acquire('config_import');

  // Attempt to import configuration and verify that an error message appears.
  $this
    ->drupalPost(NULL, array(), t('Import all'));
  $this
    ->assertUrl('admin/config/development/sync');
  $this
    ->assertText(t('Another request may be synchronizing configuration already.'));

  // Release the lock, just to keep testing sane.
  lock()
    ->release('config_import');

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