function ConfigImportCommandTest::testImportLock
Tests concurrent importing of configuration.
See also
\Drupal\Tests\config\Functional\ConfigImportUITest::testImportLock()
File
-
core/
tests/ Drupal/ FunctionalTests/ Core/ Config/ ConfigImportCommandTest.php, line 271
Class
- ConfigImportCommandTest
- Tests the 'config:import' command.
Namespace
Drupal\FunctionalTests\Core\ConfigCode
public function testImportLock() : void {
$new_site_name = 'Config import test ' . $this->randomMachineName();
$this->prepareSiteNameUpdate($new_site_name);
// Acquire a fake lock on the import mechanism.
$lock = $this->container
->get('lock.persistent');
$this->assertTrue($lock->acquire(ConfigImporter::LOCK_NAME));
// Attempt to import configuration and verify that an error message appears.
$tester = $this->commandTester();
$code = $tester->execute([
'--yes' => TRUE,
]);
self::assertSame(Command::FAILURE, $code);
self::assertStringContainsString('Another request may be synchronizing configuration already.', $tester->getDisplay());
// Release the lock, just to keep testing sane.
$lock->release(ConfigImporter::LOCK_NAME);
// Verify site name has not changed.
self::assertNotEquals($new_site_name, $this->config('system.site')
->get('name'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.