From 4fbf3fbd40ad7f6137526c4f36e8a932015a0c81 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 19 Dec 2010 22:41:15 -0500 Subject: [feature/system-cron] Basic tests for cron manager. PHPBB3-9596 --- tests/cron/all_tests.php | 41 ++++++++++++++++++++++++++++++++ tests/cron/manager_test.php | 57 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 tests/cron/all_tests.php create mode 100644 tests/cron/manager_test.php (limited to 'tests/cron') diff --git a/tests/cron/all_tests.php b/tests/cron/all_tests.php new file mode 100644 index 0000000000..1fa5af7f5e --- /dev/null +++ b/tests/cron/all_tests.php @@ -0,0 +1,41 @@ +addTestSuite('phpbb_cron_manager_test'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_cron_all_tests::main') +{ + phpbb_cron_all_tests::main(); +} + diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php new file mode 100644 index 0000000000..4d3fa1d120 --- /dev/null +++ b/tests/cron/manager_test.php @@ -0,0 +1,57 @@ +register(); + +require_once '../phpBB/includes/cron/manager.php'; + +class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->manager = new phpbb_cron_manager(); + } + + public function test_manager_finds_shipped_tasks() + { + $tasks = $this->manager->find_cron_task_names(); + $this->assertGreaterThan(1, count($tasks)); + } + + public function test_manager_finds_shipped_task_by_name() + { + $task = $this->manager->find_task('phpbb_cron_task_core_queue'); + $this->assertNotNull($task); + } + + public function test_manager_instantiates_task_by_name() + { + $task = $this->manager->instantiate_task('phpbb_cron_task_core_queue', array()); + $this->assertNotNull($task); + } + + public function test_manager_finds_all_ready_tasks() + { + $tasks = $this->manager->find_all_ready_tasks(); + $this->assertGreaterThan(0, count($tasks)); + } + + public function test_manager_finds_one_ready_task() { + $task = $this->manager->find_one_ready_task(); + $this->assertNotNull($task); + } +} -- cgit v1.2.1