diff options
author | Nils Adermann <naderman@naderman.de> | 2012-09-01 19:21:24 +0200 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2012-09-01 19:21:24 +0200 |
commit | c539c2b0f9f736da816422320d6f58e6f414f54e (patch) | |
tree | 668e2e5658a1c7dac452e49081665d1bf7a86a39 /tests | |
parent | 66b60ddba848593c2e644d7784a3bde9872b2a24 (diff) | |
parent | 282a80077d4630ba59043fffe59e8a7ce8619ecb (diff) | |
download | forums-c539c2b0f9f736da816422320d6f58e6f414f54e.tar forums-c539c2b0f9f736da816422320d6f58e6f414f54e.tar.gz forums-c539c2b0f9f736da816422320d6f58e6f414f54e.tar.bz2 forums-c539c2b0f9f736da816422320d6f58e6f414f54e.tar.xz forums-c539c2b0f9f736da816422320d6f58e6f414f54e.zip |
Merge remote-tracking branch 'github-igorw/feature/dic' into develop
* github-igorw/feature/dic: (35 commits)
[feature/dic] Spaces to tabs, add useless docblocks
[feature/dic] Remove unneeded newline
[feature/dic] Add a doc block for the prune_forum cron task forum_data
[feature/dic] Update composer.lock to symfony/* RC1
[feature/dic] Fix re-ordering of services
[feature/dic] Fix parse errors
[feature/dic] Add docblock for cron_manager::wrap_task()
[feature/dic] Make cron task attributes protected, one per line
[feature/dic] Coding style: Braces
[feature/dic] Re-order services alphabetically
[feature/dic] Remove duplicate event-dispatcher dependency
[feature/dic] Adjust installer script to work with partially configured container
[feature/dic] Generate full cache driver class name on fresh install
[feature/dic] Adjust cache driver class name for BC
[feature/dic] Rename {phpEx => php_ext} for consistency
[feature/dic] Add trailing newline to htaccess
[feature/dic] Require symfony/* 2.1.*, tabs instead of spaces, --dev lock file
[feature/dic] Load services from extensions
[feature/dic] Introduce DI processors instead of abusing compiler passes
[feature/dic] Add dbal_ class prefix to dbal.driver.class
...
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cron/ext/testext/cron/dummy_task.php | 5 | ||||
-rw-r--r-- | tests/cron/includes/cron/task/core/dummy_task.php | 5 | ||||
-rw-r--r-- | tests/cron/includes/cron/task/core/second_dummy_task.php | 5 | ||||
-rw-r--r-- | tests/cron/manager_test.php | 32 | ||||
-rw-r--r-- | tests/cron/task_provider_test.php | 37 | ||||
-rw-r--r-- | tests/cron/tasks/simple_not_runnable.php | 5 | ||||
-rw-r--r-- | tests/cron/tasks/simple_ready.php | 5 | ||||
-rw-r--r-- | tests/cron/tasks/simple_should_not_run.php | 5 |
8 files changed, 69 insertions, 30 deletions
diff --git a/tests/cron/ext/testext/cron/dummy_task.php b/tests/cron/ext/testext/cron/dummy_task.php index 996f5b39cf..a31806c1b1 100644 --- a/tests/cron/ext/testext/cron/dummy_task.php +++ b/tests/cron/ext/testext/cron/dummy_task.php @@ -11,6 +11,11 @@ class phpbb_ext_testext_cron_dummy_task extends phpbb_cron_task_base { public static $was_run = 0; + public function get_name() + { + return get_class($this); + } + public function run() { self::$was_run++; diff --git a/tests/cron/includes/cron/task/core/dummy_task.php b/tests/cron/includes/cron/task/core/dummy_task.php index 6e2e2db636..ce3e91a9ba 100644 --- a/tests/cron/includes/cron/task/core/dummy_task.php +++ b/tests/cron/includes/cron/task/core/dummy_task.php @@ -11,6 +11,11 @@ class phpbb_cron_task_core_dummy_task extends phpbb_cron_task_base { public static $was_run = 0; + public function get_name() + { + return get_class($this); + } + public function run() { self::$was_run++; diff --git a/tests/cron/includes/cron/task/core/second_dummy_task.php b/tests/cron/includes/cron/task/core/second_dummy_task.php index 8cd0bddfc0..76a55588f9 100644 --- a/tests/cron/includes/cron/task/core/second_dummy_task.php +++ b/tests/cron/includes/cron/task/core/second_dummy_task.php @@ -11,6 +11,11 @@ class phpbb_cron_task_core_second_dummy_task extends phpbb_cron_task_base { public static $was_run = 0; + public function get_name() + { + return get_class($this); + } + public function run() { self::$was_run++; diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php index 3e40a6d338..3c541be2a6 100644 --- a/tests/cron/manager_test.php +++ b/tests/cron/manager_test.php @@ -18,10 +18,10 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase { public function setUp() { - $this->manager = new phpbb_cron_manager(array( - 'phpbb_cron_task_core_dummy_task', - 'phpbb_cron_task_core_second_dummy_task', - 'phpbb_ext_testext_cron_dummy_task', + $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'; } @@ -33,13 +33,6 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase $this->assertEquals($this->task_name, $task->get_name()); } - public function test_manager_instantiates_task_by_name() - { - $task = $this->manager->instantiate_task($this->task_name, array()); - $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(); @@ -54,10 +47,10 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase public function test_manager_finds_only_ready_tasks() { - $manager = new phpbb_cron_manager(array( - 'phpbb_cron_task_core_simple_ready', - 'phpbb_cron_task_core_simple_not_runnable', - 'phpbb_cron_task_core_simple_should_not_run', + $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); @@ -69,8 +62,15 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase $names = array(); foreach ($tasks as $task) { - $names[] = get_class($task->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); + } } diff --git a/tests/cron/task_provider_test.php b/tests/cron/task_provider_test.php index b42f40bb4a..ec853bb3ba 100644 --- a/tests/cron/task_provider_test.php +++ b/tests/cron/task_provider_test.php @@ -11,31 +11,40 @@ 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); } } diff --git a/tests/cron/tasks/simple_not_runnable.php b/tests/cron/tasks/simple_not_runnable.php index 837f28f1c0..56d484eacd 100644 --- a/tests/cron/tasks/simple_not_runnable.php +++ b/tests/cron/tasks/simple_not_runnable.php @@ -2,6 +2,11 @@ class phpbb_cron_task_core_simple_not_runnable extends phpbb_cron_task_base { + public function get_name() + { + return get_class($this); + } + public function run() { } diff --git a/tests/cron/tasks/simple_ready.php b/tests/cron/tasks/simple_ready.php index de5f10e491..8aa0507406 100644 --- a/tests/cron/tasks/simple_ready.php +++ b/tests/cron/tasks/simple_ready.php @@ -2,6 +2,11 @@ class phpbb_cron_task_core_simple_ready extends phpbb_cron_task_base { + public function get_name() + { + return get_class($this); + } + public function run() { } diff --git a/tests/cron/tasks/simple_should_not_run.php b/tests/cron/tasks/simple_should_not_run.php index c2a41616f6..58f6df2616 100644 --- a/tests/cron/tasks/simple_should_not_run.php +++ b/tests/cron/tasks/simple_should_not_run.php @@ -2,6 +2,11 @@ class phpbb_cron_task_core_simple_should_not_run extends phpbb_cron_task_base { + public function get_name() + { + return get_class($this); + } + public function run() { } |