라이브러리 업데이트 catfan/medoo 추가
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Lock\Tests\Store;
|
||||
|
||||
use Symfony\Component\Lock\Key;
|
||||
use Symfony\Component\Lock\Store\SemaphoreStore;
|
||||
|
||||
/**
|
||||
@@ -29,4 +30,31 @@ class SemaphoreStoreTest extends AbstractStoreTest
|
||||
{
|
||||
return new SemaphoreStore();
|
||||
}
|
||||
|
||||
public function testResourceRemoval()
|
||||
{
|
||||
$initialCount = $this->getOpenedSemaphores();
|
||||
$store = new SemaphoreStore();
|
||||
$key = new Key(uniqid(__METHOD__, true));
|
||||
$store->waitAndSave($key);
|
||||
|
||||
$this->assertGreaterThan($initialCount, $this->getOpenedSemaphores(), 'Semaphores should have been created');
|
||||
|
||||
$store->delete($key);
|
||||
$this->assertEquals($initialCount, $this->getOpenedSemaphores(), 'All semaphores should be removed');
|
||||
}
|
||||
|
||||
private function getOpenedSemaphores()
|
||||
{
|
||||
$lines = explode(PHP_EOL, trim(`ipcs -su`));
|
||||
if ('------ Semaphore Status --------' !== $lines[0]) {
|
||||
throw new \Exception('Failed to extract list of opend semaphores. Expect a Semaphore status, got '.implode(PHP_EOL, $lines));
|
||||
}
|
||||
list($key, $value) = explode(' = ', $lines[1]);
|
||||
if ('used arrays' !== $key) {
|
||||
throw new \Exception('Failed to extract list of opend semaphores. Expect a used arrays key, got '.implode(PHP_EOL, $lines));
|
||||
}
|
||||
|
||||
return (int) $value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user