function ExportStorageManagerTest::testGetStorageLock

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Config/ExportStorageManagerTest.php \Drupal\KernelTests\Core\Config\ExportStorageManagerTest::testGetStorageLock()
  2. 10 core/tests/Drupal/KernelTests/Core/Config/ExportStorageManagerTest.php \Drupal\KernelTests\Core\Config\ExportStorageManagerTest::testGetStorageLock()
  3. 11.x core/tests/Drupal/KernelTests/Core/Config/ExportStorageManagerTest.php \Drupal\KernelTests\Core\Config\ExportStorageManagerTest::testGetStorageLock()

Test the export storage when it is locked.

File

core/tests/Drupal/KernelTests/Core/Config/ExportStorageManagerTest.php, line 80

Class

ExportStorageManagerTest
Tests the export storage manager.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testGetStorageLock() {
    $lock = $this->createMock('Drupal\\Core\\Lock\\LockBackendInterface');
    $lock->expects($this->at(0))
        ->method('acquire')
        ->with(ExportStorageManager::LOCK_NAME)
        ->will($this->returnValue(FALSE));
    $lock->expects($this->at(1))
        ->method('wait')
        ->with(ExportStorageManager::LOCK_NAME);
    $lock->expects($this->at(2))
        ->method('acquire')
        ->with(ExportStorageManager::LOCK_NAME)
        ->will($this->returnValue(FALSE));
    // The export storage manager under test.
    $manager = new ExportStorageManager($this->container
        ->get('config.storage'), $this->container
        ->get('database'), $this->container
        ->get('event_dispatcher'), $lock);
    $this->expectException(StorageTransformerException::class);
    $this->expectExceptionMessage("Cannot acquire config export transformer lock.");
    $manager->getStorage();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.