From 33371effc414fd1712cfd819a5d36b18a91c1e3f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 4 Oct 2012 15:28:51 -0500 Subject: [ticket/11103] Mock notification manager Fixing delete_user_pms_test.php PHPBB3-11103 --- tests/mock/notification_manager.php | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/mock/notification_manager.php (limited to 'tests/mock') diff --git a/tests/mock/notification_manager.php b/tests/mock/notification_manager.php new file mode 100644 index 0000000000..fdcd681de4 --- /dev/null +++ b/tests/mock/notification_manager.php @@ -0,0 +1,76 @@ + array(), + 'unread_count' => 0, + ); + } + + public function mark_notifications_read() {} + + public function mark_notifications_read_by_parent() {} + + public function mark_notifications_read_by_id() {} + + + public function add_notifications() + { + return array(); + } + + public function add_notifications_for_users() {} + + public function update_notifications() {} + + public function delete_notifications() {} + + public function get_subscription_types() + { + return array(); + } + + public function get_subscription_methods() + { + return array(); + } + + + public function get_subscriptions() + { + return array(); + } + + public function add_subscription() {} + + public function delete_subscription() {} + + public function load_users() {} + + public function get_user() + { + return null; + } +} -- cgit v1.2.1 From a57f207d6893289598bcd5e37f2549eea60d1137 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Oct 2012 15:09:29 -0500 Subject: [ticket/11103] More extensive notification tests PHPBB3-11103 --- tests/mock/notifications_auth.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/mock/notifications_auth.php (limited to 'tests/mock') diff --git a/tests/mock/notifications_auth.php b/tests/mock/notifications_auth.php new file mode 100644 index 0000000000..d1c1458de7 --- /dev/null +++ b/tests/mock/notifications_auth.php @@ -0,0 +1,35 @@ + Date: Thu, 18 Oct 2012 19:24:08 -0500 Subject: [ticket/11103] Brackets on their own lines PHPBB3-11103 --- tests/mock/notification_manager.php | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'tests/mock') diff --git a/tests/mock/notification_manager.php b/tests/mock/notification_manager.php index fdcd681de4..388be3a28c 100644 --- a/tests/mock/notification_manager.php +++ b/tests/mock/notification_manager.php @@ -29,11 +29,17 @@ class phpbb_mock_notification_manager ); } - public function mark_notifications_read() {} + public function mark_notifications_read() + { + } - public function mark_notifications_read_by_parent() {} + public function mark_notifications_read_by_parent() + { + } - public function mark_notifications_read_by_id() {} + public function mark_notifications_read_by_id() + { + } public function add_notifications() @@ -41,11 +47,17 @@ class phpbb_mock_notification_manager return array(); } - public function add_notifications_for_users() {} + public function add_notifications_for_users() + { + } - public function update_notifications() {} + public function update_notifications() + { + } - public function delete_notifications() {} + public function delete_notifications() + { + } public function get_subscription_types() { @@ -63,11 +75,17 @@ class phpbb_mock_notification_manager return array(); } - public function add_subscription() {} + public function add_subscription() + { + } - public function delete_subscription() {} + public function delete_subscription() + { + } - public function load_users() {} + public function load_users() + { + } public function get_user() { -- cgit v1.2.1 From bc18e368c36af90b2e998913e827dc7be71f3bd0 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 20 Oct 2012 21:55:58 -0500 Subject: [ticket/11103] Correct the test case Fix a bug that broke it and make sure to set the needed config/auth settings PHPBB3-11103 --- tests/mock/notifications_auth.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/mock') diff --git a/tests/mock/notifications_auth.php b/tests/mock/notifications_auth.php index d1c1458de7..d960acb81a 100644 --- a/tests/mock/notifications_auth.php +++ b/tests/mock/notifications_auth.php @@ -32,4 +32,9 @@ class phpbb_mock_notifications_auth extends phpbb_auth return $auth_list; } + + function acl_get($opt, $f = 0) + { + return true; + } } -- cgit v1.2.1 From e549b7663da47d7518b93074e513c7e1d034bf52 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 29 Oct 2012 18:09:20 -0500 Subject: [ticket/11103] Set basic notifications to be enabled by default Now, if there is no row for the user in the user_notifications table, the user will receive basic notifications. If the user wishes to not receive notifications, a row must be added with notify = 0. For other methods besides the basic (e.g. email, jabber) a row must still be added with notify = 1 for them to receive notifications PHPBB3-11103 --- tests/mock/notification_manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/mock') diff --git a/tests/mock/notification_manager.php b/tests/mock/notification_manager.php index 388be3a28c..47fe30730f 100644 --- a/tests/mock/notification_manager.php +++ b/tests/mock/notification_manager.php @@ -70,7 +70,7 @@ class phpbb_mock_notification_manager } - public function get_subscriptions() + public function get_global_subscriptions() { return array(); } -- cgit v1.2.1 From 2afb8b9df873c3f9572a32ab7a62ea8ba8d8a45b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 20 Nov 2012 18:14:48 -0600 Subject: [ticket/11103] Create user loader class, update for DIC Create a very basic user loader class to handle querying/storing user data in a centralized location. Use DIC collection service for notification types/methods. Cleanup unused dependencies. Fix some other issues. PHPBB3-11103 --- tests/mock/container_builder.php | 19 +++++++ tests/mock/notifications_notification_manager.php | 69 +++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 tests/mock/notifications_notification_manager.php (limited to 'tests/mock') diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php index 8a81dd72d1..734d3e1741 100644 --- a/tests/mock/container_builder.php +++ b/tests/mock/container_builder.php @@ -11,6 +11,9 @@ use Symfony\Component\DependencyInjection\ScopeInterface; class phpbb_mock_container_builder implements ContainerInterface { + protected $services = array(); + protected $parameters = array(); + /** * Sets a service. * @@ -22,6 +25,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function set($id, $service, $scope = self::SCOPE_CONTAINER) { + $this->services[$id] = $service; } /** @@ -42,6 +46,12 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) { + if ($this->has($id)) + { + return $this->services[$id]; + } + + throw new Exception('Could not find service: ' . $id); } /** @@ -55,6 +65,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function has($id) { + return isset($this->services[$id]); } /** @@ -70,6 +81,12 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function getParameter($name) { + if ($this->hasParameter($name)) + { + return $this->parameters[$name]; + } + + throw new Exception('Could not find parameter: ' . $name); } /** @@ -83,6 +100,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function hasParameter($name) { + return isset($this->parameters[$name]); } /** @@ -95,6 +113,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function setParameter($name, $value) { + $this->parameters[$name] = $value; } /** diff --git a/tests/mock/notifications_notification_manager.php b/tests/mock/notifications_notification_manager.php new file mode 100644 index 0000000000..81f24e67c0 --- /dev/null +++ b/tests/mock/notifications_notification_manager.php @@ -0,0 +1,69 @@ +$name = $value; + } + + // Extra dependencies for get_*_class functions + protected $auth = null; + protected $cache = null; + protected $config = null; + public function setDependencies($auth, $cache, $config) + { + $this->auth = $auth; + $this->cache = $cache; + $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_type = 'phpbb_notification_type_' . $item_type; + + $item = new $item_type($this->user_loader, $this->db, $this->cache, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notifications_table, $this->user_notifications_table); + + $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, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notifications_table, $this->user_notifications_table); + + $method->set_notification_manager($this); + + return $method; + } +} -- cgit v1.2.1 From e50f69187f21e29a12512880e0c69f2876e84aa1 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 20 Dec 2012 04:35:30 -0500 Subject: [ticket/11037] Eliminate global $db usage in cache drivers. The only time $db is needed in cache drivers is to navigate the result set in sql_save. Pass it as a parameter in that function. PHPBB3-11037 --- tests/mock/cache.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/mock') diff --git a/tests/mock/cache.php b/tests/mock/cache.php index bc18ca066b..71af3037f5 100644 --- a/tests/mock/cache.php +++ b/tests/mock/cache.php @@ -121,7 +121,11 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface public function sql_load($query) { } - public function sql_save($query, $query_result, $ttl) + + /** + * {@inheritDoc} + */ + public function sql_save(phpbb_db_driver $db, $query, $query_result, $ttl) { return $query_result; } -- cgit v1.2.1 From 07282a30ae077825ea81a4e26839ac0473dc97b7 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 15 Jan 2013 12:10:07 -0600 Subject: [ticket/11103] Fix some various issues, better comments PHPBB3-11103 --- tests/mock/notifications_notification_manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/mock') diff --git a/tests/mock/notifications_notification_manager.php b/tests/mock/notifications_notification_manager.php index 81f24e67c0..c995afb9ab 100644 --- a/tests/mock/notifications_notification_manager.php +++ b/tests/mock/notifications_notification_manager.php @@ -44,7 +44,7 @@ class phpbb_mock_notifications_notification_manager extends phpbb_notification_m { $item_type = 'phpbb_notification_type_' . $item_type; - $item = new $item_type($this->user_loader, $this->db, $this->cache, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notifications_table, $this->user_notifications_table); + $item = new $item_type($this->user_loader, $this->db, $this->cache, $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->set_notification_manager($this); @@ -60,7 +60,7 @@ class phpbb_mock_notifications_notification_manager extends phpbb_notification_m { $method_name = 'phpbb_notification_method_' . $method_name; - $method = new $method_name($this->user_loader, $this->db, $this->cache, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notifications_table, $this->user_notifications_table); + $method = new $method_name($this->user_loader, $this->db, $this->cache, $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); -- cgit v1.2.1