diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/console/config/config_test.php | 70 |
1 files changed, 65 insertions, 5 deletions
diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php index c17c78eb7e..86cba12401 100644 --- a/tests/console/config/config_test.php +++ b/tests/console/config/config_test.php @@ -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); |