diff options
| author | Nicofuma <github@nicofuma.fr> | 2014-04-28 14:00:27 +0200 |
|---|---|---|
| committer | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-07-13 22:41:13 +0200 |
| commit | be0d4e20d4be8bc3217e5d025058e065b8f2071a (patch) | |
| tree | 557a9732223835282b86ba8986120d978bca5260 /tests/notification/submit_post_base.php | |
| parent | 58d1d37c167c978257c9a4680d56835c63202738 (diff) | |
| download | forums-be0d4e20d4be8bc3217e5d025058e065b8f2071a.tar forums-be0d4e20d4be8bc3217e5d025058e065b8f2071a.tar.gz forums-be0d4e20d4be8bc3217e5d025058e065b8f2071a.tar.bz2 forums-be0d4e20d4be8bc3217e5d025058e065b8f2071a.tar.xz forums-be0d4e20d4be8bc3217e5d025058e065b8f2071a.zip | |
[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
Diffstat (limited to 'tests/notification/submit_post_base.php')
| -rw-r--r-- | tests/notification/submit_post_base.php | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 04fb6658c3..73711369ed 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -50,7 +50,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,7 +69,11 @@ 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 = new \phpbb\cache\service( new \phpbb\cache\driver\dummy(), @@ -111,30 +115,46 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $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 = $this->build_type($type); + $phpbb_container->set('notification.type.' . $type, array(array($this, 'build_type'), array($type))); $notification_types_array['notification.type.' . $type] = $class; } + // Methods Types + $class_name = 'phpbb\notification\method\board'; + $class = new $class_name( + $user_loader, $db, $cache->get_driver(), $user, $auth, $config, + $phpbb_root_path, $phpEx, + NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE); + $phpbb_container->set('notification.method.board', $class); + $notification_methods_array = array('notification.method.board' => $class); + // Notification Manager - $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(), + $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, $notification_methods_array, $phpbb_container, $user_loader, $config, $phpbb_dispatcher, $db, $cache, $user, $phpbb_root_path, $phpEx, - NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); + NOTIFICATION_TYPES_TABLE, USER_NOTIFICATIONS_TABLE); $phpbb_container->set('notification_manager', $phpbb_notifications); } + public function build_type($type) + { + global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path, $user_loader; + + $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, USER_NOTIFICATIONS_TABLE); + + if ($type === 'quote') + { + $class->set_utils(new \phpbb\textformatter\s9e\utils); + } + + return $class; + } + /** * @dataProvider submit_post_data */ @@ -157,4 +177,11 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $this->assertEquals($expected_after, $this->db->sql_fetchrowset($result)); $this->db->sql_freeresult($result); } + + 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'); + } } |
