1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-14 04:34:07 +02:00

Merge pull request #3751 from Nicofuma/ticket/11444

[ticket/11444] Moving the in-board notifications to a method class
This commit is contained in:
Máté Bartus
2015-07-14 12:19:52 +02:00
61 changed files with 1581 additions and 993 deletions

View File

@@ -11,6 +11,8 @@
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
/**
* @group functional
*/
@@ -21,15 +23,15 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
return array(
// Rows inserted by phpBB/install/schemas/schema_data.sql
// Also see PHPBB3-11460
array('notification.type.post_notification', true),
array('notification.type.topic_notification', true),
array('notification.type.post_notification.method.board', true),
array('notification.type.topic_notification.method.board', true),
array('notification.type.post_notification.method.email', true),
array('notification.type.topic_notification.method.email', true),
// Default behaviour for in-board notifications:
// If user did not opt-out, in-board notifications are on.
array('notification.type.bookmark_notification', true),
array('notification.type.quote_notification', true),
array('notification.type.bookmark_notification.method.board', true),
array('notification.type.quote_notification.method.board', true),
// Default behaviour for email notifications:
// If user did not opt-in, email notifications are off.

View File

@@ -52,7 +52,15 @@ class phpbb_mock_container_builder implements ContainerInterface
{
if ($this->has($id))
{
return $this->services[$id];
$service = $this->services[$id];
if (is_array($service) && is_callable($service[0]))
{
return call_user_func_array($service[0], $service[1]);
}
else
{
return $service;
}
}
throw new Exception('Could not find service: ' . $id);
@@ -180,4 +188,9 @@ class phpbb_mock_container_builder implements ContainerInterface
public function isScopeActive($name)
{
}
public function isFrozen()
{
return false;
}
}

View File

@@ -32,19 +32,18 @@ class phpbb_mock_notification_manager
);
}
public function mark_notifications_read()
public function mark_notifications()
{
}
public function mark_notifications_read_by_parent()
public function mark_notifications_by_parent()
{
}
public function mark_notifications_read_by_id()
public function mark_notifications_by_id()
{
}
public function add_notifications()
{
return array();

View File

@@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
class phpbb_mock_notification_type_post extends \phpbb\notification\type\post
{
public function __construct($user_loader, $db, $cache, $user, $auth, $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)
public function __construct($user_loader, $db, $cache, $user, $auth, $config, $phpbb_root_path, $php_ext, $notification_types_table, $user_notifications_table)
{
$this->user_loader = $user_loader;
$this->db = $db;
@@ -34,7 +34,6 @@ class phpbb_mock_notification_type_post extends \phpbb\notification\type\post
$this->php_ext = $php_ext;
$this->notification_types_table = $notification_types_table;
$this->notifications_table = $notifications_table;
$this->user_notifications_table = $user_notifications_table;
$this->user_notifications_table = $user_notifications_table;
}
}

View File

@@ -11,6 +11,10 @@
*
*/
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
require_once dirname(__FILE__) . '/manager_helper.php';
abstract class phpbb_tests_notification_base extends phpbb_database_test_case
@@ -39,6 +43,13 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
);
}
protected function get_notification_methods()
{
return array(
'notification.method.board',
);
}
protected function setUp()
{
parent::setUp();
@@ -55,6 +66,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
'allow_bookmarks' => true,
'allow_topic_notify' => true,
'allow_forum_notify' => true,
'allow_board_notifications' => true,
));
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
@@ -62,8 +74,9 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$this->user = $user;
$this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
$auth = $this->auth = new phpbb_mock_notifications_auth();
$cache_driver = new \phpbb\cache\driver\dummy();
$cache = $this->cache = new \phpbb\cache\service(
new \phpbb\cache\driver\dummy(),
$cache_driver,
$this->config,
$this->db,
$phpbb_root_path,
@@ -72,41 +85,62 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$this->phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_container = $this->container = new phpbb_mock_container_builder();
$phpbb_container = $this->container = new ContainerBuilder();
$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__ . '/fixtures'));
$loader->load('services_notification.yml');
$phpbb_container->set('user_loader', $this->user_loader);
$phpbb_container->set('user', $user);
$phpbb_container->set('config', $this->config);
$phpbb_container->set('dbal.conn', $this->db);
$phpbb_container->set('auth', $auth);
$phpbb_container->set('cache.driver', $cache_driver);
$phpbb_container->set('cache', $cache);
$phpbb_container->set('text_formatter.utils', new \phpbb\textformatter\s9e\utils());
$phpbb_container->set('dispatcher', $this->phpbb_dispatcher);
$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
$phpbb_container->setParameter('core.php_ext', $phpEx);
$phpbb_container->setParameter('tables.notifications', 'phpbb_notifications');
$phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
$phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types');
$this->notifications = new phpbb_notification_manager_helper(
array(),
array(),
$this->container,
$this->user_loader,
$this->config,
$this->phpbb_dispatcher,
$this->db,
$this->cache,
$this->user,
$phpbb_root_path,
$phpEx,
'phpbb_notification_types',
'phpbb_notifications',
'phpbb_user_notifications'
);
$phpbb_container->set('notification_manager', $this->notifications);
$phpbb_container->compile();
$this->notifications->setDependencies($this->auth, $this->config);
$types = array();
foreach ($this->get_notification_types() as $type)
{
$type_parts = explode('.', $type);
$class = $this->build_type('phpbb\notification\type\\' . array_pop($type_parts));
$class = $this->build_type($type);
$types[$type] = $class;
$this->container->set($type, $class);
}
$this->notifications->set_var('notification_types', $types);
$methods = array();
foreach ($this->get_notification_methods() as $method)
{
$class = $this->container->get($method);
$methods[$method] = $class;
}
$this->notifications->set_var('notification_methods', $methods);
$this->db->sql_query('DELETE FROM phpbb_notification_types');
$this->db->sql_query('DELETE FROM phpbb_notifications');
$this->db->sql_query('DELETE FROM phpbb_user_notifications');
@@ -114,21 +148,14 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
protected function build_type($type)
{
global $phpbb_root_path, $phpEx;
$instance = new $type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications');
if ($type === 'phpbb\\notification\\type\\quote')
{
$instance->set_utils(new \phpbb\textformatter\s9e\utils);
}
$instance = $this->container->get($type);
return $instance;
}
protected function assert_notifications($expected, $options = array())
{
$notifications = $this->notifications->load_notifications(array_merge(array(
$notifications = $this->notifications->load_notifications('notification.method.board', array_merge(array(
'count_unread' => true,
'order_by' => 'notification_time',
'order_dir' => 'ASC',

View File

@@ -47,12 +47,13 @@ class test extends \phpbb\notification\type\base
{
$this->notification_time = $post['post_time'];
return parent::create_insert_array($post, $pre_create_data);
parent::create_insert_array($post, $pre_create_data);
}
public function create_update_array($type_data)
{
$data = $this->create_insert_array($type_data);
$this->create_insert_array($type_data);
$data = $this->get_insert_array();
// Unset data unique to each row
unset(

View File

@@ -0,0 +1,70 @@
imports:
- { resource: ../../../phpBB/config/default/container/services_notification.yml }
services:
notification_manager:
synthetic: true
user_loader:
synthetic: true
user:
synthetic: true
config:
synthetic: true
dbal.conn:
synthetic: true
auth:
synthetic: true
cache.driver:
synthetic: true
path_helper:
synthetic: true
groupposition.legend:
synthetic: true
groupposition.teampage:
synthetic: true
groupposition.teampage:
synthetic: true
text_formatter.s9e.factory:
synthetic: true
text_formatter.s9e.quote_helper:
synthetic: true
text_formatter.parser:
synthetic: true
text_formatter.s9e.parser:
synthetic: true
text_formatter.renderer:
synthetic: true
text_formatter.s9e.renderer:
synthetic: true
text_formatter.utils:
synthetic: true
text_formatter.s9e.utils:
synthetic: true
text_formatter.data_access:
synthetic: true
test:
class: phpbb\notification\type\test
scope: prototype
parent: notification.type.base
tags:
- { name: notification.type }

View File

@@ -126,35 +126,35 @@
<value>notification.type.bookmark</value>
<value>0</value>
<value>2</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.bookmark</value>
<value>0</value>
<value>3</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.bookmark</value>
<value>0</value>
<value>4</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.bookmark</value>
<value>0</value>
<value>5</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.bookmark</value>
<value>0</value>
<value>6</value>
<value></value>
<value>notification.method.board</value>
<value>0</value>
</row>
</table>

View File

@@ -156,49 +156,49 @@
<value>notification.type.post</value>
<value>0</value>
<value>2</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.post</value>
<value>0</value>
<value>3</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.post</value>
<value>0</value>
<value>4</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.post</value>
<value>0</value>
<value>5</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.post</value>
<value>0</value>
<value>6</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.post</value>
<value>0</value>
<value>7</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.post</value>
<value>0</value>
<value>8</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
</table>

View File

@@ -110,49 +110,49 @@
<value>notification.type.needs_approval</value>
<value>0</value>
<value>2</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>3</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>4</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>5</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>6</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>7</value>
<value></value>
<value>notification.method.board</value>
<value>0</value>
</row>
<row>
<value>notification.type.needs_approval</value>
<value>0</value>
<value>9</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
</table>

View File

@@ -98,35 +98,35 @@
<value>notification.type.quote</value>
<value>0</value>
<value>2</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.quote</value>
<value>0</value>
<value>3</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.quote</value>
<value>0</value>
<value>4</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.quote</value>
<value>0</value>
<value>5</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.quote</value>
<value>0</value>
<value>6</value>
<value></value>
<value>notification.method.board</value>
<value>0</value>
</row>
</table>

View File

@@ -106,28 +106,28 @@
<value>notification.type.topic</value>
<value>0</value>
<value>2</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.topic</value>
<value>0</value>
<value>6</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.topic</value>
<value>0</value>
<value>7</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
<row>
<value>notification.type.topic</value>
<value>0</value>
<value>8</value>
<value></value>
<value>notification.method.board</value>
<value>1</value>
</row>
</table>

View File

@@ -37,40 +37,4 @@ class phpbb_notification_manager_helper extends \phpbb\notification\manager
$this->auth = $auth;
$this->config = $config;
}
/**
* Helper to get the notifications item type class and set it up
*/
public function get_item_type_class($item_type, $data = array())
{
$item_parts = explode('.', $item_type);
$item_type = 'phpbb\notification\type\\' . array_pop($item_parts);
$item = new $item_type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table);
if ($item_type === 'phpbb\\notification\\type\\quote')
{
$item->set_utils(new \phpbb\textformatter\s9e\utils);
}
$item->set_notification_manager($this);
$item->set_initial_data($data);
return $item;
}
/**
* Helper to get the notifications method class and set it up
*/
public function get_method_class($method_name)
{
$method_name = 'phpbb\notification\method\\' . $method_name;
$method = new $method_name($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table);
$method->set_notification_manager($this);
return $method;
}
}

View File

@@ -29,7 +29,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base
$quote_type_id = $this->notifications->get_notification_type_id('notification.type.quote');
$test_type_id = $this->notifications->get_notification_type_id('test');
$this->assertEquals(array(
self::assertEquals(array(
'test' => $test_type_id,
'notification.type.quote' => $quote_type_id,
'notification.type.post' => $post_type_id,
@@ -40,13 +40,13 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'notification.type.post',
)
));
$this->assertEquals($quote_type_id, $this->notifications->get_notification_type_id('notification.type.quote'));
self::assertEquals($quote_type_id, $this->notifications->get_notification_type_id('notification.type.quote'));
try
{
$this->assertEquals(false, $this->notifications->get_notification_type_id('fail'));
self::assertEquals(false, $this->notifications->get_notification_type_id('fail'));
$this->fail('Non-existent type should throw an exception');
self::fail('Non-existent type should throw an exception');
}
catch (Exception $e) {}
}
@@ -55,15 +55,15 @@ class phpbb_notification_test extends phpbb_tests_notification_base
{
$subscription_types = $this->notifications->get_subscription_types();
$this->assertArrayHasKey('NOTIFICATION_GROUP_MISCELLANEOUS', $subscription_types);
$this->assertArrayHasKey('NOTIFICATION_GROUP_POSTING', $subscription_types);
self::assertArrayHasKey('NOTIFICATION_GROUP_MISCELLANEOUS', $subscription_types);
self::assertArrayHasKey('NOTIFICATION_GROUP_POSTING', $subscription_types);
$this->assertArrayHasKey('notification.type.bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']);
$this->assertArrayHasKey('notification.type.post', $subscription_types['NOTIFICATION_GROUP_POSTING']);
$this->assertArrayHasKey('notification.type.quote', $subscription_types['NOTIFICATION_GROUP_POSTING']);
$this->assertArrayHasKey('notification.type.topic', $subscription_types['NOTIFICATION_GROUP_POSTING']);
self::assertArrayHasKey('notification.type.bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']);
self::assertArrayHasKey('notification.type.post', $subscription_types['NOTIFICATION_GROUP_POSTING']);
self::assertArrayHasKey('notification.type.quote', $subscription_types['NOTIFICATION_GROUP_POSTING']);
self::assertArrayHasKey('notification.type.topic', $subscription_types['NOTIFICATION_GROUP_POSTING']);
$this->assertArrayHasKey('notification.type.pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']);
self::assertArrayHasKey('notification.type.pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']);
//get_subscription_types
//get_subscription_methods
@@ -72,33 +72,33 @@ class phpbb_notification_test extends phpbb_tests_notification_base
public function test_subscriptions()
{
$expected_subscriptions = array(
'notification.type.post' => array(''),
'notification.type.topic' => array(''),
'notification.type.quote' => array(''),
'notification.type.bookmark' => array(''),
'test' => array(''),
'notification.type.pm' => array(''),
'notification.type.post' => array('notification.method.board'),
'notification.type.topic' => array('notification.method.board'),
'notification.type.quote' => array('notification.method.board'),
'notification.type.bookmark' => array('notification.method.board'),
'test' => array('notification.method.board'),
'notification.type.pm' => array('notification.method.board'),
);
$subscriptions = $this->notifications->get_global_subscriptions(2);
foreach ($expected_subscriptions as $item_type => $methods)
{
self::assertArrayHasKey($item_type, $subscriptions);
$this->assert_array_content_equals($methods, $subscriptions[$item_type]);
}
foreach ($subscriptions as $item_type => $methods)
{
$this->assert_array_content_equals($methods, $expected_subscriptions[$item_type]);
$this->assert_array_content_equals($methods, $expected_subscriptions[$item_type]);
}
$this->notifications->delete_subscription('notification.type.post', 0, '', 2);
$this->notifications->delete_subscription('notification.type.post', 0, 'notification.method.board', 2);
$this->assertArrayNotHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2));
self::assertArrayNotHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2));
$this->notifications->add_subscription('notification.type.post', 0, '', 2);
$this->notifications->add_subscription('notification.type.post', 0, 'notification.method.board', 2);
$this->assertArrayHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2));
self::assertArrayHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2));
}
public function test_notifications()
@@ -124,11 +124,11 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'user_id' => 0,
)));
$this->assertEquals(array(
self::assertEquals(array(
'notifications' => array(),
'unread_count' => 0,
'total_count' => 0,
), $this->notifications->load_notifications(array(
), $this->notifications->load_notifications('notification.method.board', array(
'count_unread' => true,
)));

View File

@@ -11,6 +11,10 @@
*
*/
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php';
@@ -50,7 +54,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
{
parent::setUp();
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path;
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path, $user_loader;
// Database
$this->db = $this->new_dbal();
@@ -69,10 +73,15 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
)));
// Config
$config = new \phpbb\config\config(array('num_topics' => 1,'num_posts' => 1,));
$config = new \phpbb\config\config(array(
'num_topics' => 1,
'num_posts' => 1,
'allow_board_notifications' => true,
));
$cache_driver = new \phpbb\cache\driver\dummy();
$cache = new \phpbb\cache\service(
new \phpbb\cache\driver\dummy(),
$cache_driver,
$config,
$db,
$phpbb_root_path,
@@ -99,39 +108,46 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$type_cast_helper = $this->getMock('\phpbb\request\type_cast_helper_interface');
$request = $this->getMock('\phpbb\request\request');
// Container
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
$user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
// Container
$phpbb_container = new ContainerBuilder();
$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__ . '/fixtures'));
$loader->load('services_notification.yml');
$phpbb_container->set('user_loader', $user_loader);
$phpbb_container->set('user', $user);
$phpbb_container->set('config', $config);
$phpbb_container->set('dbal.conn', $db);
$phpbb_container->set('auth', $auth);
$phpbb_container->set('cache.driver', $cache_driver);
$phpbb_container->set('cache', $cache);
$phpbb_container->set('text_formatter.utils', new \phpbb\textformatter\s9e\utils());
$phpbb_container->set('dispatcher', $phpbb_dispatcher);
$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
$phpbb_container->setParameter('core.php_ext', $phpEx);
$phpbb_container->setParameter('tables.notifications', 'phpbb_notifications');
$phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
$phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types');
$phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
$phpbb_container->compile();
// Notification Types
$notification_types = array('quote', 'bookmark', 'post', 'post_in_queue', 'topic', 'topic_in_queue', 'approve_topic', 'approve_post');
$notification_types_array = array();
foreach ($notification_types as $type)
{
$class_name = '\phpbb\notification\type\\' . $type;
$class = new $class_name(
$user_loader, $db, $cache->get_driver(), $user, $auth, $config,
$phpbb_root_path, $phpEx,
NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
if ($type === 'quote')
{
$class->set_utils(new \phpbb\textformatter\s9e\utils);
}
$phpbb_container->set('notification.type.' . $type, $class);
$class = $phpbb_container->get('notification.type.' . $type);
$notification_types_array['notification.type.' . $type] = $class;
}
// Methods Types
$notification_methods_array = array('notification.method.board' => $phpbb_container->get('notification.method.board'));
// Notification Manager
$phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(),
$phpbb_container, $user_loader, $config, $phpbb_dispatcher, $db, $cache, $user,
$phpbb_root_path, $phpEx,
NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
$phpbb_notifications = new \phpbb\notification\manager($notification_types_array, $notification_methods_array,
$phpbb_container, $user_loader, $phpbb_dispatcher, $db, $cache, $user,
NOTIFICATION_TYPES_TABLE, USER_NOTIFICATIONS_TABLE);
$phpbb_container->set('notification_manager', $phpbb_notifications);
}

View File

@@ -51,7 +51,8 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_
*/
public function submit_post_data()
{
$parser = $this->get_test_case_helpers()->set_s9e_services()->get('text_formatter.parser');
// The new mock container is needed because the data providers may be executed before phpunit call setUp()
$parser = $this->get_test_case_helpers()->set_s9e_services(new phpbb_mock_container_builder())->get('text_formatter.parser');
return array(
/**

View File

@@ -61,7 +61,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
$user_loader->load_users(array(2, 3, 4, 5, 6));
$this->notification = new phpbb_mock_notification_type_post(
$user_loader, null, null, $user, null, null, $phpbb_root_path, $phpEx, null, null, null
$user_loader, null, null, $user, null, null, $phpbb_root_path, $phpEx, null, null
);
}

View File

@@ -426,24 +426,34 @@ class phpbb_test_case_helpers
$cache_key_parser = $prefix . '_parser';
$cache_key_renderer = $prefix . '_renderer';
$container->set('cache.driver', $cache);
$container->setParameter('cache.dir', $cache_dir);
if (!$container->isFrozen())
{
$container->setParameter('cache.dir', $cache_dir);
}
// Create a path_helper
if (!$container->has('path_helper'))
if (!$container->has('path_helper') || $container->getDefinition('path_helper')->isSynthetic())
{
$path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
new \phpbb\filesystem(),
$this->test_case->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
);
$container->set(
'path_helper',
new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
new \phpbb\filesystem(),
$this->test_case->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
)
$path_helper
);
}
else
{
$path_helper = $container->get('path_helper');
}
// Create an event dispatcher
if ($container->has('dispatcher'))
@@ -534,7 +544,7 @@ class phpbb_test_case_helpers
// Calls configured in services.yml
$renderer->configure_quote_helper($quote_helper);
$renderer->configure_smilies_path($config, $container->get('path_helper'));
$renderer->configure_smilies_path($config, $path_helper);
$renderer->configure_user($user, $config, $auth);
$container->set('text_formatter.renderer', $renderer);