diff options
author | Igor Wiedler <igor@wiedler.ch> | 2012-04-09 15:05:28 +0200 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2012-04-09 15:05:28 +0200 |
commit | 3ebe89cb7eff57c3ffdbe0b7dcd9cdc35b48d26b (patch) | |
tree | 9a5c38eb1f18d2d3219b3fa0a4cb4bd9fc854dd4 /tests/cron/task_provider_test.php | |
parent | 0a5348a1376fafb487884086a70069bea8c5640b (diff) | |
download | forums-3ebe89cb7eff57c3ffdbe0b7dcd9cdc35b48d26b.tar forums-3ebe89cb7eff57c3ffdbe0b7dcd9cdc35b48d26b.tar.gz forums-3ebe89cb7eff57c3ffdbe0b7dcd9cdc35b48d26b.tar.bz2 forums-3ebe89cb7eff57c3ffdbe0b7dcd9cdc35b48d26b.tar.xz forums-3ebe89cb7eff57c3ffdbe0b7dcd9cdc35b48d26b.zip |
[feature/dic] Fix test suite for dic-powered cron
PHPBB3-10739
Diffstat (limited to 'tests/cron/task_provider_test.php')
-rw-r--r-- | tests/cron/task_provider_test.php | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/tests/cron/task_provider_test.php b/tests/cron/task_provider_test.php index 4547c61a55..4458d811a5 100644 --- a/tests/cron/task_provider_test.php +++ b/tests/cron/task_provider_test.php @@ -7,37 +7,48 @@ * */ -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'; class phpbb_cron_task_provider_test extends PHPUnit_Framework_TestCase { public function setUp() { - $this->extension_manager = new phpbb_mock_extension_manager( - dirname(__FILE__) . '/', - array( - 'testext' => array( - 'ext_name' => 'testext', - 'ext_active' => true, - 'ext_path' => 'ext/testext/' - ), - )); - $this->provider = new phpbb_cron_task_provider($this->extension_manager); + $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() { - $tasks = array(); + $task_names = array(); foreach ($this->provider as $task) { - $tasks[] = $task; + $task_names[] = $task->get_name(); } - sort($tasks); + 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', - ), $tasks); + ), $task_names); } } |