aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cron
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-01-20 08:52:09 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2011-02-12 22:05:54 -0500
commit1fd8d6de7f6bb41505530c83e487a9dc18bd25af (patch)
treed1e5a226ca875e940d1d98c710051d1911d8b2ad /tests/cron
parent4e689c522f8cdb60984eb47020bee3c0535210bb (diff)
downloadforums-1fd8d6de7f6bb41505530c83e487a9dc18bd25af.tar
forums-1fd8d6de7f6bb41505530c83e487a9dc18bd25af.tar.gz
forums-1fd8d6de7f6bb41505530c83e487a9dc18bd25af.tar.bz2
forums-1fd8d6de7f6bb41505530c83e487a9dc18bd25af.tar.xz
forums-1fd8d6de7f6bb41505530c83e487a9dc18bd25af.zip
[feature/system-cron] More tests for cron manager.
PHPBB3-9596
Diffstat (limited to 'tests/cron')
-rw-r--r--tests/cron/manager_test.php21
-rw-r--r--tests/cron/task2/testmod/simple_not_runnable.php13
-rw-r--r--tests/cron/task2/testmod/simple_ready.php8
-rw-r--r--tests/cron/task2/testmod/simple_should_not_run.php13
4 files changed, 55 insertions, 0 deletions
diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php
index c282a802b2..6288a5c641 100644
--- a/tests/cron/manager_test.php
+++ b/tests/cron/manager_test.php
@@ -10,6 +10,9 @@
require_once __DIR__ . '/../mock/cache.php';
require_once __DIR__ . '/task/testmod/dummy_task.php';
require_once __DIR__ . '/task/testmod/second_dummy_task.php';
+require_once __DIR__ . '/task2/testmod/simple_ready.php';
+require_once __DIR__ . '/task2/testmod/simple_not_runnable.php';
+require_once __DIR__ . '/task2/testmod/simple_should_not_run.php';
class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
{
@@ -59,4 +62,22 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
$tasks = $manager->find_all_ready_tasks();
$this->assertEquals(1, sizeof($tasks));
}
+
+ public function test_manager_finds_only_ready_tasks()
+ {
+ $manager = new phpbb_cron_manager(__DIR__ . '/task2/', 'php');
+ $tasks = $manager->find_all_ready_tasks();
+ $task_names = $this->tasks_to_names($tasks);
+ $this->assertEquals(array('phpbb_cron_task_testmod_simple_ready'), $task_names);
+ }
+
+ private function tasks_to_names($tasks)
+ {
+ $names = array();
+ foreach ($tasks as $task)
+ {
+ $names[] = get_class($task->task);
+ }
+ return $names;
+ }
}
diff --git a/tests/cron/task2/testmod/simple_not_runnable.php b/tests/cron/task2/testmod/simple_not_runnable.php
new file mode 100644
index 0000000000..54869fa1cc
--- /dev/null
+++ b/tests/cron/task2/testmod/simple_not_runnable.php
@@ -0,0 +1,13 @@
+<?php
+
+class phpbb_cron_task_testmod_simple_not_runnable extends phpbb_cron_task_base
+{
+ public function run()
+ {
+ }
+
+ public function is_runnable()
+ {
+ return false;
+ }
+}
diff --git a/tests/cron/task2/testmod/simple_ready.php b/tests/cron/task2/testmod/simple_ready.php
new file mode 100644
index 0000000000..e407441e90
--- /dev/null
+++ b/tests/cron/task2/testmod/simple_ready.php
@@ -0,0 +1,8 @@
+<?php
+
+class phpbb_cron_task_testmod_simple_ready extends phpbb_cron_task_base
+{
+ public function run()
+ {
+ }
+}
diff --git a/tests/cron/task2/testmod/simple_should_not_run.php b/tests/cron/task2/testmod/simple_should_not_run.php
new file mode 100644
index 0000000000..14ba4cdbd3
--- /dev/null
+++ b/tests/cron/task2/testmod/simple_should_not_run.php
@@ -0,0 +1,13 @@
+<?php
+
+class phpbb_cron_task_testmod_simple_should_not_run extends phpbb_cron_task_base
+{
+ public function run()
+ {
+ }
+
+ public function should_run()
+ {
+ return false;
+ }
+}