diff options
author | LEZY Thomas <thomas.gif.91@gmail.com> | 2014-05-29 16:37:45 +0200 |
---|---|---|
committer | LEZY Thomas <thomas.gif.91@gmail.com> | 2014-05-29 16:37:45 +0200 |
commit | e7fd259766ff78edf98ee08fff83cb70ac46b6f7 (patch) | |
tree | 77e46fc43236e8c88b9665d56b23a8953c1ba7cb /tests/console | |
parent | 532e4470ea08e6245878e49e77f1ca51354681e7 (diff) | |
download | forums-e7fd259766ff78edf98ee08fff83cb70ac46b6f7.tar forums-e7fd259766ff78edf98ee08fff83cb70ac46b6f7.tar.gz forums-e7fd259766ff78edf98ee08fff83cb70ac46b6f7.tar.bz2 forums-e7fd259766ff78edf98ee08fff83cb70ac46b6f7.tar.xz forums-e7fd259766ff78edf98ee08fff83cb70ac46b6f7.zip |
[ticket/12597] Refactoring and test improving
Adding tests of return status
Refactoring code
Adding consistency in verbose mode
PHPBB3-12597
Diffstat (limited to 'tests/console')
-rw-r--r-- | tests/console/cron/run_test.php | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index c7c514c084..e5cd170492 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -56,56 +56,74 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case public function test_normal_use() { $command_tester = $this->get_command_tester(); - $command_tester->execute(array('command' => $this->command_name)); + $exit_status = $command_tester->execute(array('command' => $this->command_name)); $this->assertSame('', $command_tester->getDisplay()); $this->assertSame(true, $this->task->executed); + $this->assertSame(0, $exit_status); } public function test_verbose_mode() { $command_tester = $this->get_command_tester(); - $command_tester->execute(array('command' => $this->command_name, '--verbose' => true)); + $exit_status = $command_tester->execute(array('command' => $this->command_name, '--verbose' => true)); $this->assertContains('RUNNING_TASK', $command_tester->getDisplay()); $this->assertSame(true, $this->task->executed); + $this->assertSame(0, $exit_status); } public function test_error_lock() { $this->lock->acquire(); $command_tester = $this->get_command_tester(); - $command_tester->execute(array('command' => $this->command_name)); + $exit_status = $command_tester->execute(array('command' => $this->command_name)); $this->assertContains('CRON_LOCK_ERROR', $command_tester->getDisplay()); $this->assertSame(false, $this->task->executed); + $this->assertSame(1, $exit_status); + } + + public function test_no_task() + { + $tasks = array( + ); + $this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $pathEx); + $command_tester = $this->get_command_tester(); + $exit_status = $command_tester->execute(array('command' => $this->command_name)); + + $this->assertContains('CRON_NO_TASK', $command_tester->getDisplay()); + $this->assertSame(0, $exit_status); } public function test_arg_valid() { $command_tester = $this->get_command_tester(); - $command_tester->execute(array('command' => $this->command_name, 'name' => 'phpbb_cron_task_simple')); + $exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'phpbb_cron_task_simple')); $this->assertSame('', $command_tester->getDisplay()); $this->assertSame(true, $this->task->executed); + $this->assertSame(0, $exit_status); } public function test_arg_invalid() { $command_tester = $this->get_command_tester(); - $command_tester->execute(array('command' => $this->command_name, 'name' => 'foo')); + $exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'foo')); - $this->assertContains('CRON_NO_TASK', $command_tester->getDisplay()); + $this->assertContains('CRON_NO_SUCH_TASK', $command_tester->getDisplay()); $this->assertSame(false, $this->task->executed); + $this->assertSame(2, $exit_status); } public function test_arg_valid_verbose() { $command_tester = $this->get_command_tester(); - $command_tester->execute(array('command' => $this->command_name, 'name' => 'phpbb_cron_task_simple', '--verbose' => true)); + $exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'phpbb_cron_task_simple', '--verbose' => true)); - $this->assertSame('', $command_tester->getDisplay()); + $this->assertContains('RUNNING_TASK', $command_tester->getDisplay()); $this->assertSame(true, $this->task->executed); + $this->assertSame(0, $exit_status); } public function get_command_tester() |