From ec90f2b380a598a3dbf7ada0e95878d9d1b85cbe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Dec 2014 16:34:02 +0100 Subject: [ticket/13421] Move tools to subdirectory PHPBB3-13421 --- tests/notification/convert_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/notification') diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index 32ab34c9bc..ad6e5849d3 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -32,7 +32,7 @@ class phpbb_notification_convert_test extends phpbb_database_test_case $this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert( new \phpbb\config\config(array()), $this->db, - new \phpbb\db\tools($this->db), + new \phpbb\db\tools\tools($this->db), $phpbb_root_path, $phpEx, 'phpbb_' -- cgit v1.2.1 From 79d4ff553844fa80be4da9286239f62a45489072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sun, 11 Jan 2015 17:32:31 +0100 Subject: [ticket/13494] Update calls to `set_config()` PHPBB3-13494 --- tests/notification/group_request_test.php | 2 -- tests/notification/submit_post_base.php | 1 - tests/notification/user_list_trim_test.php | 1 - 3 files changed, 4 deletions(-) (limited to 'tests/notification') diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index 0d1bda95ce..0d532882c6 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -40,8 +40,6 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); include_once($phpbb_root_path . 'includes/functions_content.' . $phpEx); - set_config(false, false, false, $this->config); - $this->container->set('groupposition.legend', new \phpbb\groupposition\legend( $this->db, $this->user diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 5e770f71c9..fd5f33466b 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -70,7 +70,6 @@ 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,)); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); $cache = new \phpbb\cache\service( diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index c43eff729c..2d24950275 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -33,7 +33,6 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case $db = $this->new_dbal(); $config = new \phpbb\config\config(array()); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); $cache = new \phpbb\cache\service( -- cgit v1.2.1 From a633f3484c63fe4bd70df548b3ae4bd569bdef46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sun, 11 Jan 2015 18:01:52 +0100 Subject: [ticket/13496] Update calls to `set_config_count()` PHPBB3-13496 --- tests/notification/submit_post_base.php | 1 - tests/notification/user_list_trim_test.php | 1 - 2 files changed, 2 deletions(-) (limited to 'tests/notification') diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index fd5f33466b..2d621f82d3 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -70,7 +70,6 @@ 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,)); - set_config_count(null, null, null, $config); $cache = new \phpbb\cache\service( new \phpbb\cache\driver\null(), diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index 2d24950275..5886c49512 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -33,7 +33,6 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case $db = $this->new_dbal(); $config = new \phpbb\config\config(array()); - set_config_count(null, null, null, $config); $cache = new \phpbb\cache\service( new \phpbb\cache\driver\null(), -- cgit v1.2.1 From 37ae99c75d388221489aa1069078d92eca413741 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Jan 2015 12:06:45 +0100 Subject: [ticket/10748] Replace direct creations of tools(); PHPBB3-10748 --- tests/notification/convert_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/notification') diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index ad6e5849d3..4a7fd89409 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -28,11 +28,12 @@ class phpbb_notification_convert_test extends phpbb_database_test_case global $phpbb_root_path, $phpEx; $this->db = $this->new_dbal(); + $factory = new \phpbb\db\tools\factory(); $this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert( new \phpbb\config\config(array()), $this->db, - new \phpbb\db\tools\tools($this->db), + $factory->get($this->db), $phpbb_root_path, $phpEx, 'phpbb_' -- cgit v1.2.1 From 147a713cc066d493b50b82a9d475aa9af940e2b4 Mon Sep 17 00:00:00 2001 From: s9e Date: Sat, 22 Nov 2014 20:00:58 +0100 Subject: [ticket/11768] This commit integrates s9e\TextFormatter This commit integrates s9e\TextFormatter as outlined in http://area51.phpbb.com/phpBB/viewtopic.php?f=108&t=44467 PHPBB3-11768 --- tests/notification/group_request_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/notification') diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index 0d532882c6..6a56a38c45 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -51,6 +51,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas )); $phpbb_dispatcher = new phpbb_mock_event_dispatcher; $phpbb_log = new \phpbb\log\null(); + $this->get_test_case_helpers()->set_s9e_services(); // Now on to the actual test -- cgit v1.2.1 From 179a4700221aa49071b07d638c44b9326c7a14a8 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Tue, 14 Apr 2015 02:31:23 +0200 Subject: [ticket/13762] Moving language related functionality into a separate class PHPBB3-13762 --- tests/notification/base.php | 7 +++++-- tests/notification/submit_post_base.php | 5 ++++- tests/notification/user_list_trim_test.php | 14 ++++++++------ 3 files changed, 17 insertions(+), 9 deletions(-) (limited to 'tests/notification') diff --git a/tests/notification/base.php b/tests/notification/base.php index 162feae557..c9d57a5934 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -56,7 +56,10 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case 'allow_topic_notify' => true, 'allow_forum_notify' => true, )); - $user = $this->user = new \phpbb\user('\phpbb\datetime'); + $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'); + $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 = $this->cache = new \phpbb\cache\service( @@ -66,7 +69,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $phpbb_root_path, $phpEx ); - + $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = $this->container = new phpbb_mock_container_builder(); diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 2d621f82d3..1412fb8509 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -83,7 +83,10 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); // User - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $user->ip = ''; $user->data = array( 'user_id' => 2, diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index 5886c49512..bcbdc81ef0 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -51,7 +51,9 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case array('u_viewprofile', 1, false), ))); - $user = new \phpbb\user('\phpbb\datetime'); + $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'); $user->data = array('user_lang' => 'en'); $user->add_lang('common'); @@ -71,7 +73,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case 'topic_title' => 'Test', 'poster_id' => 2, 'post_username' => 'A', - 'responders' => null, + 'responders' => null, ), 'Reply from A in topic:', ), @@ -82,7 +84,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case 'post_username' => 'A', 'responders' => array( array('username' => '', 'poster_id' => 3), - ), + ), ), 'Reply from A and B in topic:', ), @@ -94,7 +96,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case 'responders' => array( array('username' => '', 'poster_id' => 3), array('username' => '', 'poster_id' => 4), - ), + ), ), 'Reply from A, B, and C in topic:', ), @@ -107,7 +109,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case array('username' => '', 'poster_id' => 3), array('username' => '', 'poster_id' => 4), array('username' => '', 'poster_id' => 5), - ), + ), ), 'Reply from A, B, C, and D in topic:', ), @@ -121,7 +123,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case array('username' => '', 'poster_id' => 4), array('username' => '', 'poster_id' => 5), array('username' => '', 'poster_id' => 6), - ), + ), ), 'Reply from A, B, C, and 2 others in topic:', ), -- cgit v1.2.1 From b3cc20a575da12e7b66f3883dcc7f0eb6ca82ad8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 4 May 2015 10:09:37 +0200 Subject: [ticket/13782] Rename null driver to dummy for PHP7 compatibility PHPBB3-13782 --- tests/notification/base.php | 2 +- tests/notification/submit_post_base.php | 2 +- tests/notification/user_list_trim_test.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/notification') diff --git a/tests/notification/base.php b/tests/notification/base.php index c9d57a5934..a1ebecd6f9 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -63,7 +63,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $auth = $this->auth = new phpbb_mock_notifications_auth(); $cache = $this->cache = new \phpbb\cache\service( - new \phpbb\cache\driver\null(), + new \phpbb\cache\driver\dummy(), $this->config, $this->db, $phpbb_root_path, diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 1412fb8509..d7a711e007 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -72,7 +72,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $config = new \phpbb\config\config(array('num_topics' => 1,'num_posts' => 1,)); $cache = new \phpbb\cache\service( - new \phpbb\cache\driver\null(), + new \phpbb\cache\driver\dummy(), $config, $db, $phpbb_root_path, diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index bcbdc81ef0..f7b4fcb215 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -35,7 +35,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case $config = new \phpbb\config\config(array()); $cache = new \phpbb\cache\service( - new \phpbb\cache\driver\null(), + new \phpbb\cache\driver\dummy(), $config, $db, $phpbb_root_path, -- cgit v1.2.1 From 232f71dae43df9794184961431aca81d0e4652da Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 4 May 2015 10:11:28 +0200 Subject: [ticket/13782] Rename null log to dummy for PHP7 compatibility PHPBB3-13782 --- tests/notification/group_request_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/notification') diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index 6a56a38c45..a24808fbbd 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -50,7 +50,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas $this->cache->get_driver() )); $phpbb_dispatcher = new phpbb_mock_event_dispatcher; - $phpbb_log = new \phpbb\log\null(); + $phpbb_log = new \phpbb\log\dummy(); $this->get_test_case_helpers()->set_s9e_services(); // Now on to the actual test -- cgit v1.2.1 From e2bc6c8024eed988ba833ec062b9e856a77ff661 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 10 May 2015 03:04:12 +0200 Subject: [ticket/13828] Renamed testing doubles to avoid PHP7 keywords PHPBB3-13828 --- tests/notification/submit_post_type_topic_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/notification') diff --git a/tests/notification/submit_post_type_topic_test.php b/tests/notification/submit_post_type_topic_test.php index c095fbc4ba..f14f305517 100644 --- a/tests/notification/submit_post_type_topic_test.php +++ b/tests/notification/submit_post_type_topic_test.php @@ -42,7 +42,7 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_ ), ))); - $phpbb_log = $this->getMock('\phpbb\log\null'); + $phpbb_log = $this->getMock('\phpbb\log\dummy'); } /** -- cgit v1.2.1 From f5ce9f273829ba470a1348b4314cddb58f552da0 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 3 May 2015 16:06:42 +0200 Subject: [ticket/13680] Updated quote notifications Added get_quote_authors() to text_formatter.utils service to retrieve the names used in first-level quotes PHPBB3-13680 --- tests/notification/base.php | 9 ++++- tests/notification/manager_helper.php | 5 +++ tests/notification/submit_post_base.php | 5 +++ tests/notification/submit_post_type_quote_test.php | 38 ++++++++++++---------- 4 files changed, 38 insertions(+), 19 deletions(-) (limited to 'tests/notification') diff --git a/tests/notification/base.php b/tests/notification/base.php index a1ebecd6f9..45b0b6f179 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -116,7 +116,14 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case { global $phpbb_root_path, $phpEx; - return 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_notifications', 'phpbb_user_notifications'); + + if ($type === 'phpbb\\notification\\type\\quote') + { + $instance->set_utils(new \phpbb\textformatter\s9e\utils); + } + + return $instance; } protected function assert_notifications($expected, $options = array()) diff --git a/tests/notification/manager_helper.php b/tests/notification/manager_helper.php index 75b7275d3a..48bf5b177b 100644 --- a/tests/notification/manager_helper.php +++ b/tests/notification/manager_helper.php @@ -48,6 +48,11 @@ class phpbb_notification_manager_helper extends \phpbb\notification\manager $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); diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index d7a711e007..04fb6658c3 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -117,6 +117,11 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $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); $notification_types_array['notification.type.' . $type] = $class; diff --git a/tests/notification/submit_post_type_quote_test.php b/tests/notification/submit_post_type_quote_test.php index 61e3840773..8ad6a62b09 100644 --- a/tests/notification/submit_post_type_quote_test.php +++ b/tests/notification/submit_post_type_quote_test.php @@ -51,6 +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'); + return array( /** * Normal post @@ -65,15 +67,15 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ */ array( array( - 'message' => implode(' ', array( - '[quote="poster":uid]poster should not be notified[/quote:uid]', - '[quote="test":uid]test should be notified[/quote:uid]', - '[quote="unauthorized":uid]unauthorized to read, should not receive a notification[/quote:uid]', - '[quote="notified":uid]already notified, should not receive a new notification[/quote:uid]', - '[quote="disabled":uid]option disabled, should not receive a notification[/quote:uid]', - '[quote="default":uid]option set to default, should receive a notification[/quote:uid]', - '[quote="doesn\'t exist":uid]user does not exist, should not receive a notification[/quote:uid]', - )), + 'message' => $parser->parse(implode(' ', array( + '[quote="poster"]poster should not be notified[/quote]', + '[quote="test"]test should be notified[/quote]', + '[quote="unauthorized"]unauthorized to read, should not receive a notification[/quote]', + '[quote="notified"]already notified, should not receive a new notification[/quote]', + '[quote="disabled"]option disabled, should not receive a notification[/quote]', + '[quote="default"]option set to default, should receive a notification[/quote]', + '[quote="doesn\'t exist"]user does not exist, should not receive a notification[/quote]', + ))), 'bbcode_uid' => 'uid', ), array( @@ -94,15 +96,15 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ */ array( array( - 'message' => implode(' ', array( - '[quote="poster":uid]poster should not be notified[/quote:uid]', - '[quote="test":uid]test should be notified[/quote:uid]', - '[quote="unauthorized":uid]unauthorized to read, should not receive a notification[/quote:uid]', - '[quote="notified":uid]already notified, should not receive a new notification[/quote:uid]', - '[quote="disabled":uid]option disabled, should not receive a notification[/quote:uid]', - '[quote="default":uid]option set to default, should receive a notification[/quote:uid]', - '[quote="doesn\'t exist":uid]user does not exist, should not receive a notification[/quote:uid]', - )), + 'message' => $parser->parse(implode(' ', array( + '[quote="poster"]poster should not be notified[/quote]', + '[quote="test"]test should be notified[/quote]', + '[quote="unauthorized"]unauthorized to read, should not receive a notification[/quote]', + '[quote="notified"]already notified, should not receive a new notification[/quote]', + '[quote="disabled"]option disabled, should not receive a notification[/quote]', + '[quote="default"]option set to default, should receive a notification[/quote]', + '[quote="doesn\'t exist"]user does not exist, should not receive a notification[/quote]', + ))), 'bbcode_uid' => 'uid', 'force_approved_state' => false, ), -- cgit v1.2.1 From be0d4e20d4be8bc3217e5d025058e065b8f2071a Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Mon, 28 Apr 2014 14:00:27 +0200 Subject: [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 --- tests/notification/base.php | 33 ++++++++++-- .../ext/test/notification/type/test.php | 5 +- .../submit_post_notification.type.bookmark.xml | 10 ++-- .../submit_post_notification.type.post.xml | 14 ++--- ...submit_post_notification.type.post_in_queue.xml | 14 ++--- .../submit_post_notification.type.quote.xml | 10 ++-- .../submit_post_notification.type.topic.xml | 8 +-- tests/notification/manager_helper.php | 7 +-- tests/notification/notification_test.php | 48 ++++++++--------- tests/notification/submit_post_base.php | 61 ++++++++++++++++------ tests/notification/user_list_trim_test.php | 2 +- 11 files changed, 134 insertions(+), 78 deletions(-) (limited to 'tests/notification') diff --git a/tests/notification/base.php b/tests/notification/base.php index 45b0b6f179..c898c76947 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -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', diff --git a/tests/notification/ext/test/notification/type/test.php b/tests/notification/ext/test/notification/type/test.php index b02a563f06..7f3b4a4ef1 100644 --- a/tests/notification/ext/test/notification/type/test.php +++ b/tests/notification/ext/test/notification/type/test.php @@ -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( diff --git a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml index a1413e2cf8..7f069abc59 100644 --- a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml +++ b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml @@ -126,35 +126,35 @@ notification.type.bookmark 0 2 - + notification.method.board 1 notification.type.bookmark 0 3 - + notification.method.board 1 notification.type.bookmark 0 4 - + notification.method.board 1 notification.type.bookmark 0 5 - + notification.method.board 1 notification.type.bookmark 0 6 - + notification.method.board 0 diff --git a/tests/notification/fixtures/submit_post_notification.type.post.xml b/tests/notification/fixtures/submit_post_notification.type.post.xml index ed75787c70..a4bf9d3ee4 100644 --- a/tests/notification/fixtures/submit_post_notification.type.post.xml +++ b/tests/notification/fixtures/submit_post_notification.type.post.xml @@ -156,49 +156,49 @@ notification.type.post 0 2 - + notification.method.board 1 notification.type.post 0 3 - + notification.method.board 1 notification.type.post 0 4 - + notification.method.board 1 notification.type.post 0 5 - + notification.method.board 1 notification.type.post 0 6 - + notification.method.board 1 notification.type.post 0 7 - + notification.method.board 1 notification.type.post 0 8 - + notification.method.board 1 diff --git a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml index 2dea8e34dd..0a955c48d2 100644 --- a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml +++ b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml @@ -110,49 +110,49 @@ notification.type.needs_approval 0 2 - + notification.method.board 1 notification.type.needs_approval 0 3 - + notification.method.board 1 notification.type.needs_approval 0 4 - + notification.method.board 1 notification.type.needs_approval 0 5 - + notification.method.board 1 notification.type.needs_approval 0 6 - + notification.method.board 1 notification.type.needs_approval 0 7 - + notification.method.board 0 notification.type.needs_approval 0 9 - + notification.method.board 1 diff --git a/tests/notification/fixtures/submit_post_notification.type.quote.xml b/tests/notification/fixtures/submit_post_notification.type.quote.xml index dd5bc620cd..c66830fbf5 100644 --- a/tests/notification/fixtures/submit_post_notification.type.quote.xml +++ b/tests/notification/fixtures/submit_post_notification.type.quote.xml @@ -98,35 +98,35 @@ notification.type.quote 0 2 - + notification.method.board 1 notification.type.quote 0 3 - + notification.method.board 1 notification.type.quote 0 4 - + notification.method.board 1 notification.type.quote 0 5 - + notification.method.board 1 notification.type.quote 0 6 - + notification.method.board 0 diff --git a/tests/notification/fixtures/submit_post_notification.type.topic.xml b/tests/notification/fixtures/submit_post_notification.type.topic.xml index 1ba8d05699..e0f6583f48 100644 --- a/tests/notification/fixtures/submit_post_notification.type.topic.xml +++ b/tests/notification/fixtures/submit_post_notification.type.topic.xml @@ -106,28 +106,28 @@ notification.type.topic 0 2 - + notification.method.board 1 notification.type.topic 0 6 - + notification.method.board 1 notification.type.topic 0 7 - + notification.method.board 1 notification.type.topic 0 8 - + notification.method.board 1 diff --git a/tests/notification/manager_helper.php b/tests/notification/manager_helper.php index 48bf5b177b..40cf9b3ad4 100644 --- a/tests/notification/manager_helper.php +++ b/tests/notification/manager_helper.php @@ -46,7 +46,7 @@ class phpbb_notification_manager_helper extends \phpbb\notification\manager $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); + $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->user_notifications_table); if ($item_type === 'phpbb\\notification\\type\\quote') { @@ -65,9 +65,10 @@ class phpbb_notification_manager_helper extends \phpbb\notification\manager */ public function get_method_class($method_name) { - $method_name = 'phpbb\notification\method\\' . $method_name; + $method_parts = explode('.', $method_name); + $method_name = 'phpbb\notification\method\\' . array_pop($method_parts); - $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 = 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, NOTIFICATIONS_TABLE, $this->user_notifications_table); $method->set_notification_manager($this); diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index 79fa5338c4..167cde13ca 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -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,12 +72,12 @@ 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); @@ -89,16 +89,16 @@ class phpbb_notification_test extends phpbb_tests_notification_base 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, ))); 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'); + } } diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index f7b4fcb215..d57fbf0485 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -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 ); } -- cgit v1.2.1 From fc34057f288c6b8c656a0ed1ac2cb5a86f86206d Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 9 Jul 2015 17:04:40 +0200 Subject: [ticket/11444] Update tests and cleanup types/methods PHPBB3-11444 --- tests/notification/base.php | 54 ++++++++-------- .../fixtures/services_notification.yml | 70 +++++++++++++++++++++ tests/notification/manager_helper.php | 37 ----------- tests/notification/notification_test.php | 2 +- tests/notification/submit_post_base.php | 71 +++++++++------------- tests/notification/submit_post_type_quote_test.php | 3 +- 6 files changed, 130 insertions(+), 107 deletions(-) create mode 100644 tests/notification/fixtures/services_notification.yml (limited to 'tests/notification') diff --git a/tests/notification/base.php b/tests/notification/base.php index c898c76947..1295f099f0 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -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 @@ -70,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, @@ -80,36 +85,48 @@ 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_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); @@ -117,11 +134,9 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $methods = array(); foreach ($this->get_notification_methods() as $method) { - $method_parts = explode('.', $method); - $class = $this->build_type('phpbb\notification\method\\' . array_pop($method_parts)); + $class = $this->container->get($method); $methods[$method] = $class; - $this->container->set($method, $class); } $this->notifications->set_var('notification_methods', $methods); @@ -133,26 +148,11 @@ 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_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 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('notification.method.board', array_merge(array( diff --git a/tests/notification/fixtures/services_notification.yml b/tests/notification/fixtures/services_notification.yml new file mode 100644 index 0000000000..7eaa7e81ec --- /dev/null +++ b/tests/notification/fixtures/services_notification.yml @@ -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 } diff --git a/tests/notification/manager_helper.php b/tests/notification/manager_helper.php index 40cf9b3ad4..2e8699e1e0 100644 --- a/tests/notification/manager_helper.php +++ b/tests/notification/manager_helper.php @@ -37,41 +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->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_parts = explode('.', $method_name); - $method_name = 'phpbb\notification\method\\' . array_pop($method_parts); - - $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, NOTIFICATIONS_TABLE, $this->user_notifications_table); - - $method->set_notification_manager($this); - - return $method; - } } diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index 167cde13ca..ec42aa193c 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -81,9 +81,9 @@ class phpbb_notification_test extends phpbb_tests_notification_base ); $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]); } diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 73711369ed..72b25abf0a 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -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'; @@ -75,8 +79,9 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c '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, @@ -103,58 +108,49 @@ 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 = $this->build_type($type); - $phpbb_container->set('notification.type.' . $type, array(array($this, 'build_type'), array($type))); + $class = $phpbb_container->get('notification.type.' . $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_methods_array = array('notification.method.board' => $phpbb_container->get('notification.method.board')); // Notification Manager $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, + $phpbb_container, $user_loader, $phpbb_dispatcher, $db, $cache, $user, 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 */ @@ -177,11 +173,4 @@ 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'); - } } diff --git a/tests/notification/submit_post_type_quote_test.php b/tests/notification/submit_post_type_quote_test.php index 8ad6a62b09..3fab8c05ba 100644 --- a/tests/notification/submit_post_type_quote_test.php +++ b/tests/notification/submit_post_type_quote_test.php @@ -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( /** -- cgit v1.2.1 From 981bd8bed4f126ec01e02d9e1737c4d42994461c Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 29 May 2015 14:40:23 +0200 Subject: [ticket/12143] Fix those tests I always have to fix them.. :( PHPBB3-12143 --- tests/notification/group_request_test.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/notification') diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index a24808fbbd..d16e198861 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -49,6 +49,11 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas $this->user, $this->cache->get_driver() )); + $this->container->set('group_helper', new \phpbb\group\helper( + new \phpbb\language\language( + new phpbb\language\language_file_loader($phpbb_root_path, $phpEx) + ) + )); $phpbb_dispatcher = new phpbb_mock_event_dispatcher; $phpbb_log = new \phpbb\log\dummy(); $this->get_test_case_helpers()->set_s9e_services(); -- cgit v1.2.1 From 25103698040977fd0d655d6e658157a07bb24990 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 19 Jul 2015 22:53:28 +0200 Subject: [ticket/12143] Fix tests after rebase PHPBB3-12143 --- tests/notification/fixtures/services_notification.yml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/notification') diff --git a/tests/notification/fixtures/services_notification.yml b/tests/notification/fixtures/services_notification.yml index 7eaa7e81ec..e0a404b12b 100644 --- a/tests/notification/fixtures/services_notification.yml +++ b/tests/notification/fixtures/services_notification.yml @@ -23,6 +23,9 @@ services: cache.driver: synthetic: true + group_helper: + synthetic: true + path_helper: synthetic: true -- cgit v1.2.1 From b64a37d451132dcf7ef5fc3d6e700a6fb6decd90 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 13 Oct 2015 23:40:52 -0700 Subject: [ticket/14237] Use $language class for notifications PHPBB3-14237 --- tests/notification/base.php | 2 ++ tests/notification/fixtures/services_notification.yml | 3 +++ tests/notification/submit_post_base.php | 10 +++++++--- tests/notification/user_list_trim_test.php | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) (limited to 'tests/notification') diff --git a/tests/notification/base.php b/tests/notification/base.php index 1295f099f0..b64e25cf8c 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -90,6 +90,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $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('config', $this->config); $phpbb_container->set('dbal.conn', $this->db); $phpbb_container->set('auth', $auth); @@ -111,6 +112,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $this->phpbb_dispatcher, $this->db, $this->cache, + $lang, $this->user, 'phpbb_notification_types', 'phpbb_user_notifications' diff --git a/tests/notification/fixtures/services_notification.yml b/tests/notification/fixtures/services_notification.yml index e0a404b12b..6e68cccff6 100644 --- a/tests/notification/fixtures/services_notification.yml +++ b/tests/notification/fixtures/services_notification.yml @@ -17,6 +17,9 @@ services: dbal.conn: synthetic: true + language: + synthetic: true + auth: synthetic: true diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 72b25abf0a..14ca4499d2 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -54,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, $user_loader; + global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader; // Database $this->db = $this->new_dbal(); @@ -91,9 +91,12 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c // Event dispatcher $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + // Language + $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + // User $user = $this->getMock('\phpbb\user', array(), array( - new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + $lang, '\phpbb\datetime' )); $user->ip = ''; @@ -117,6 +120,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $loader->load('services_notification.yml'); $phpbb_container->set('user_loader', $user_loader); $phpbb_container->set('user', $user); + $phpbb_container->set('language', $lang); $phpbb_container->set('config', $config); $phpbb_container->set('dbal.conn', $db); $phpbb_container->set('auth', $auth); @@ -146,7 +150,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c // Notification Manager $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, $notification_methods_array, - $phpbb_container, $user_loader, $phpbb_dispatcher, $db, $cache, $user, + $phpbb_container, $user_loader, $phpbb_dispatcher, $db, $cache, $lang, $user, NOTIFICATION_TYPES_TABLE, USER_NOTIFICATIONS_TABLE); $phpbb_container->set('notification_manager', $phpbb_notifications); } diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index d57fbf0485..9f6eb492f6 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -55,13 +55,13 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->data = array('user_lang' => 'en'); - $user->add_lang('common'); + $lang->add_lang('common'); $user_loader = new phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE); $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 + $user_loader, null, null, $lang, $user, null, null, $phpbb_root_path, $phpEx, null, null ); } -- cgit v1.2.1 From 14e8113fcf01be7dbdb080458fcbf4e75668cc1a Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 31 Mar 2016 11:06:47 -0700 Subject: [ticket/14576] Move common required files to bootstrap PHPBB3-14576 --- tests/notification/group_request_test.php | 1 - tests/notification/submit_post_base.php | 3 --- tests/notification/user_list_trim_test.php | 3 --- 3 files changed, 7 deletions(-) (limited to 'tests/notification') diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index d16e198861..92e758a336 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -12,7 +12,6 @@ */ require_once dirname(__FILE__) . '/base.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_notification_group_request_test extends phpbb_tests_notification_base { diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 14ca4499d2..21559c42a5 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -15,10 +15,7 @@ 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'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; abstract class phpbb_notification_submit_post_base extends phpbb_database_test_case { diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index 9f6eb492f6..7d4dff6024 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_notification_user_list_trim_test extends phpbb_database_test_case { protected $notification; -- cgit v1.2.1