diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2012-10-29 18:09:20 -0500 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2012-10-29 18:09:20 -0500 |
commit | e549b7663da47d7518b93074e513c7e1d034bf52 (patch) | |
tree | de8b250ab18d550e597c7d093a0633a6f2004bed /tests | |
parent | eddb56f8426161923d8870ca5f8f899c342075db (diff) | |
download | forums-e549b7663da47d7518b93074e513c7e1d034bf52.tar forums-e549b7663da47d7518b93074e513c7e1d034bf52.tar.gz forums-e549b7663da47d7518b93074e513c7e1d034bf52.tar.bz2 forums-e549b7663da47d7518b93074e513c7e1d034bf52.tar.xz forums-e549b7663da47d7518b93074e513c7e1d034bf52.zip |
[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
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mock/notification_manager.php | 2 | ||||
-rw-r--r-- | tests/notification/ext/test/notification/type/test.php | 2 | ||||
-rw-r--r-- | tests/notification/notification.php | 149 |
3 files changed, 6 insertions, 147 deletions
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(); } diff --git a/tests/notification/ext/test/notification/type/test.php b/tests/notification/ext/test/notification/type/test.php index e76bdb5e0c..34149484df 100644 --- a/tests/notification/ext/test/notification/type/test.php +++ b/tests/notification/ext/test/notification/type/test.php @@ -29,7 +29,7 @@ class phpbb_ext_test_notification_type_test extends phpbb_notification_type_base public function find_users_for_notification($post, $options = array()) { - return $this->_find_users_for_notification(0, $options); + return $this->check_user_notification_options(array(0), $options); } public function create_insert_array($post, $pre_create_data = array()) diff --git a/tests/notification/notification.php b/tests/notification/notification.php index bb671e62ef..4bacc2a954 100644 --- a/tests/notification/notification.php +++ b/tests/notification/notification.php @@ -119,159 +119,19 @@ class phpbb_notification_test extends phpbb_database_test_case public function test_subscriptions() { - $this->notifications->add_subscription('phpbb_notification_type_post', 0, ''); - $this->notifications->add_subscription('phpbb_notification_type_post', 0, '', 1); - $this->notifications->add_subscription('phpbb_notification_type_quote', 0, '', 1); - - $this->notifications->add_subscription('phpbb_notification_type_post', 0, '', 2); - $this->notifications->add_subscription('phpbb_notification_type_post', 0, 'email', 2); - $this->notifications->add_subscription('phpbb_notification_type_post', 0, 'jabber', 2); - $this->notifications->add_subscription('phpbb_notification_type_post', 1, '', 2); - $this->notifications->add_subscription('phpbb_notification_type_post', 1, 'email', 2); - $this->notifications->add_subscription('phpbb_notification_type_post', 1, 'jabber', 2); - $this->notifications->add_subscription('phpbb_notification_type_post', 2, '', 2); - $this->notifications->add_subscription('phpbb_notification_type_post', 2, 'email', 2); - $this->notifications->add_subscription('phpbb_notification_type_post', 2, 'jabber', 2); - - $this->assertEquals(array( - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 0, - 'user_id' => 0, - 'method' => '', - ), - ), $this->notifications->get_subscriptions()); - - $this->assertEquals(array( - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 0, - 'user_id' => 1, - 'method' => '', - ), - array( - 'item_type' => 'phpbb_notification_type_quote', - 'item_id' => 0, - 'user_id' => 1, - 'method' => '', - ), - ), $this->notifications->get_subscriptions(1)); - - $this->assertEquals(array( - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 0, - 'user_id' => 2, - 'method' => '', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 0, - 'user_id' => 2, - 'method' => 'email', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 0, - 'user_id' => 2, - 'method' => 'jabber', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 1, - 'user_id' => 2, - 'method' => '', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 1, - 'user_id' => 2, - 'method' => 'email', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 1, - 'user_id' => 2, - 'method' => 'jabber', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 2, - 'user_id' => 2, - 'method' => '', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 2, - 'user_id' => 2, - 'method' => 'email', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 2, - 'user_id' => 2, - 'method' => 'jabber', - ), - ), $this->notifications->get_subscriptions(2)); + $this->notifications->delete_subscription('phpbb_notification_type_post', 0, '', 2); - $this->assertEquals(array( - 'phpbb_notification_type_post' => array( - '', - 'email', - 'jabber', - ), - ), $this->notifications->get_subscriptions(2, true)); + $this->assertArrayNotHasKey('phpbb_notification_type_post', $this->notifications->get_global_subscriptions(2)); - $this->notifications->delete_subscription('phpbb_notification_type_post', 0, '', 2); - $this->notifications->delete_subscription('phpbb_notification_type_post', 1, 'email', 2); - $this->notifications->delete_subscription('phpbb_notification_type_post', 2, 'jabber', 2); + $this->notifications->add_subscription('phpbb_notification_type_post', 0, '', 2); - $this->assertEquals(array( - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 0, - 'user_id' => 2, - 'method' => 'email', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 0, - 'user_id' => 2, - 'method' => 'jabber', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 1, - 'user_id' => 2, - 'method' => '', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 1, - 'user_id' => 2, - 'method' => 'jabber', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 2, - 'user_id' => 2, - 'method' => '', - ), - array( - 'item_type' => 'phpbb_notification_type_post', - 'item_id' => 2, - 'user_id' => 2, - 'method' => 'email', - ), - ), $this->notifications->get_subscriptions(2)); + $this->assertArrayHasKey('phpbb_notification_type_post', $this->notifications->get_global_subscriptions(2)); } public function test_notifications() { global $db; - $this->notifications->add_subscription('phpbb_ext_test_notification_type_test'); - // Used to test post notifications later $db->sql_query('INSERT INTO ' . TOPICS_WATCH_TABLE . ' ' . $db->sql_build_array('INSERT', array( 'topic_id' => 2, @@ -320,7 +180,6 @@ class phpbb_notification_test extends phpbb_database_test_case 'topic_id' => 2, 'user_id' => 0, ))); - $this->notifications->add_subscription('phpbb_notification_type_bookmark'); $this->notifications->add_notifications(array('phpbb_notification_type_quote', 'phpbb_notification_type_bookmark', 'phpbb_notification_type_post', 'phpbb_ext_test_notification_type_test'), array( 'post_id' => '5', |