[ticket/12658] Add test for command config:increment

PHPBB3-12658
This commit is contained in:
LEZY Thomas 2014-06-05 11:32:46 +02:00 committed by Tristan Darricau
parent 9affb8c171
commit 3fbab9504b

View file

@ -167,6 +167,58 @@ class phpbb_console_command_config_test extends phpbb_test_case
$this->assertContains('Could not get config', $command_tester->getDisplay());
}
public function test_increment_dynamic()
{
$this->config->set('test_key', 0, false);
$this->assertSame($this->config['test_key'], 0);
$this->class_name = 'increment';
$command_tester = $this->get_command_tester();
$command_tester->execute(array(
'command' => $this->command_name,
'key' => 'test_key',
'increment' => 2,
'--dynamic' => true,
));
$this->assertContains('Successfully incremented config test_key', $command_tester->getDisplay());
$this->assertSame(2, $this->config['test_key']);
}
public function test_increment_no_dynamic()
{
$this->config->set('test_key', 0, false);
$this->assertSame($this->config['test_key'], 0);
$this->class_name = 'increment';
$command_tester = $this->get_command_tester();
$command_tester->execute(array(
'command' => $this->command_name,
'key' => 'test_key',
'increment' => 2,
'--dynamic' => false,
));
$this->assertContains('Successfully incremented config test_key', $command_tester->getDisplay());
$this->assertSame(2, $this->config['test_key']);
}
public function test_increment_no_set()
{
$this->assertEmpty($this->config);
$this->class_name = 'increment';
$command_tester = $this->get_command_tester();
$command_tester->execute(array(
'command' => $this->command_name,
'key' => 'test_key',
'increment' => 2,
'--dynamic' => true,
));
$this->assertContains('Successfully incremented config test_key', $command_tester->getDisplay());
$this->assertSame(2, $this->config['test_key']);
}
public function get_command_tester()
{
$command_complete_name = $this->command_namespace . '\\' . $this->class_name;