1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 08:47:45 +02:00

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
  ...
This commit is contained in:
Nils Adermann
2012-09-01 19:21:24 +02:00
37 changed files with 850 additions and 277 deletions

View File

@@ -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++;

View File

@@ -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++;

View File

@@ -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++;

View File

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

View File

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

View File

@@ -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()
{
}

View File

@@ -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()
{
}

View File

@@ -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()
{
}