diff options
author | LEZY Thomas <thomas.lezy@ensimag.grenoble-inp.fr> | 2014-06-05 10:44:55 +0200 |
---|---|---|
committer | Tristan Darricau <github@nicofuma.fr> | 2014-08-23 12:41:35 +0200 |
commit | ede73b207b139a991181284cd0cc0daf96139384 (patch) | |
tree | 5a1803952c6e3546cc237934b1c1417ac4cd11d1 /tests | |
parent | 1662ee64e0c70dc10e08c52294a1227d6e283741 (diff) | |
download | forums-ede73b207b139a991181284cd0cc0daf96139384.tar forums-ede73b207b139a991181284cd0cc0daf96139384.tar.gz forums-ede73b207b139a991181284cd0cc0daf96139384.tar.bz2 forums-ede73b207b139a991181284cd0cc0daf96139384.tar.xz forums-ede73b207b139a991181284cd0cc0daf96139384.zip |
[ticket/12658] Add test for command config:set-atomic
PHPBB3-12658
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); |