public function ConfigImportUITest::testImportLock in Drupal 9
Same name and namespace in other branches
- 8 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 232
Class
- ConfigImportUITest
- Tests the user interface for importing configuration.
Namespace
Drupal\Tests\config\FunctionalCode
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
->assertSession()
->pageTextNotContains('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
->submitForm([], 'Import all');
$this
->assertSession()
->pageTextContains('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
->assertNotEquals($this
->config('system.site')
->get('name'), $new_site_name);
}