mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-20 07:42:09 +02:00
[feature/system-cron] More tests for cron manager.
PHPBB3-9596
This commit is contained in:
parent
4e689c522f
commit
1fd8d6de7f
@ -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;
|
||||
}
|
||||
}
|
||||
|
13
tests/cron/task2/testmod/simple_not_runnable.php
Normal file
13
tests/cron/task2/testmod/simple_not_runnable.php
Normal file
@ -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;
|
||||
}
|
||||
}
|
8
tests/cron/task2/testmod/simple_ready.php
Normal file
8
tests/cron/task2/testmod/simple_ready.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class phpbb_cron_task_testmod_simple_ready extends phpbb_cron_task_base
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
}
|
||||
}
|
13
tests/cron/task2/testmod/simple_should_not_run.php
Normal file
13
tests/cron/task2/testmod/simple_should_not_run.php
Normal file
@ -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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user