1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-11 03:04:09 +02:00

[ticket/11444] Moving the in-board notifications to a method class

Currently the in-board method for the notifications is hardcoded and
cannot be disabled. This method should be in his own class extending
`phpbb\notification\method\method_interface`.

It also add the possibility, for each method, to be enabled by default (ie:
no entry in the DB => notification enabled).

https://tracker.phpbb.com/browse/PHPBB3-11444
https://tracker.phpbb.com/browse/PHPBB3-11967

PHPBB3-11444
This commit is contained in:
Nicofuma
2014-04-28 14:00:27 +02:00
committed by Tristan Darricau
parent 58d1d37c16
commit be0d4e20d4
55 changed files with 1229 additions and 609 deletions

View File

@@ -39,6 +39,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 +62,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);
@@ -87,7 +95,6 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$phpbb_root_path,
$phpEx,
'phpbb_notification_types',
'phpbb_notifications',
'phpbb_user_notifications'
);
@@ -107,6 +114,18 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$this->notifications->set_var('notification_types', $types);
$methods = array();
foreach ($this->get_notification_methods() as $method)
{
$method_parts = explode('.', $method);
$class = $this->build_type('phpbb\notification\method\\' . array_pop($method_parts));
$methods[$method] = $class;
$this->container->set($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');
@@ -116,7 +135,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
{
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');
$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_user_notifications');
if ($type === 'phpbb\\notification\\type\\quote')
{
@@ -126,9 +145,17 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
return $instance;
}
protected function build_method($method)
{
global $phpbb_root_path, $phpEx;
return new $method($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');
}
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',