aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cron/task_provider_test.php
blob: ec853bb3ba7df438700378c9823cb225627ba4c6 (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
<?php
/**
*
* @package testing
* @copyright (c) 2010 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

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);
	}
}