Skip to content

Commit

Permalink
Added test for ApcStorageLock::releaseAll(); increased the number of …
Browse files Browse the repository at this point in the history
…locks used for tests
  • Loading branch information
avpaderno committed Feb 17, 2025
1 parent c34044d commit 04d3f99
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/apc_storage_lock.test
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ApcStorageLockTestCase extends ApcStorageBaseTestCase {
'lock_' . $this->randomName(),
'lock_' . $this->randomName(),
'lock_' . $this->randomName(),
'lock_' . $this->randomName(),
);
$count = 0;

Expand Down Expand Up @@ -185,7 +186,7 @@ class ApcStorageLockTestCase extends ApcStorageBaseTestCase {
}

/**
* Tests that ApcStorageLock::waitForLock() correctly works.
* Tests that ApcStorageLock::waitForLock() works correctly.
*/
public function testWait(): void {
if ($this->skipTest) {
Expand All @@ -210,4 +211,31 @@ class ApcStorageLockTestCase extends ApcStorageBaseTestCase {
}
}

/**
* Tests that ApcStorageLock::releaseAll() works correctly.
*/
public function testReleaseAll(): void {
if ($this->skipTest) {
return;
}

if (!$this->assertApcuEmpty()) {
return;
}

if ($this->assertTrue($this->initLocks(), 'All the locks have been created.')) {
$this->acquireLocks(2.0, 4.0);

ApcStorageLock::releaseAll();

foreach ($this->lockNames as $name) {
$message = format_string(
'The @name lock is available after all locks have been released.',
array('@name' => $name)
);

$this->assertTrue(ApcStorageLock::get($name)->maybeAvailable(), $message);
}
}
}
}

0 comments on commit 04d3f99

Please sign in to comment.