From 1fd8d6de7f6bb41505530c83e487a9dc18bd25af Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 20 Jan 2011 08:52:09 -0500 Subject: [feature/system-cron] More tests for cron manager. PHPBB3-9596 --- tests/cron/manager_test.php | 21 +++++++++++++++++++++ tests/cron/task2/testmod/simple_not_runnable.php | 13 +++++++++++++ tests/cron/task2/testmod/simple_ready.php | 8 ++++++++ tests/cron/task2/testmod/simple_should_not_run.php | 13 +++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 tests/cron/task2/testmod/simple_not_runnable.php create mode 100644 tests/cron/task2/testmod/simple_ready.php create mode 100644 tests/cron/task2/testmod/simple_should_not_run.php (limited to 'tests/cron') 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 @@ +