aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cron/task_provider_test.php
blob: 4458d811a536984519e57ae2025051cfb707bed1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?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';

class phpbb_cron_task_provider_test extends PHPUnit_Framework_TestCase
{
	public function setUp()
	{
		$this->tasks = array(
			'phpbb_cron_task_core_dummy_task',
			'phpbb_cron_task_core_second_dummy_task',
			'phpbb_ext_testext_cron_dummy_task',
		);

		$container = $this->getMock('Symfony\Component\DependencyInjection\TaggedContainerInterface');
		$container
			->expects($this->once())
			->method('findTaggedServiceIds')
			->will($this->returnValue(array_flip($this->tasks)));
		$container
			->expects($this->any())
			->method('get')
			->will($this->returnCallback(function ($name) {
				return new $name;
			}));

		$this->provider = new phpbb_cron_task_provider($container);
	}

	public function test_manager_finds_shipped_tasks()
	{
		$task_names = array();
		foreach ($this->provider as $task)
		{
			$task_names[] = $task->get_name();
		}
		sort($task_names);

		$this->assertEquals(array(
			'phpbb_cron_task_core_dummy_task',
			'phpbb_cron_task_core_second_dummy_task',
			'phpbb_ext_testext_cron_dummy_task',
		), $task_names);
	}
}