From 58d7302b495783edd6e0826c100ffa93acb0693d Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Mon, 2 Jun 2014 12:17:37 +0200 Subject: [PATCH 01/15] [ticket/12602] Add files to print the cron list and test files. PHPBB3-12602 --- phpBB/config/console.yml | 8 ++ phpBB/language/en/acp/common.php | 1 + .../phpbb/console/command/cron/cron_list.php | 80 ++++++++++++++ tests/console/cron/cron_list_test.php | 100 ++++++++++++++++++ tests/console/cron/tasks/simple_not_ready.php | 13 +++ .../cron/tasks/simple_not_runnable.php | 18 ++++ tests/console/cron/tasks/simple_ready.php | 13 +++ .../cron/tasks/simple_should_not_run.php | 18 ++++ 8 files changed, 251 insertions(+) create mode 100644 phpBB/phpbb/console/command/cron/cron_list.php create mode 100644 tests/console/cron/cron_list_test.php create mode 100644 tests/console/cron/tasks/simple_not_ready.php create mode 100644 tests/console/cron/tasks/simple_not_runnable.php create mode 100644 tests/console/cron/tasks/simple_ready.php create mode 100644 tests/console/cron/tasks/simple_should_not_run.php diff --git a/phpBB/config/console.yml b/phpBB/config/console.yml index a102a8c609..9b0f0aa9a4 100644 --- a/phpBB/config/console.yml +++ b/phpBB/config/console.yml @@ -46,6 +46,14 @@ services: tags: - { name: console.command } + console.command.cron.list: + class: phpbb\console\command\cron\cron_list + arguments: + - @cron.manager + - @user + tags: + - { name: console.command } + console.command.cron.run: class: phpbb\console\command\cron\run arguments: diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 838a73caed..36de5e07ad 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -223,6 +223,7 @@ $lang = array_merge($lang, array( 'BACK' => 'Back', + 'CLI_DESCRIPTION_CRON_LIST' => 'Print the cron list.', 'CLI_DESCRIPTION_CRON_RUN' => 'Runs all ready cron tasks.', 'CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1' => 'Name of the task to be run', diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php new file mode 100644 index 0000000000..0018d9542d --- /dev/null +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -0,0 +1,80 @@ +cron_manager = $cron_manager; + $this->user = $user; + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('cron:list') + ->setDescription($this->user->lang('CLI_DESCR_CRON_LIST')) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $tasks = $this->cron_manager->get_tasks(); + + if (empty($tasks)) + { + $output->writeln($this->user->lang('NO_TASK')); + return; + } + + $ready_tasks = array(); + $not_ready_tasks = array(); + foreach ($tasks as $task) + { + if ($task->is_ready()) + { + $ready_tasks[] = $task; + } + else + { + $not_ready_tasks[] = $task; + } + } + + if (!empty($ready_tasks)) + { + $output->writeln('' . $this->user->lang('TASKS_READY') . ''); + foreach ($ready_tasks as $task) + { + $output->writeln($task->get_name()); + } + $output->writeln(''); + } + + if (!empty($not_ready_tasks)) + { + $output->writeln('' . $this->user->lang('TASKS_NOT_READY') . ''); + foreach ($not_ready_tasks as $task) + { + $output->writeln($task->get_name()); + } + } + } +} diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php new file mode 100644 index 0000000000..12fac4a832 --- /dev/null +++ b/tests/console/cron/cron_list_test.php @@ -0,0 +1,100 @@ +user = $this->getMock('\phpbb\user'); + $this->user->method('lang')->will($this->returnArgument(0)); + } + + public function test_no_task() + { + $tasks = array(); + $this->get_cron_manager($tasks); + $command_tester = $this->get_command_tester(); + $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); + $this->assertContains('NO_TASK', $command_tester->getDisplay()); + } + + public function test_only_ready() + { + $tasks = array( + new phpbb_cron_task_simple(), + new phpbb_cron_task_simple() + ); + $this->get_cron_manager($tasks); + $command_tester = $this->get_command_tester(); + $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); + $this->assertContains('TASKS_READYcommand1command2', preg_replace('/\s+/', '', $command_tester->getDisplay())); + } + + public function test_only_not_ready() + { + $tasks = array( + new phpbb_cron_task_simple_not_ready(), + new phpbb_cron_task_simple_not_ready() + ); + $this->get_cron_manager($tasks); + $command_tester = $this->get_command_tester(); + $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); + $this->assertContains('TASKS_NOT_READYcommand1command2', preg_replace('/\s+/', '', $command_tester->getDisplay())); + } + + public function test_both_ready() + { + $tasks = array( + new phpbb_cron_task_simple(), + new phpbb_cron_task_simple(), + new phpbb_cron_task_simple_not_ready(), + new phpbb_cron_task_simple_not_ready() + ); + $this->get_cron_manager($tasks); + $command_tester = $this->get_command_tester(); + $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); + $this->assertSame('TASKS_READYcommand1command2TASKS_NOT_READYcommand3command4', preg_replace('/\s+/', '', $command_tester->getDisplay())); + } + + public function get_cron_manager(array $tasks) + { + global $pathEx, $phpbb_root_path; + $i = 1; + foreach ($tasks as $task) + { + $task->set_name('command' . $i); + $i++; + } + $this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $pathEx); + } + + public function get_command_tester() + { + $application = new Application(); + $application->add(new cron_list($this->cron_manager, $this->user)); + + $command = $application->find('cron:list'); + $this->command_name = $command->getName(); + return new CommandTester($command); + } +} diff --git a/tests/console/cron/tasks/simple_not_ready.php b/tests/console/cron/tasks/simple_not_ready.php new file mode 100644 index 0000000000..887768e5fe --- /dev/null +++ b/tests/console/cron/tasks/simple_not_ready.php @@ -0,0 +1,13 @@ + Date: Mon, 2 Jun 2014 15:58:02 +0200 Subject: [PATCH 02/15] [ticket/12602] Correction of the output message for the cron list PHPBB3-12602 --- phpBB/phpbb/console/command/cron/cron_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php index 0018d9542d..beedc3c932 100644 --- a/phpBB/phpbb/console/command/cron/cron_list.php +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -30,7 +30,7 @@ class cron_list extends \phpbb\console\command\command { $this ->setName('cron:list') - ->setDescription($this->user->lang('CLI_DESCR_CRON_LIST')) + ->setDescription($this->user->lang('CLI_DESCRIPTION_CRON_LIST')) ; } From 85e8d1c2efd5f3746ebd50c91ba9e95a98ecb28c Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Mon, 2 Jun 2014 16:12:47 +0200 Subject: [PATCH 03/15] [ticket/12602] Add function get_tasks. PHPBB3-12602 --- phpBB/phpbb/cron/manager.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/phpBB/phpbb/cron/manager.php b/phpBB/phpbb/cron/manager.php index 1eb8edf033..77dfcff471 100644 --- a/phpBB/phpbb/cron/manager.php +++ b/phpBB/phpbb/cron/manager.php @@ -121,6 +121,21 @@ class manager return null; } + /** + * Find all tasks and return them. + * + * @return array List of all tasks. + */ + public function get_tasks() + { + $tasks = array(); + foreach ($this->tasks as $task) + { + $tasks[] = $task; + } + return $tasks; + } + /** * Wraps a task inside an instance of \phpbb\cron\task\wrapper. * From c3ccef10d191c9d6ff5d655074a2a0b436788bcd Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 2 Jun 2014 16:21:25 +0200 Subject: [PATCH 04/15] [ticket/12602] Cleanup tests PHPBB3-12602 --- tests/console/cron/cron_list_test.php | 16 ++++++++-------- .../console/cron/tasks/simple_not_runnable.php | 18 ------------------ tests/console/cron/tasks/simple_ready.php | 7 +------ .../cron/tasks/simple_should_not_run.php | 18 ------------------ 4 files changed, 9 insertions(+), 50 deletions(-) delete mode 100644 tests/console/cron/tasks/simple_not_runnable.php delete mode 100644 tests/console/cron/tasks/simple_should_not_run.php diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index 12fac4a832..aabd3e388a 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -7,7 +7,7 @@ * */ -require_once dirname(__FILE__) . '/tasks/simple.php'; +require_once dirname(__FILE__) . '/tasks/simple_ready.php'; require_once dirname(__FILE__) . '/tasks/simple_not_ready.php'; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; @@ -41,13 +41,13 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case public function test_only_ready() { $tasks = array( - new phpbb_cron_task_simple(), - new phpbb_cron_task_simple() + new phpbb_cron_task_simple_ready(), + new phpbb_cron_task_simple_ready() ); $this->get_cron_manager($tasks); $command_tester = $this->get_command_tester(); $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); - $this->assertContains('TASKS_READYcommand1command2', preg_replace('/\s+/', '', $command_tester->getDisplay())); + $this->assertContains('TASKS_READY command1 command2', preg_replace('/\s+/', ' ', trim($command_tester->getDisplay()))); } public function test_only_not_ready() @@ -59,21 +59,21 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case $this->get_cron_manager($tasks); $command_tester = $this->get_command_tester(); $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); - $this->assertContains('TASKS_NOT_READYcommand1command2', preg_replace('/\s+/', '', $command_tester->getDisplay())); + $this->assertContains('TASKS_NOT_READY command1 command2', preg_replace('/\s+/', ' ', trim($command_tester->getDisplay()))); } public function test_both_ready() { $tasks = array( - new phpbb_cron_task_simple(), - new phpbb_cron_task_simple(), + new phpbb_cron_task_simple_ready(), + new phpbb_cron_task_simple_ready(), new phpbb_cron_task_simple_not_ready(), new phpbb_cron_task_simple_not_ready() ); $this->get_cron_manager($tasks); $command_tester = $this->get_command_tester(); $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); - $this->assertSame('TASKS_READYcommand1command2TASKS_NOT_READYcommand3command4', preg_replace('/\s+/', '', $command_tester->getDisplay())); + $this->assertSame('TASKS_READY command1 command2 TASKS_NOT_READY command3 command4', preg_replace('/\s+/', ' ', trim($command_tester->getDisplay()))); } public function get_cron_manager(array $tasks) diff --git a/tests/console/cron/tasks/simple_not_runnable.php b/tests/console/cron/tasks/simple_not_runnable.php deleted file mode 100644 index 4951b5b4b9..0000000000 --- a/tests/console/cron/tasks/simple_not_runnable.php +++ /dev/null @@ -1,18 +0,0 @@ - Date: Tue, 3 Jun 2014 10:42:50 +0200 Subject: [PATCH 05/15] [ticket/12602] Changes to respect coding style and to factorize code. PHPBB3-12602 --- .../phpbb/console/command/cron/cron_list.php | 22 ++++--- phpBB/phpbb/cron/manager.php | 7 +-- tests/console/cron/cron_list_test.php | 62 +++++++++---------- 3 files changed, 45 insertions(+), 46 deletions(-) diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php index beedc3c932..f95cb6fb03 100644 --- a/phpBB/phpbb/console/command/cron/cron_list.php +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -61,20 +61,26 @@ class cron_list extends \phpbb\console\command\command if (!empty($ready_tasks)) { $output->writeln('' . $this->user->lang('TASKS_READY') . ''); - foreach ($ready_tasks as $task) - { - $output->writeln($task->get_name()); - } + $this->print_tasks_names($ready_tasks, $output); + } + + if (!empty($ready_tasks) && !empty($not_ready_tasks)) + { $output->writeln(''); } if (!empty($not_ready_tasks)) { $output->writeln('' . $this->user->lang('TASKS_NOT_READY') . ''); - foreach ($not_ready_tasks as $task) - { - $output->writeln($task->get_name()); - } + $this->print_tasks_names($not_ready_tasks, $output); + } + } + + public function print_tasks_names ($tasks, $output) + { + foreach ($tasks as $task) + { + $output->writeln($task->get_name()); } } } diff --git a/phpBB/phpbb/cron/manager.php b/phpBB/phpbb/cron/manager.php index 77dfcff471..f04f063228 100644 --- a/phpBB/phpbb/cron/manager.php +++ b/phpBB/phpbb/cron/manager.php @@ -128,12 +128,7 @@ class manager */ public function get_tasks() { - $tasks = array(); - foreach ($this->tasks as $task) - { - $tasks[] = $task; - } - return $tasks; + return $this->tasks; } /** diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index aabd3e388a..dd4a33ee62 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -23,6 +23,8 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case protected $command_name; + protected $command_tester; + protected function setUp() { $this->user = $this->getMock('\phpbb\user'); @@ -31,49 +33,26 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case public function test_no_task() { - $tasks = array(); - $this->get_cron_manager($tasks); - $command_tester = $this->get_command_tester(); - $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); - $this->assertContains('NO_TASK', $command_tester->getDisplay()); + $this->initiate_test(0,0); + $this->assertContains('NO_TASK', $this->command_tester->getDisplay()); } public function test_only_ready() { - $tasks = array( - new phpbb_cron_task_simple_ready(), - new phpbb_cron_task_simple_ready() - ); - $this->get_cron_manager($tasks); - $command_tester = $this->get_command_tester(); - $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); - $this->assertContains('TASKS_READY command1 command2', preg_replace('/\s+/', ' ', trim($command_tester->getDisplay()))); + $this->initiate_test(2,0); + $this->assertContains('TASKS_READY command1 command2', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); } public function test_only_not_ready() { - $tasks = array( - new phpbb_cron_task_simple_not_ready(), - new phpbb_cron_task_simple_not_ready() - ); - $this->get_cron_manager($tasks); - $command_tester = $this->get_command_tester(); - $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); - $this->assertContains('TASKS_NOT_READY command1 command2', preg_replace('/\s+/', ' ', trim($command_tester->getDisplay()))); + $this->initiate_test(0,2); + $this->assertContains('TASKS_NOT_READY command1 command2', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); } public function test_both_ready() { - $tasks = array( - new phpbb_cron_task_simple_ready(), - new phpbb_cron_task_simple_ready(), - new phpbb_cron_task_simple_not_ready(), - new phpbb_cron_task_simple_not_ready() - ); - $this->get_cron_manager($tasks); - $command_tester = $this->get_command_tester(); - $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); - $this->assertSame('TASKS_READY command1 command2 TASKS_NOT_READY command3 command4', preg_replace('/\s+/', ' ', trim($command_tester->getDisplay()))); + $this->initiate_test(2,2); + $this->assertSame('TASKS_READY command1 command2 TASKS_NOT_READY command3 command4', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); } public function get_cron_manager(array $tasks) @@ -97,4 +76,23 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case $this->command_name = $command->getName(); return new CommandTester($command); } -} + + public function initiate_test ($number_ready, $number_not_ready) + { + $tasks = array(); + + for ($i = 0; $i < $number_ready; $i++) + { + $tasks[] = new phpbb_cron_task_simple_ready(); + } + + for ($i = 0; $i < $number_not_ready; $i++) + { + $tasks[] = new phpbb_cron_task_simple_not_ready(); + } + + $this->get_cron_manager($tasks); + $this->command_tester = $this->get_command_tester(); + $this->command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); + } +} \ No newline at end of file From 721a1d0bc49fce52a8e438946a58ba0ca6db2f28 Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Tue, 3 Jun 2014 10:50:00 +0200 Subject: [PATCH 06/15] [ticket/12602] Headers updated. PHPBB3-12602 --- phpBB/phpbb/console/command/cron/cron_list.php | 10 +++++++--- tests/console/cron/cron_list_test.php | 16 ++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php index f95cb6fb03..c933bc6d69 100644 --- a/phpBB/phpbb/console/command/cron/cron_list.php +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ namespace phpbb\console\command\cron; diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index dd4a33ee62..921de31703 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -1,11 +1,15 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ require_once dirname(__FILE__) . '/tasks/simple_ready.php'; require_once dirname(__FILE__) . '/tasks/simple_not_ready.php'; From 5aca27e8cfc0f9387bc62756c8f296e2cec823a3 Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Tue, 3 Jun 2014 10:54:28 +0200 Subject: [PATCH 07/15] [ticket/12602] Fix coding style mistakes. PHPBB3-12602 --- phpBB/language/en/acp/common.php | 2 +- phpBB/phpbb/console/command/cron/cron_list.php | 1 + tests/console/cron/cron_list_test.php | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 36de5e07ad..c3a946466f 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -223,7 +223,7 @@ $lang = array_merge($lang, array( 'BACK' => 'Back', - 'CLI_DESCRIPTION_CRON_LIST' => 'Print the cron list.', + 'CLI_DESCRIPTION_CRON_LIST' => 'Print the cron list.', 'CLI_DESCRIPTION_CRON_RUN' => 'Runs all ready cron tasks.', 'CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1' => 'Name of the task to be run', diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php index c933bc6d69..c6677db1f5 100644 --- a/phpBB/phpbb/console/command/cron/cron_list.php +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -88,3 +88,4 @@ class cron_list extends \phpbb\console\command\command } } } + diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index 921de31703..32b7c792e8 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -13,6 +13,7 @@ require_once dirname(__FILE__) . '/tasks/simple_ready.php'; require_once dirname(__FILE__) . '/tasks/simple_not_ready.php'; + use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\cron\cron_list; @@ -99,4 +100,4 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case $this->command_tester = $this->get_command_tester(); $this->command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); } -} \ No newline at end of file +} From 7c22d653e92af46375a6547be7e9b2527bc3d385 Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Wed, 4 Jun 2014 15:50:09 +0200 Subject: [PATCH 08/15] [ticket/12602] Coding style correction. PHPBB3-12602 --- phpBB/phpbb/console/command/cron/cron_list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php index c6677db1f5..c933bc6d69 100644 --- a/phpBB/phpbb/console/command/cron/cron_list.php +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -88,4 +88,3 @@ class cron_list extends \phpbb\console\command\command } } } - From 442e12828b827239806e84dcd77641cfc5daca57 Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Wed, 4 Jun 2014 21:56:55 +0200 Subject: [PATCH 09/15] [ticket/12602] Fix spaces issues. PHPBB3-12602 --- phpBB/phpbb/console/command/cron/cron_list.php | 2 +- tests/console/cron/cron_list_test.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php index c933bc6d69..9d9a3bdef7 100644 --- a/phpBB/phpbb/console/command/cron/cron_list.php +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -80,7 +80,7 @@ class cron_list extends \phpbb\console\command\command } } - public function print_tasks_names ($tasks, $output) + public function print_tasks_names($tasks, $output) { foreach ($tasks as $task) { diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index 32b7c792e8..ad74f17875 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -38,25 +38,25 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case public function test_no_task() { - $this->initiate_test(0,0); + $this->initiate_test(0, 0); $this->assertContains('NO_TASK', $this->command_tester->getDisplay()); } public function test_only_ready() { - $this->initiate_test(2,0); + $this->initiate_test(2, 0); $this->assertContains('TASKS_READY command1 command2', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); } public function test_only_not_ready() { - $this->initiate_test(0,2); + $this->initiate_test(0, 2); $this->assertContains('TASKS_NOT_READY command1 command2', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); } public function test_both_ready() { - $this->initiate_test(2,2); + $this->initiate_test(2, 2); $this->assertSame('TASKS_READY command1 command2 TASKS_NOT_READY command3 command4', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); } @@ -82,7 +82,7 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case return new CommandTester($command); } - public function initiate_test ($number_ready, $number_not_ready) + public function initiate_test($number_ready, $number_not_ready) { $tasks = array(); From f119e060b72b82f5b4242129a647d828370b6c49 Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Thu, 5 Jun 2014 09:12:44 +0200 Subject: [PATCH 10/15] [ticket/12602] Fix internationalisation of cron_list.php PHPBB3-12602 --- phpBB/language/en/acp/common.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index c3a946466f..a192ec396d 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -303,6 +303,8 @@ $lang = array_merge($lang, array( 'SHOW_ALL_OPERATIONS' => 'Show all operations', + 'TASKS_NOT_READY' => 'Not ready tasks:', + 'TASKS_READY' => 'Ready tasks:', 'TOTAL_SIZE' => 'Total size', 'UCP' => 'User Control Panel', From c6999481e7ebd4c24127161ad2b51d8c3e15dc05 Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Thu, 5 Jun 2014 15:11:15 +0200 Subject: [PATCH 11/15] [ticket/12602] Add types, change description of cron:list. PHPBB3-12602 --- phpBB/language/en/acp/common.php | 2 +- phpBB/phpbb/console/command/cron/cron_list.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index a192ec396d..239b576738 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -223,7 +223,7 @@ $lang = array_merge($lang, array( 'BACK' => 'Back', - 'CLI_DESCRIPTION_CRON_LIST' => 'Print the cron list.', + 'CLI_DESCRIPTION_CRON_LIST' => 'Prints a list of ready and unready cron jobs.', 'CLI_DESCRIPTION_CRON_RUN' => 'Runs all ready cron tasks.', 'CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1' => 'Name of the task to be run', diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php index 9d9a3bdef7..1c32e6e306 100644 --- a/phpBB/phpbb/console/command/cron/cron_list.php +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -80,7 +80,7 @@ class cron_list extends \phpbb\console\command\command } } - public function print_tasks_names($tasks, $output) + protected function print_tasks_names(array $tasks, OutputInterface $output) { foreach ($tasks as $task) { From 8f0a04f318a5cf11595eae9f52118bfef7f3d98c Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Fri, 6 Jun 2014 10:21:00 +0200 Subject: [PATCH 12/15] [ticket/12602] Fix language var mistakes. PHPBB3-12602 --- phpBB/language/en/acp/common.php | 2 +- phpBB/phpbb/console/command/cron/cron_list.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 239b576738..7d82e21799 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -230,8 +230,8 @@ $lang = array_merge($lang, array( 'COLOUR_SWATCH' => 'Web-safe colour swatch', 'CONFIG_UPDATED' => 'Configuration updated successfully.', 'CRON_LOCK_ERROR' => 'Could not obtain cron lock.', + 'CRON_NO_RUNNABLE_TASK' => 'No cron task needs to be run right now.', 'CRON_NO_SUCH_TASK' => 'Could not find cron task “%s”.', - 'CRON_NO_TASK' => 'No cron tasks need to be run right now.', 'DEACTIVATE' => 'Deactivate', 'DIRECTORY_DOES_NOT_EXIST' => 'The entered path “%s” does not exist.', diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php index 1c32e6e306..cc51a57f4b 100644 --- a/phpBB/phpbb/console/command/cron/cron_list.php +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -44,7 +44,7 @@ class cron_list extends \phpbb\console\command\command if (empty($tasks)) { - $output->writeln($this->user->lang('NO_TASK')); + $output->writeln($this->user->lang('CRON_NO_RUNNABLE_TASK')); return; } From 49beb2075b8a6831c6c394fb7b2ba081b860664d Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Fri, 6 Jun 2014 10:29:58 +0200 Subject: [PATCH 13/15] [ticket/12602] Fix test mistake. PHPBB3-12602 --- tests/console/cron/cron_list_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index ad74f17875..ea54c17738 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -39,7 +39,7 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case public function test_no_task() { $this->initiate_test(0, 0); - $this->assertContains('NO_TASK', $this->command_tester->getDisplay()); + $this->assertContains('CRON_NO_RUNNABLE_TASK', $this->command_tester->getDisplay()); } public function test_only_ready() From 347de7f060095cc43c2a5b5575924997ac8d3dbf Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Fri, 6 Jun 2014 14:55:37 +0200 Subject: [PATCH 14/15] [ticket/12602] Rectify language keys. PHPBB3-12602 --- phpBB/language/en/acp/common.php | 2 +- phpBB/phpbb/console/command/cron/cron_list.php | 2 +- tests/console/cron/cron_list_test.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 7d82e21799..fa0c21d76e 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -230,8 +230,8 @@ $lang = array_merge($lang, array( 'COLOUR_SWATCH' => 'Web-safe colour swatch', 'CONFIG_UPDATED' => 'Configuration updated successfully.', 'CRON_LOCK_ERROR' => 'Could not obtain cron lock.', - 'CRON_NO_RUNNABLE_TASK' => 'No cron task needs to be run right now.', 'CRON_NO_SUCH_TASK' => 'Could not find cron task “%s”.', + 'CRON_NO_TASKS' => 'No cron tasks could be found.', 'DEACTIVATE' => 'Deactivate', 'DIRECTORY_DOES_NOT_EXIST' => 'The entered path “%s” does not exist.', diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php index cc51a57f4b..9db6a23947 100644 --- a/phpBB/phpbb/console/command/cron/cron_list.php +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -44,7 +44,7 @@ class cron_list extends \phpbb\console\command\command if (empty($tasks)) { - $output->writeln($this->user->lang('CRON_NO_RUNNABLE_TASK')); + $output->writeln($this->user->lang('CRON_NO_TASKS')); return; } diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index ea54c17738..46705a585f 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -39,7 +39,7 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case public function test_no_task() { $this->initiate_test(0, 0); - $this->assertContains('CRON_NO_RUNNABLE_TASK', $this->command_tester->getDisplay()); + $this->assertContains('CRON_NO_TASKS', $this->command_tester->getDisplay()); } public function test_only_ready() From 088ce641be6528bc8705b630569c98a082455aa4 Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Fri, 6 Jun 2014 17:49:18 +0200 Subject: [PATCH 15/15] [ticket/12602] Fix language key removal. PHPBB3-12602 --- phpBB/language/en/acp/common.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index fa0c21d76e..12cdc28aa3 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -231,6 +231,7 @@ $lang = array_merge($lang, array( 'CONFIG_UPDATED' => 'Configuration updated successfully.', 'CRON_LOCK_ERROR' => 'Could not obtain cron lock.', 'CRON_NO_SUCH_TASK' => 'Could not find cron task “%s”.', + 'CRON_NO_TASK' => 'No cron tasks need to be run right now.', 'CRON_NO_TASKS' => 'No cron tasks could be found.', 'DEACTIVATE' => 'Deactivate',