mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 14:00:31 +02:00
[feature/system-cron] Make use of the new config class in locks.
PHPBB3-9596
This commit is contained in:
committed by
Oleg Pudeyev
parent
311a7ff753
commit
165b0ec0b2
@@ -25,22 +25,21 @@ class phpbb_lock_db_test extends phpbb_database_test_case
|
||||
global $db, $config;
|
||||
|
||||
$db = $this->db = $this->new_dbal();
|
||||
$config = $this->config = array('rand_seed' => '', 'rand_seed_last_update' => '0');
|
||||
$config = $this->config = new phpbb_config(array('rand_seed' => '', 'rand_seed_last_update' => '0'));
|
||||
set_config(null, null, null, $this->config);
|
||||
$this->lock = new phpbb_lock_db('test_lock', $this->config, $this->db);
|
||||
}
|
||||
|
||||
public function test_new_lock()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$this->assertTrue($this->lock->lock());
|
||||
$this->assertTrue(isset($config['test_lock']), 'Lock was created');
|
||||
$this->assertTrue(isset($this->config['test_lock']), 'Lock was created');
|
||||
|
||||
$lock2 = new phpbb_lock_db('test_lock', $config, $this->db);
|
||||
$lock2 = new phpbb_lock_db('test_lock', $this->config, $this->db);
|
||||
$this->assertFalse($lock2->lock());
|
||||
|
||||
$this->lock->unlock();
|
||||
$this->assertEquals('0', $config['test_lock'], 'Lock was released');
|
||||
$this->assertEquals('0', $this->config['test_lock'], 'Lock was released');
|
||||
}
|
||||
|
||||
public function test_expire_lock()
|
||||
@@ -51,17 +50,34 @@ class phpbb_lock_db_test extends phpbb_database_test_case
|
||||
|
||||
public function test_double_lock()
|
||||
{
|
||||
global $config;
|
||||
$this->assertTrue($this->lock->lock());
|
||||
$this->assertTrue(isset($this->config['test_lock']), 'Lock was created');
|
||||
|
||||
$value = $this->config['test_lock'];
|
||||
|
||||
$this->assertTrue($this->lock->lock());
|
||||
$this->assertTrue(isset($config['test_lock']), 'Lock was created');
|
||||
|
||||
$value = $config['test_lock'];
|
||||
|
||||
$this->assertTrue($this->lock->lock());
|
||||
$this->assertEquals($value, $config['test_lock'], 'Second lock was ignored');
|
||||
$this->assertEquals($value, $this->config['test_lock'], 'Second lock was ignored');
|
||||
|
||||
$this->lock->unlock();
|
||||
$this->assertEquals('0', $config['test_lock'], 'Lock was released');
|
||||
$this->assertEquals('0', $this->config['test_lock'], 'Lock was released');
|
||||
}
|
||||
|
||||
public function test_double_unlock()
|
||||
{
|
||||
$this->assertTrue($this->lock->lock());
|
||||
$this->assertFalse(empty($this->config['test_lock']), 'First lock is acquired');
|
||||
|
||||
$this->lock->unlock();
|
||||
$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->lock());
|
||||
$this->assertFalse(empty($this->config['test_lock']), 'Second lock is acquired');
|
||||
|
||||
$this->lock->unlock();
|
||||
$this->assertFalse(empty($this->config['test_lock']), 'Double release of first lock is ignored');
|
||||
|
||||
$lock2->unlock();
|
||||
$this->assertEquals('0', $this->config['test_lock'], 'Second lock is released');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user