From 44861c1f45cf1d69e040cae1517062f3fb471c7a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 24 Feb 2024 17:49:44 +0100 Subject: [PATCH] [ticket/17010] Add ban manager to webpush test PHPBB3-17010 --- .../webpush_notification.type.post.xml | 2 -- .../notification_method_webpush_test.php | 24 +++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/notification/fixtures/webpush_notification.type.post.xml b/tests/notification/fixtures/webpush_notification.type.post.xml index 9d3d72d531..7654ed30aa 100644 --- a/tests/notification/fixtures/webpush_notification.type.post.xml +++ b/tests/notification/fixtures/webpush_notification.type.post.xml @@ -1,7 +1,5 @@ - -
forum_iduser_id diff --git a/tests/notification/notification_method_webpush_test.php b/tests/notification/notification_method_webpush_test.php index 9cf374da1a..0faff80576 100644 --- a/tests/notification/notification_method_webpush_test.php +++ b/tests/notification/notification_method_webpush_test.php @@ -97,8 +97,8 @@ class notification_method_webpush_test extends phpbb_tests_notification_base 'webpush_vapid_private' => self::VAPID_KEYS['privateKey'], ]); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); - $lang = new \phpbb\language\language($lang_loader); - $user = new \phpbb\user($lang, '\phpbb\datetime'); + $language = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($language, '\phpbb\datetime'); $this->user = $user; $this->user_loader = new \phpbb\user_loader($avatar_helper, $this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $auth = $this->auth = new phpbb_mock_notifications_auth(); @@ -113,19 +113,20 @@ class notification_method_webpush_test extends phpbb_tests_notification_base $phpbb_root_path, $phpEx ); + $phpbb_log = new \phpbb\log\dummy(); $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('language', $lang); + $phpbb_container->set('language', $language); $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('log', new \phpbb\log\dummy()); + $phpbb_container->set('log', $phpbb_log); $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); @@ -147,6 +148,19 @@ class notification_method_webpush_test extends phpbb_tests_notification_base ) ); + $ban_type_email = new \phpbb\ban\type\email($this->db, 'phpbb_bans', 'phpbb_users', 'phpbb_sessions', 'phpbb_sessions_keys'); + $ban_type_user = new \phpbb\ban\type\user($this->db, 'phpbb_bans', 'phpbb_users', 'phpbb_sessions', 'phpbb_sessions_keys'); + $ban_type_ip = new \phpbb\ban\type\ip($this->db, 'phpbb_bans', 'phpbb_users', 'phpbb_sessions', 'phpbb_sessions_keys'); + $phpbb_container->set('ban.type.email', $ban_type_email); + $phpbb_container->set('ban.type.user', $ban_type_user); + $phpbb_container->set('ban.type.ip', $ban_type_ip); + $collection = new \phpbb\di\service_collection($phpbb_container); + $collection->add('ban.type.email'); + $collection->add('ban.type.user'); + $collection->add('ban.type.ip'); + $ban_manager = new \phpbb\ban\manager($collection, new \phpbb\cache\driver\dummy(), $this->db, $language, $phpbb_log, $user, 'phpbb_bans', 'phpbb_users'); + $phpbb_container->set('ban.manager', $ban_manager); + $this->notification_method_webpush = new \phpbb\notification\method\webpush( $phpbb_container->get('config'), $phpbb_container->get('dbal.conn'), @@ -169,7 +183,7 @@ class notification_method_webpush_test extends phpbb_tests_notification_base $this->phpbb_dispatcher, $this->db, $this->cache, - $lang, + $language, $this->user, 'phpbb_notification_types', 'phpbb_user_notifications'