mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
[ticket/11495] Add owns_lock() method to lock classes
PHPBB3-11495
This commit is contained in:
@@ -32,13 +32,18 @@ class phpbb_lock_db_test extends phpbb_database_test_case
|
||||
|
||||
public function test_new_lock()
|
||||
{
|
||||
$this->assertFalse($this->lock->owns_lock());
|
||||
|
||||
$this->assertTrue($this->lock->acquire());
|
||||
$this->assertTrue($this->lock->owns_lock());
|
||||
$this->assertTrue(isset($this->config['test_lock']), 'Lock was created');
|
||||
|
||||
$lock2 = new phpbb_lock_db('test_lock', $this->config, $this->db);
|
||||
$this->assertFalse($lock2->acquire());
|
||||
$this->assertFalse($lock2->owns_lock());
|
||||
|
||||
$this->lock->release();
|
||||
$this->assertFalse($this->lock->owns_lock());
|
||||
$this->assertEquals('0', $this->config['test_lock'], 'Lock was released');
|
||||
}
|
||||
|
||||
@@ -50,31 +55,40 @@ class phpbb_lock_db_test extends phpbb_database_test_case
|
||||
|
||||
public function test_double_lock()
|
||||
{
|
||||
$this->assertFalse($this->lock->owns_lock());
|
||||
|
||||
$this->assertTrue($this->lock->acquire());
|
||||
$this->assertTrue($this->lock->owns_lock());
|
||||
$this->assertTrue(isset($this->config['test_lock']), 'Lock was created');
|
||||
|
||||
$value = $this->config['test_lock'];
|
||||
|
||||
$this->assertFalse($this->lock->acquire());
|
||||
$this->assertTrue($this->lock->owns_lock());
|
||||
$this->assertEquals($value, $this->config['test_lock'], 'Second lock failed');
|
||||
|
||||
$this->lock->release();
|
||||
$this->assertFalse($this->lock->owns_lock());
|
||||
$this->assertEquals('0', $this->config['test_lock'], 'Lock was released');
|
||||
}
|
||||
|
||||
public function test_double_unlock()
|
||||
{
|
||||
$this->assertTrue($this->lock->acquire());
|
||||
$this->assertTrue($this->lock->owns_lock());
|
||||
$this->assertFalse(empty($this->config['test_lock']), 'First lock is acquired');
|
||||
|
||||
$this->lock->release();
|
||||
$this->assertFalse($this->lock->owns_lock());
|
||||
$this->assertEquals('0', $this->config['test_lock'], 'First lock is released');
|
||||
|
||||
$lock2 = new phpbb_lock_db('test_lock', $this->config, $this->db);
|
||||
$this->assertTrue($lock2->acquire());
|
||||
$this->assertTrue($lock2->owns_lock());
|
||||
$this->assertFalse(empty($this->config['test_lock']), 'Second lock is acquired');
|
||||
|
||||
$this->lock->release();
|
||||
$this->assertTrue($lock2->owns_lock());
|
||||
$this->assertFalse(empty($this->config['test_lock']), 'Double release of first lock is ignored');
|
||||
|
||||
$lock2->release();
|
||||
|
Reference in New Issue
Block a user