From 1662ee64e0c70dc10e08c52294a1227d6e283741 Mon Sep 17 00:00:00 2001 From: LEZY Thomas Date: Thu, 5 Jun 2014 10:12:04 +0200 Subject: [PATCH 1/9] [ticket/12658] Add test for base case of command config:set PHPBB3-12658 --- tests/console/config/config_test.php | 71 ++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/console/config/config_test.php diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php new file mode 100644 index 0000000000..c17c78eb7e --- /dev/null +++ b/tests/console/config/config_test.php @@ -0,0 +1,71 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; + +class phpbb_console_command_config_test extends phpbb_test_case +{ + protected $config; + protected $command_name; + protected $comand_namespace; + + public function setUp() + { + $this->config = new \phpbb\config\config(array()); + } + + public function test_set_dynamic() + { + $this->assertEmpty($this->config); + + $this->command_namespace = '\phpbb\console\command\config'; + $this->command_name = 'set'; + $command_tester = $this->get_command_tester(); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'value' => 'test_value', + '--dynamic' => true, + )); + + $this->assertSame($this->config['test_key'],'test_value'); + } + + public function test_set_no_dynamic() + { + $this->assertEmpty($this->config); + + $this->command_namespace = '\phpbb\console\command\config'; + $this->command_name = 'set'; + $command_tester = $this->get_command_tester(); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'value' => 'test_value', + '--dynamic' => false, + )); + + $this->assertSame($this->config['test_key'],'test_value'); + } + + public function get_command_tester() + { + $command_complete_name = $this->command_namespace . '\\' . $this->command_name; + $application = new Application(); + $application->add(new $command_complete_name($this->config)); + $command = $application->find('config:' . $this->command_name); + $this->command_name = $command->getName(); + return new CommandTester($command); + } +} From ede73b207b139a991181284cd0cc0daf96139384 Mon Sep 17 00:00:00 2001 From: LEZY Thomas Date: Thu, 5 Jun 2014 10:44:55 +0200 Subject: [PATCH 2/9] [ticket/12658] Add test for command config:set-atomic PHPBB3-12658 --- tests/console/config/config_test.php | 70 ++++++++++++++++++++++++++-- 1 file 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); From 9affb8c171e7c292b85be4145ea7c013b8da5995 Mon Sep 17 00:00:00 2001 From: LEZY Thomas Date: Thu, 5 Jun 2014 11:06:37 +0200 Subject: [PATCH 3/9] [ticket/12658] Add test for command config:get PHPBB3-12658 --- tests/console/config/config_test.php | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php index 86cba12401..fc019e3873 100644 --- a/tests/console/config/config_test.php +++ b/tests/console/config/config_test.php @@ -119,6 +119,54 @@ class phpbb_console_command_config_test extends phpbb_test_case $this->assertSame($this->config['test_key'],'wrong_value'); } + public function test_get_no_new_line() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'],'test_value'); + + $this->class_name = 'get'; + $command_tester = $this->get_command_tester(); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + '--no-newline' => true, + )); + + $this->assertSame($this->config['test_key'], $command_tester->getDisplay()); + } + + public function test_get_new_line() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'],'test_value'); + + $this->class_name = 'get'; + $command_tester = $this->get_command_tester(); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + '--no-newline' => false, + )); + + $this->assertSame($this->config['test_key'] . "\n", $command_tester->getDisplay()); + } + + public function test_get_error() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'],'test_value'); + + $this->class_name = 'get'; + $command_tester = $this->get_command_tester(); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'wrong_key', + '--no-newline' => false, + )); + + $this->assertContains('Could not get config', $command_tester->getDisplay()); + } + public function get_command_tester() { $command_complete_name = $this->command_namespace . '\\' . $this->class_name; From 3fbab9504bb18c42b644aaf4e571108665cce50d Mon Sep 17 00:00:00 2001 From: LEZY Thomas Date: Thu, 5 Jun 2014 11:32:46 +0200 Subject: [PATCH 4/9] [ticket/12658] Add test for command config:increment PHPBB3-12658 --- tests/console/config/config_test.php | 74 +++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php index fc019e3873..95269e719f 100644 --- a/tests/console/config/config_test.php +++ b/tests/console/config/config_test.php @@ -40,7 +40,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--dynamic' => true, )); - $this->assertSame($this->config['test_key'],'test_value'); + $this->assertSame($this->config['test_key'], 'test_value'); } public function test_set_no_dynamic() @@ -56,7 +56,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--dynamic' => false, )); - $this->assertSame($this->config['test_key'],'test_value'); + $this->assertSame($this->config['test_key'], 'test_value'); } public function test_set_atomic_dynamic() @@ -64,7 +64,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $this->assertEmpty($this->config); $this->config->set('test_key', 'old_value', true); - $this->assertSame($this->config['test_key'],'old_value'); + $this->assertSame($this->config['test_key'], 'old_value'); $this->class_name = 'set_atomic'; $command_tester = $this->get_command_tester(); @@ -76,7 +76,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--dynamic' => true, )); - $this->assertSame($this->config['test_key'],'new_value'); + $this->assertSame($this->config['test_key'], 'new_value'); } public function test_set_atomic_no_dynamic() @@ -84,7 +84,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $this->assertEmpty($this->config); $this->config->set('test_key', 'old_value', false); - $this->assertSame($this->config['test_key'],'old_value'); + $this->assertSame($this->config['test_key'], 'old_value'); $this->class_name = 'set_atomic'; $command_tester = $this->get_command_tester(); @@ -96,7 +96,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--dynamic' => false )); - $this->assertSame($this->config['test_key'],'new_value'); + $this->assertSame($this->config['test_key'], 'new_value'); } public function test_set_atomic_error_dynamic() @@ -104,7 +104,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $this->assertEmpty($this->config); $this->config->set('test_key', 'wrong_value', true); - $this->assertSame($this->config['test_key'],'wrong_value'); + $this->assertSame($this->config['test_key'], 'wrong_value'); $this->class_name = 'set_atomic'; $command_tester = $this->get_command_tester(); @@ -116,13 +116,13 @@ class phpbb_console_command_config_test extends phpbb_test_case '--dynamic' => true, )); - $this->assertSame($this->config['test_key'],'wrong_value'); + $this->assertSame($this->config['test_key'], 'wrong_value'); } public function test_get_no_new_line() { $this->config->set('test_key', 'test_value', false); - $this->assertSame($this->config['test_key'],'test_value'); + $this->assertSame($this->config['test_key'], 'test_value'); $this->class_name = 'get'; $command_tester = $this->get_command_tester(); @@ -138,7 +138,7 @@ class phpbb_console_command_config_test extends phpbb_test_case public function test_get_new_line() { $this->config->set('test_key', 'test_value', false); - $this->assertSame($this->config['test_key'],'test_value'); + $this->assertSame($this->config['test_key'], 'test_value'); $this->class_name = 'get'; $command_tester = $this->get_command_tester(); @@ -154,7 +154,7 @@ class phpbb_console_command_config_test extends phpbb_test_case public function test_get_error() { $this->config->set('test_key', 'test_value', false); - $this->assertSame($this->config['test_key'],'test_value'); + $this->assertSame($this->config['test_key'], 'test_value'); $this->class_name = 'get'; $command_tester = $this->get_command_tester(); @@ -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; From f9803b73603fc02be8a8d5dcb3366cd5df769498 Mon Sep 17 00:00:00 2001 From: LEZY Thomas Date: Thu, 5 Jun 2014 14:07:39 +0200 Subject: [PATCH 5/9] [ticket/12658] Add test for command config:delete PHPBB3-12658 --- tests/console/config/config_test.php | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php index 95269e719f..f9d7fe30e4 100644 --- a/tests/console/config/config_test.php +++ b/tests/console/config/config_test.php @@ -219,6 +219,40 @@ class phpbb_console_command_config_test extends phpbb_test_case $this->assertContains('Successfully incremented config test_key', $command_tester->getDisplay()); $this->assertSame(2, $this->config['test_key']); } + + public function test_delete_ok() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'], 'test_value'); + + $this->class_name = 'delete'; + + $command_tester = $this->get_command_tester(); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + )); + + $this->assertContains('Successfully deleted config test_key', $command_tester->getDisplay()); + $this->assertEmpty($this->config); + } + + public function test_delete_error() + { + $this->assertEmpty($this->config); + + $this->class_name = 'delete'; + + $command_tester = $this->get_command_tester(); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'wrong_key', + )); + + $this->assertContains('Config wrong_key does not exist', $command_tester->getDisplay()); + $this->assertEmpty($this->config); + } + public function get_command_tester() { $command_complete_name = $this->command_namespace . '\\' . $this->class_name; From ab6c9775d33deceb87e06edc13585e6f345d3e74 Mon Sep 17 00:00:00 2001 From: LEZY Thomas Date: Thu, 5 Jun 2014 16:07:52 +0200 Subject: [PATCH 6/9] [ticket/12658] Fix typo and coding style mistakes PHPBB3-12658 --- tests/console/config/config_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php index f9d7fe30e4..47e1691b5c 100644 --- a/tests/console/config/config_test.php +++ b/tests/console/config/config_test.php @@ -19,7 +19,7 @@ class phpbb_console_command_config_test extends phpbb_test_case protected $config; protected $command_name; protected $class_name; - protected $comand_namespace; + protected $command_namespace; public function setUp() { @@ -93,7 +93,7 @@ class phpbb_console_command_config_test extends phpbb_test_case 'key' => 'test_key', 'old' => 'old_value', 'new' => 'new_value', - '--dynamic' => false + '--dynamic' => false, )); $this->assertSame($this->config['test_key'], 'new_value'); From 059f21a3ac54bd3e454b323090fbc03f1c5a0748 Mon Sep 17 00:00:00 2001 From: LEZY Thomas Date: Tue, 10 Jun 2014 09:00:39 +0200 Subject: [PATCH 7/9] [ticket/12658] Refactoring code PHPBB3-12658 --- tests/console/config/config_test.php | 48 +++++++++------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php index 47e1691b5c..5d10ab5e7a 100644 --- a/tests/console/config/config_test.php +++ b/tests/console/config/config_test.php @@ -18,21 +18,17 @@ class phpbb_console_command_config_test extends phpbb_test_case { protected $config; protected $command_name; - protected $class_name; - protected $command_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->class_name = 'set'; - $command_tester = $this->get_command_tester(); + $command_tester = $this->get_command_tester('set'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'test_key', @@ -47,8 +43,7 @@ class phpbb_console_command_config_test extends phpbb_test_case { $this->assertEmpty($this->config); - $this->class_name = 'set'; - $command_tester = $this->get_command_tester(); + $command_tester = $this->get_command_tester('set'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'test_key', @@ -66,8 +61,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $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 = $this->get_command_tester('set_atomic'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'test_key', @@ -86,8 +80,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $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 = $this->get_command_tester('set_atomic'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'test_key', @@ -106,8 +99,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $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 = $this->get_command_tester('set_atomic'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'test_key', @@ -124,8 +116,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $this->config->set('test_key', 'test_value', false); $this->assertSame($this->config['test_key'], 'test_value'); - $this->class_name = 'get'; - $command_tester = $this->get_command_tester(); + $command_tester = $this->get_command_tester('get'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'test_key', @@ -140,8 +131,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $this->config->set('test_key', 'test_value', false); $this->assertSame($this->config['test_key'], 'test_value'); - $this->class_name = 'get'; - $command_tester = $this->get_command_tester(); + $command_tester = $this->get_command_tester('get'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'test_key', @@ -156,8 +146,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $this->config->set('test_key', 'test_value', false); $this->assertSame($this->config['test_key'], 'test_value'); - $this->class_name = 'get'; - $command_tester = $this->get_command_tester(); + $command_tester = $this->get_command_tester('get'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'wrong_key', @@ -172,8 +161,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $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 = $this->get_command_tester('increment'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'test_key', @@ -190,8 +178,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $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 = $this->get_command_tester('increment'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'test_key', @@ -207,8 +194,7 @@ class phpbb_console_command_config_test extends phpbb_test_case { $this->assertEmpty($this->config); - $this->class_name = 'increment'; - $command_tester = $this->get_command_tester(); + $command_tester = $this->get_command_tester('increment'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'test_key', @@ -225,9 +211,7 @@ class phpbb_console_command_config_test extends phpbb_test_case $this->config->set('test_key', 'test_value', false); $this->assertSame($this->config['test_key'], 'test_value'); - $this->class_name = 'delete'; - - $command_tester = $this->get_command_tester(); + $command_tester = $this->get_command_tester('delete'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'test_key', @@ -241,9 +225,7 @@ class phpbb_console_command_config_test extends phpbb_test_case { $this->assertEmpty($this->config); - $this->class_name = 'delete'; - - $command_tester = $this->get_command_tester(); + $command_tester = $this->get_command_tester('delete'); $command_tester->execute(array( 'command' => $this->command_name, 'key' => 'wrong_key', @@ -253,9 +235,9 @@ class phpbb_console_command_config_test extends phpbb_test_case $this->assertEmpty($this->config); } - public function get_command_tester() + public function get_command_tester($class_name) { - $command_complete_name = $this->command_namespace . '\\' . $this->class_name; + $command_complete_name = '\phpbb\console\command\config' . '\\' . $class_name; $application = new Application(); $application->add(new $command_complete_name($this->config)); $command = $application->find('config:' . $this->command_name); From 5a4de4aa1f26596ecee53ba2573947d73dc77ab7 Mon Sep 17 00:00:00 2001 From: LEZY Thomas Date: Tue, 10 Jun 2014 09:56:11 +0200 Subject: [PATCH 8/9] [ticket/12658] Fix wrong eol character PHPBB3-12658 --- tests/console/config/config_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php index 5d10ab5e7a..b8d30d314f 100644 --- a/tests/console/config/config_test.php +++ b/tests/console/config/config_test.php @@ -138,7 +138,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--no-newline' => false, )); - $this->assertSame($this->config['test_key'] . "\n", $command_tester->getDisplay()); + $this->assertSame($this->config['test_key'] . PHP_EOL, $command_tester->getDisplay()); } public function test_get_error() From 91804b53fb262a4d7806edc51caedc9e12c71a75 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 23 Aug 2014 12:45:25 +0200 Subject: [PATCH 9/9] [ticket/12658] Rebased and fixed unit tests PHPBB3-12658 --- tests/console/config/config_test.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php index b8d30d314f..7c098af004 100644 --- a/tests/console/config/config_test.php +++ b/tests/console/config/config_test.php @@ -18,10 +18,14 @@ class phpbb_console_command_config_test extends phpbb_test_case { protected $config; protected $command_name; + protected $user; public function setUp() { $this->config = new \phpbb\config\config(array()); + + $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $this->user->method('lang')->will($this->returnArgument(0)); } public function test_set_dynamic() @@ -153,7 +157,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--no-newline' => false, )); - $this->assertContains('Could not get config', $command_tester->getDisplay()); + $this->assertContains('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay()); } public function test_increment_dynamic() @@ -169,7 +173,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--dynamic' => true, )); - $this->assertContains('Successfully incremented config test_key', $command_tester->getDisplay()); + $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); $this->assertSame(2, $this->config['test_key']); } @@ -186,7 +190,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--dynamic' => false, )); - $this->assertContains('Successfully incremented config test_key', $command_tester->getDisplay()); + $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); $this->assertSame(2, $this->config['test_key']); } @@ -202,7 +206,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--dynamic' => true, )); - $this->assertContains('Successfully incremented config test_key', $command_tester->getDisplay()); + $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); $this->assertSame(2, $this->config['test_key']); } @@ -217,7 +221,7 @@ class phpbb_console_command_config_test extends phpbb_test_case 'key' => 'test_key', )); - $this->assertContains('Successfully deleted config test_key', $command_tester->getDisplay()); + $this->assertContains('CLI_CONFIG_DELETE_SUCCESS', $command_tester->getDisplay()); $this->assertEmpty($this->config); } @@ -231,7 +235,7 @@ class phpbb_console_command_config_test extends phpbb_test_case 'key' => 'wrong_key', )); - $this->assertContains('Config wrong_key does not exist', $command_tester->getDisplay()); + $this->assertContains('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay()); $this->assertEmpty($this->config); } @@ -239,7 +243,7 @@ class phpbb_console_command_config_test extends phpbb_test_case { $command_complete_name = '\phpbb\console\command\config' . '\\' . $class_name; $application = new Application(); - $application->add(new $command_complete_name($this->config)); + $application->add(new $command_complete_name($this->user, $this->config)); $command = $application->find('config:' . $this->command_name); $this->command_name = $command->getName(); return new CommandTester($command);