mirror of
https://github.com/friendica/friendica
synced 2025-04-30 02:24:23 +02:00
Console Lock
WIP
This commit is contained in:
parent
425876316f
commit
41e2031e6b
9 changed files with 420 additions and 25 deletions
|
@ -23,12 +23,12 @@ abstract class LockTest extends MockedTest
|
|||
parent::setUp();
|
||||
|
||||
$this->instance = $this->getInstance();
|
||||
$this->instance->releaseAll();
|
||||
$this->instance->releaseAll(true);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->instance->releaseAll();
|
||||
$this->instance->releaseAll(true);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,46 @@ abstract class LockTest extends MockedTest
|
|||
$this->assertFalse($this->instance->isLocked('test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @small
|
||||
*/
|
||||
public function testGetLocks()
|
||||
{
|
||||
$this->assertTrue($this->instance->acquireLock('foo', 1));
|
||||
$this->assertTrue($this->instance->acquireLock('bar', 1));
|
||||
$this->assertTrue($this->instance->acquireLock('nice', 1));
|
||||
|
||||
$this->assertTrue($this->instance->isLocked('foo'));
|
||||
$this->assertTrue($this->instance->isLocked('bar'));
|
||||
$this->assertTrue($this->instance->isLocked('nice'));
|
||||
|
||||
$locks = $this->instance->getLocks();
|
||||
|
||||
$this->assertContains('foo', $locks);
|
||||
$this->assertContains('bar', $locks);
|
||||
$this->assertContains('nice', $locks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @small
|
||||
*/
|
||||
public function testGetLocksWithPrefix()
|
||||
{
|
||||
$this->assertTrue($this->instance->acquireLock('foo', 1));
|
||||
$this->assertTrue($this->instance->acquireLock('test1', 1));
|
||||
$this->assertTrue($this->instance->acquireLock('test2', 1));
|
||||
|
||||
$this->assertTrue($this->instance->isLocked('foo'));
|
||||
$this->assertTrue($this->instance->isLocked('test1'));
|
||||
$this->assertTrue($this->instance->isLocked('test2'));
|
||||
|
||||
$locks = $this->instance->getLocks('test');
|
||||
|
||||
$this->assertContains('test1', $locks);
|
||||
$this->assertContains('test2', $locks);
|
||||
$this->assertNotContains('foo', $locks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @medium
|
||||
*/
|
||||
|
|
|
@ -12,8 +12,6 @@ class SemaphoreLockTest extends LockTest
|
|||
{
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$dice = \Mockery::mock(Dice::class)->makePartial();
|
||||
|
||||
$app = \Mockery::mock(App::class);
|
||||
|
@ -29,6 +27,8 @@ class SemaphoreLockTest extends LockTest
|
|||
|
||||
// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
|
||||
BaseObject::setDependencyInjection($dice);
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
protected function getInstance()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue