From 0d839cbefc19247fd2b4c1132b91083bf0983305 Mon Sep 17 00:00:00 2001 From: LEZY Thomas Date: Wed, 28 May 2014 18:02:30 +0200 Subject: [PATCH] [ticket/12597] Modification of return statuses and of test files PHPBB3-12597 --- phpBB/phpbb/console/command/cron/run_all.php | 2 +- tests/console/cron/run_all_test.php | 10 ++++++---- tests/console/cron/tasks/simple.php | 11 +++++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/phpBB/phpbb/console/command/cron/run_all.php b/phpBB/phpbb/console/command/cron/run_all.php index 38a7735c03..e2d235395b 100644 --- a/phpBB/phpbb/console/command/cron/run_all.php +++ b/phpBB/phpbb/console/command/cron/run_all.php @@ -60,7 +60,7 @@ class run_all extends \phpbb\console\command\command * @param InputInterface input The input stream, unused here * @param OutputInterface output The output stream, used for printig verbose-mode * and error information. - * @return null + * @return boolean 0 if all is ok, 1 if a lock error occured */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/tests/console/cron/run_all_test.php b/tests/console/cron/run_all_test.php index b718d1c117..b85d5eb901 100644 --- a/tests/console/cron/run_all_test.php +++ b/tests/console/cron/run_all_test.php @@ -21,6 +21,7 @@ class phpbb_console_command_cron_run_all_test extends phpbb_database_test_case protected $user; protected $cron_manager; protected $command_name; + protected $task; public function getDataSet() { @@ -40,8 +41,9 @@ class phpbb_console_command_cron_run_all_test extends phpbb_database_test_case $this->user = $this->getMock('\phpbb\user'); $this->user->method('lang')->will($this->returnArgument(0)); + $this->task = new phpbb_cron_task_simple(); $tasks = array( - new phpbb_cron_task_simple(), + $this->task, ); $this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $pathEx); @@ -58,7 +60,7 @@ class phpbb_console_command_cron_run_all_test extends phpbb_database_test_case $command_tester->execute(array('command' => $this->command_name)); $this->assertSame('', $command_tester->getDisplay()); - $this->assertSame(1, $cron_num_exec); + $this->assertSame(true, $this->task->executed); } public function test_verbose_mode() @@ -69,7 +71,7 @@ class phpbb_console_command_cron_run_all_test extends phpbb_database_test_case $command_tester->execute(array('command' => $this->command_name, '--verbose' => true)); $this->assertContains('RUNNING_TASK', $command_tester->getDisplay()); - $this->assertSame(1, $cron_num_exec); + $this->assertSame(true, $this->task->executed); } public function test_error_lock() @@ -81,7 +83,7 @@ class phpbb_console_command_cron_run_all_test extends phpbb_database_test_case $command_tester->execute(array('command' => $this->command_name)); $this->assertContains('CRON_LOCK_ERROR', $command_tester->getDisplay()); - $this->assertSame(0, $cron_num_exec); + $this->assertSame(false, $this->task->executed); } public function get_command_tester() diff --git a/tests/console/cron/tasks/simple.php b/tests/console/cron/tasks/simple.php index be2a8a1d9d..15194caaf7 100644 --- a/tests/console/cron/tasks/simple.php +++ b/tests/console/cron/tasks/simple.php @@ -2,6 +2,14 @@ class phpbb_cron_task_simple extends \phpbb\cron\task\base { + public $executed; + + public function __construct() + { + $executed = false; + parent::__construct(); + } + public function get_name() { return get_class($this); @@ -9,7 +17,6 @@ class phpbb_cron_task_simple extends \phpbb\cron\task\base public function run() { - global $cron_num_exec; - $cron_num_exec++; + $this->executed = true; } }