mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
[feature/extension-manager] Porting cron tasks over to the extension finder
PHPBB3-10323
This commit is contained in:
@@ -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;
|
||||
|
23
tests/cron/includes/cron/task/core/dummy_task.php
Normal file
23
tests/cron/includes/cron/task/core/dummy_task.php
Normal file
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
|
@@ -7,25 +7,35 @@
|
||||
*
|
||||
*/
|
||||
|
||||
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__) . '/root2/includes/cron/task/core/simple_ready.php';
|
||||
require_once dirname(__FILE__) . '/root2/includes/cron/task/core/simple_not_runnable.php';
|
||||
require_once dirname(__FILE__) . '/root2/includes/cron/task/core/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';
|
||||
$this->extension_manager = new phpbb_mock_extension_manager(
|
||||
dirname(__FILE__) . '/',
|
||||
array(
|
||||
'testext' => array(
|
||||
'ext_name' => 'testext',
|
||||
'ext_active' => true,
|
||||
'ext_path' => dirname(__FILE__) . '/ext/testext/'
|
||||
),
|
||||
));
|
||||
$this->manager = new phpbb_cron_manager($this->extension_manager);
|
||||
$this->task_name = 'phpbb_cron_task_core_dummy_task';
|
||||
}
|
||||
|
||||
public function test_manager_finds_shipped_tasks()
|
||||
{
|
||||
$tasks = $this->manager->find_cron_task_names();
|
||||
$this->assertEquals(2, sizeof($tasks));
|
||||
$this->assertEquals(3, sizeof($tasks));
|
||||
}
|
||||
|
||||
public function test_manager_finds_shipped_task_by_name()
|
||||
@@ -45,7 +55,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 +64,12 @@ 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(new phpbb_mock_extension_manager(dirname(__FILE__) . '/root2/'));
|
||||
$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)
|
||||
|
@@ -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()
|
||||
{
|
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class phpbb_cron_task_core_simple_ready extends phpbb_cron_task_base
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
}
|
||||
}
|
@@ -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()
|
||||
{
|
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
class phpbb_cron_task_testmod_simple_ready extends phpbb_cron_task_base
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user