public function LockUnitTest::testBackendLockRelease in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Lock/LockUnitTest.php \Drupal\system\Tests\Lock\LockUnitTest::testBackendLockRelease()
Tests backend release functionality.
File
- core/
modules/ system/ src/ Tests/ Lock/ LockUnitTest.php, line 43 - Contains \Drupal\system\Tests\Lock\LockUnitTest.
Class
- LockUnitTest
- Tests the Database lock backend.
Namespace
Drupal\system\Tests\LockCode
public function testBackendLockRelease() {
$success = $this->lock
->acquire('lock_a');
$this
->assertTrue($success, 'Could acquire first lock.');
// This function is not part of the backend, but the default database
// backend implement it, we can here use it safely.
$is_free = $this->lock
->lockMayBeAvailable('lock_a');
$this
->assertFalse($is_free, 'First lock is unavailable.');
$this->lock
->release('lock_a');
$is_free = $this->lock
->lockMayBeAvailable('lock_a');
$this
->assertTrue($is_free, 'First lock has been released.');
$success = $this->lock
->acquire('lock_b');
$this
->assertTrue($success, 'Could acquire second lock.');
$success = $this->lock
->acquire('lock_b');
$this
->assertTrue($success, 'Could acquire second lock a second time within the same request.');
$this->lock
->release('lock_b');
}