mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/12658] Add test for command config:set-atomic
PHPBB3-12658
This commit is contained in:
parent
1662ee64e0
commit
ede73b207b
1 changed files with 65 additions and 5 deletions
|
@ -18,19 +18,20 @@ class phpbb_console_command_config_test extends phpbb_test_case
|
|||
{
|
||||
protected $config;
|
||||
protected $command_name;
|
||||
protected $class_name;
|
||||
protected $comand_namespace;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->config = new \phpbb\config\config(array());
|
||||
$this->command_namespace = '\phpbb\console\command\config';
|
||||
}
|
||||
|
||||
public function test_set_dynamic()
|
||||
{
|
||||
$this->assertEmpty($this->config);
|
||||
|
||||
$this->command_namespace = '\phpbb\console\command\config';
|
||||
$this->command_name = 'set';
|
||||
$this->class_name = 'set';
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array(
|
||||
'command' => $this->command_name,
|
||||
|
@ -46,8 +47,7 @@ class phpbb_console_command_config_test extends phpbb_test_case
|
|||
{
|
||||
$this->assertEmpty($this->config);
|
||||
|
||||
$this->command_namespace = '\phpbb\console\command\config';
|
||||
$this->command_name = 'set';
|
||||
$this->class_name = 'set';
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array(
|
||||
'command' => $this->command_name,
|
||||
|
@ -59,9 +59,69 @@ class phpbb_console_command_config_test extends phpbb_test_case
|
|||
$this->assertSame($this->config['test_key'],'test_value');
|
||||
}
|
||||
|
||||
public function test_set_atomic_dynamic()
|
||||
{
|
||||
$this->assertEmpty($this->config);
|
||||
|
||||
$this->config->set('test_key', 'old_value', true);
|
||||
$this->assertSame($this->config['test_key'],'old_value');
|
||||
|
||||
$this->class_name = 'set_atomic';
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array(
|
||||
'command' => $this->command_name,
|
||||
'key' => 'test_key',
|
||||
'old' => 'old_value',
|
||||
'new' => 'new_value',
|
||||
'--dynamic' => true,
|
||||
));
|
||||
|
||||
$this->assertSame($this->config['test_key'],'new_value');
|
||||
}
|
||||
|
||||
public function test_set_atomic_no_dynamic()
|
||||
{
|
||||
$this->assertEmpty($this->config);
|
||||
|
||||
$this->config->set('test_key', 'old_value', false);
|
||||
$this->assertSame($this->config['test_key'],'old_value');
|
||||
|
||||
$this->class_name = 'set_atomic';
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array(
|
||||
'command' => $this->command_name,
|
||||
'key' => 'test_key',
|
||||
'old' => 'old_value',
|
||||
'new' => 'new_value',
|
||||
'--dynamic' => false
|
||||
));
|
||||
|
||||
$this->assertSame($this->config['test_key'],'new_value');
|
||||
}
|
||||
|
||||
public function test_set_atomic_error_dynamic()
|
||||
{
|
||||
$this->assertEmpty($this->config);
|
||||
|
||||
$this->config->set('test_key', 'wrong_value', true);
|
||||
$this->assertSame($this->config['test_key'],'wrong_value');
|
||||
|
||||
$this->class_name = 'set_atomic';
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array(
|
||||
'command' => $this->command_name,
|
||||
'key' => 'test_key',
|
||||
'old' => 'old_value',
|
||||
'new' => 'new_value',
|
||||
'--dynamic' => true,
|
||||
));
|
||||
|
||||
$this->assertSame($this->config['test_key'],'wrong_value');
|
||||
}
|
||||
|
||||
public function get_command_tester()
|
||||
{
|
||||
$command_complete_name = $this->command_namespace . '\\' . $this->command_name;
|
||||
$command_complete_name = $this->command_namespace . '\\' . $this->class_name;
|
||||
$application = new Application();
|
||||
$application->add(new $command_complete_name($this->config));
|
||||
$command = $application->find('config:' . $this->command_name);
|
||||
|
|
Loading…
Add table
Reference in a new issue