mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-25 12:33:29 +01:00
* develop: (441 commits) [feature/new-tz-handling] Don't use global user but make it a parameter [feature/new-tz-handling] Fix size of suggestion button in chrome [feature/new-tz-handling] Fall back to UTC, if the timezone is invalid [feature/new-tz-handling] Add previous selected value to validation if valid [feature/new-tz-handling] Display suggestion when a different value is selected [ticket/10998] Add border-radius to forum rules block - prosilver [feature/new-tz-handling] Remove additional marking of selected items [feature/new-tz-handling] Move update helper function to new class [feature/new-tz-handling] Fix unit test [feature/new-tz-handling] Delete old variable which is not used anymore [feature/new-tz-handling] Rename $user->tz back to $user->timezone [feature/pagination-as-list] New parameter for name of start var [feature/pagination-as-list] Updates for nils comments [feature/pagination-as-list] Rename and deprecate functions [feature/pagination-as-list] Various fixes and improvements [ticket/10968] Render pagination within the template [feature/new-tz-handling] Remove "timezone might be numeric" [feature/new-tz-handling] Add function to update the timezone [feature/new-tz-handling] Correctly update user and board timezones on update [ticket/10996] Use correct DBMS name in Travis config for PostgreSQL ... Conflicts: phpBB/common.php phpBB/composer.json phpBB/composer.lock tests/cron/task_provider_test.php
77 lines
2.2 KiB
PHP
77 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
*
|
|
* @package testing
|
|
* @copyright (c) 2010 phpBB Group
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
|
*
|
|
*/
|
|
|
|
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 = $this->create_cron_manager(array(
|
|
new phpbb_cron_task_core_dummy_task(),
|
|
new phpbb_cron_task_core_second_dummy_task(),
|
|
new phpbb_ext_testext_cron_dummy_task(),
|
|
));
|
|
$this->task_name = 'phpbb_cron_task_core_dummy_task';
|
|
}
|
|
|
|
public function test_manager_finds_shipped_task_by_name()
|
|
{
|
|
$task = $this->manager->find_task($this->task_name);
|
|
$this->assertInstanceOf('phpbb_cron_task_wrapper', $task);
|
|
$this->assertEquals($this->task_name, $task->get_name());
|
|
}
|
|
|
|
public function test_manager_finds_all_ready_tasks()
|
|
{
|
|
$tasks = $this->manager->find_all_ready_tasks();
|
|
$this->assertEquals(3, sizeof($tasks));
|
|
}
|
|
|
|
public function test_manager_finds_one_ready_task()
|
|
{
|
|
$task = $this->manager->find_one_ready_task();
|
|
$this->assertInstanceOf('phpbb_cron_task_wrapper', $task);
|
|
}
|
|
|
|
public function test_manager_finds_only_ready_tasks()
|
|
{
|
|
$manager = $this->create_cron_manager(array(
|
|
new phpbb_cron_task_core_simple_ready(),
|
|
new phpbb_cron_task_core_simple_not_runnable(),
|
|
new 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_core_simple_ready'), $task_names);
|
|
}
|
|
|
|
private function tasks_to_names($tasks)
|
|
{
|
|
$names = array();
|
|
foreach ($tasks as $task)
|
|
{
|
|
$names[] = $task->get_name();
|
|
}
|
|
return $names;
|
|
}
|
|
|
|
private function create_cron_manager($tasks)
|
|
{
|
|
global $phpbb_root_path, $phpEx;
|
|
|
|
return new phpbb_cron_manager($tasks, $phpbb_root_path, $phpEx);
|
|
}
|
|
}
|