aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cron
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cron')
-rw-r--r--tests/cron/ext/testext/cron/dummy_task.php (renamed from tests/cron/task/testmod/dummy_task.php)2
-rw-r--r--tests/cron/includes/cron/task/core/dummy_task.php23
-rw-r--r--tests/cron/includes/cron/task/core/second_dummy_task.php (renamed from tests/cron/task/testmod/second_dummy_task.php)2
-rw-r--r--tests/cron/manager_test.php46
-rw-r--r--tests/cron/task2/testmod/simple_ready.php8
-rw-r--r--tests/cron/task_provider_test.php43
-rw-r--r--tests/cron/tasks/simple_not_runnable.php (renamed from tests/cron/task2/testmod/simple_not_runnable.php)2
-rw-r--r--tests/cron/tasks/simple_ready.php8
-rw-r--r--tests/cron/tasks/simple_should_not_run.php (renamed from tests/cron/task2/testmod/simple_should_not_run.php)2
9 files changed, 98 insertions, 38 deletions
diff --git a/tests/cron/task/testmod/dummy_task.php b/tests/cron/ext/testext/cron/dummy_task.php
index 5941157589..06546ada05 100644
--- a/tests/cron/task/testmod/dummy_task.php
+++ b/tests/cron/ext/testext/cron/dummy_task.php
@@ -7,7 +7,7 @@
*
*/
-class phpbb_cron_task_testmod_dummy_task extends phpbb_cron_task_base
+class phpbb_ext_testext_cron_dummy_task extends phpbb_cron_task_base
{
public static $was_run = 0;
diff --git a/tests/cron/includes/cron/task/core/dummy_task.php b/tests/cron/includes/cron/task/core/dummy_task.php
new file mode 100644
index 0000000000..ddaf6a9b7c
--- /dev/null
+++ b/tests/cron/includes/cron/task/core/dummy_task.php
@@ -0,0 +1,23 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2010 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+class phpbb_cron_task_core_dummy_task extends phpbb_cron_task_base
+{
+ public static $was_run = 0;
+
+ public function run()
+ {
+ self::$was_run++;
+ }
+
+ public function should_run()
+ {
+ return true;
+ }
+}
diff --git a/tests/cron/task/testmod/second_dummy_task.php b/tests/cron/includes/cron/task/core/second_dummy_task.php
index 7118b2ebe7..36c3912c30 100644
--- a/tests/cron/task/testmod/second_dummy_task.php
+++ b/tests/cron/includes/cron/task/core/second_dummy_task.php
@@ -7,7 +7,7 @@
*
*/
-class phpbb_cron_task_testmod_second_dummy_task extends phpbb_cron_task_base
+class phpbb_cron_task_core_second_dummy_task extends phpbb_cron_task_base
{
public static $was_run = 0;
diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php
index 65d8360fbb..80c92e234b 100644
--- a/tests/cron/manager_test.php
+++ b/tests/cron/manager_test.php
@@ -7,25 +7,24 @@
*
*/
-require_once dirname(__FILE__) . '/../mock/cache.php';
-require_once dirname(__FILE__) . '/task/testmod/dummy_task.php';
-require_once dirname(__FILE__) . '/task/testmod/second_dummy_task.php';
-require_once dirname(__FILE__) . '/task2/testmod/simple_ready.php';
-require_once dirname(__FILE__) . '/task2/testmod/simple_not_runnable.php';
-require_once dirname(__FILE__) . '/task2/testmod/simple_should_not_run.php';
+require_once dirname(__FILE__) . '/../mock/extension_manager.php';
+require_once dirname(__FILE__) . '/includes/cron/task/core/dummy_task.php';
+require_once dirname(__FILE__) . '/includes/cron/task/core/second_dummy_task.php';
+require_once dirname(__FILE__) . '/ext/testext/cron/dummy_task.php';
+require_once dirname(__FILE__) . '/tasks/simple_ready.php';
+require_once dirname(__FILE__) . '/tasks/simple_not_runnable.php';
+require_once dirname(__FILE__) . '/tasks/simple_should_not_run.php';
class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
{
public function setUp()
{
- $this->manager = new phpbb_cron_manager(dirname(__FILE__) . '/task/', 'php');
- $this->task_name = 'phpbb_cron_task_testmod_dummy_task';
- }
-
- public function test_manager_finds_shipped_tasks()
- {
- $tasks = $this->manager->find_cron_task_names();
- $this->assertEquals(2, sizeof($tasks));
+ $this->manager = new phpbb_cron_manager(array(
+ 'phpbb_cron_task_core_dummy_task',
+ 'phpbb_cron_task_core_second_dummy_task',
+ 'phpbb_ext_testext_cron_dummy_task',
+ ));
+ $this->task_name = 'phpbb_cron_task_core_dummy_task';
}
public function test_manager_finds_shipped_task_by_name()
@@ -45,7 +44,7 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
public function test_manager_finds_all_ready_tasks()
{
$tasks = $this->manager->find_all_ready_tasks();
- $this->assertEquals(2, sizeof($tasks));
+ $this->assertEquals(3, sizeof($tasks));
}
public function test_manager_finds_one_ready_task()
@@ -54,21 +53,16 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
$this->assertInstanceOf('phpbb_cron_task_wrapper', $task);
}
- public function test_manager_finds_all_ready_tasks_cached()
- {
- $cache = new phpbb_mock_cache(array('_cron_tasks' => array($this->task_name)));
- $manager = new phpbb_cron_manager(dirname(__FILE__) . '/../../phpBB/', 'php', $cache);
-
- $tasks = $manager->find_all_ready_tasks();
- $this->assertEquals(1, sizeof($tasks));
- }
-
public function test_manager_finds_only_ready_tasks()
{
- $manager = new phpbb_cron_manager(dirname(__FILE__) . '/task2/', 'php');
+ $manager = new phpbb_cron_manager(array(
+ 'phpbb_cron_task_core_simple_ready',
+ 'phpbb_cron_task_core_simple_not_runnable',
+ 'phpbb_cron_task_core_simple_should_not_run',
+ ));
$tasks = $manager->find_all_ready_tasks();
$task_names = $this->tasks_to_names($tasks);
- $this->assertEquals(array('phpbb_cron_task_testmod_simple_ready'), $task_names);
+ $this->assertEquals(array('phpbb_cron_task_core_simple_ready'), $task_names);
}
private function tasks_to_names($tasks)
diff --git a/tests/cron/task2/testmod/simple_ready.php b/tests/cron/task2/testmod/simple_ready.php
deleted file mode 100644
index e407441e90..0000000000
--- a/tests/cron/task2/testmod/simple_ready.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-
-class phpbb_cron_task_testmod_simple_ready extends phpbb_cron_task_base
-{
- public function run()
- {
- }
-}
diff --git a/tests/cron/task_provider_test.php b/tests/cron/task_provider_test.php
new file mode 100644
index 0000000000..5565d0f64c
--- /dev/null
+++ b/tests/cron/task_provider_test.php
@@ -0,0 +1,43 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2010 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../mock/extension_manager.php';
+
+class phpbb_cron_task_provider_test extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->extension_manager = new phpbb_mock_extension_manager(
+ dirname(__FILE__) . '/',
+ array(
+ 'testext' => array(
+ 'ext_name' => 'testext',
+ 'ext_active' => true,
+ 'ext_path' => 'ext/testext/'
+ ),
+ ));
+ $this->provider = new phpbb_cron_task_provider($this->extension_manager);
+ }
+
+ public function test_manager_finds_shipped_tasks()
+ {
+ $tasks = array();
+ foreach ($this->provider as $task)
+ {
+ $tasks[] = $task;
+ }
+ sort($tasks);
+
+ $this->assertEquals(array(
+ 'phpbb_cron_task_core_dummy_task',
+ 'phpbb_cron_task_core_second_dummy_task',
+ 'phpbb_ext_testext_cron_dummy_task',
+ ), $tasks);
+ }
+}
diff --git a/tests/cron/task2/testmod/simple_not_runnable.php b/tests/cron/tasks/simple_not_runnable.php
index 54869fa1cc..837f28f1c0 100644
--- a/tests/cron/task2/testmod/simple_not_runnable.php
+++ b/tests/cron/tasks/simple_not_runnable.php
@@ -1,6 +1,6 @@
<?php
-class phpbb_cron_task_testmod_simple_not_runnable extends phpbb_cron_task_base
+class phpbb_cron_task_core_simple_not_runnable extends phpbb_cron_task_base
{
public function run()
{
diff --git a/tests/cron/tasks/simple_ready.php b/tests/cron/tasks/simple_ready.php
new file mode 100644
index 0000000000..de5f10e491
--- /dev/null
+++ b/tests/cron/tasks/simple_ready.php
@@ -0,0 +1,8 @@
+<?php
+
+class phpbb_cron_task_core_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/tasks/simple_should_not_run.php
index 14ba4cdbd3..c2a41616f6 100644
--- a/tests/cron/task2/testmod/simple_should_not_run.php
+++ b/tests/cron/tasks/simple_should_not_run.php
@@ -1,6 +1,6 @@
<?php
-class phpbb_cron_task_testmod_simple_should_not_run extends phpbb_cron_task_base
+class phpbb_cron_task_core_simple_should_not_run extends phpbb_cron_task_base
{
public function run()
{