diff --git a/phpBB/includes/notification/type/bookmark.php b/phpBB/includes/notification/type/bookmark.php
index 4e48a967d0..946cb9b4ed 100644
--- a/phpBB/includes/notification/type/bookmark.php
+++ b/phpBB/includes/notification/type/bookmark.php
@@ -89,6 +89,7 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post
{
return array();
}
+ sort($users);
$auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']);
diff --git a/phpBB/includes/notification/type/post.php b/phpBB/includes/notification/type/post.php
index d8ffdea81d..626c13b7fd 100644
--- a/phpBB/includes/notification/type/post.php
+++ b/phpBB/includes/notification/type/post.php
@@ -106,11 +106,26 @@ class phpbb_notification_type_post extends phpbb_notification_type_base
}
$this->db->sql_freeresult($result);
+ $sql = 'SELECT user_id
+ FROM ' . FORUMS_WATCH_TABLE . '
+ WHERE forum_id = ' . (int) $post['forum_id'] . '
+ AND notify_status = ' . NOTIFY_YES . '
+ AND user_id <> ' . (int) $post['poster_id'];
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $users[] = $row['user_id'];
+ }
+ $this->db->sql_freeresult($result);
+
if (empty($users))
{
return array();
}
+ $users = array_unique($users);
+ sort($users);
+
$auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']);
if (empty($auth_read))
diff --git a/phpBB/includes/notification/type/post_in_queue.php b/phpBB/includes/notification/type/post_in_queue.php
index 9c719205e6..bc4b15cdc3 100644
--- a/phpBB/includes/notification/type/post_in_queue.php
+++ b/phpBB/includes/notification/type/post_in_queue.php
@@ -82,7 +82,7 @@ class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post
'ignore_users' => array(),
), $options);
- // 0 is for global
+ // 0 is for global moderator permissions
$auth_approve = $this->auth->acl_get_list(false, $this->permission, array($post['forum_id'], 0));
if (empty($auth_approve))
@@ -101,8 +101,15 @@ class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post
{
$has_permission = array_unique(array_merge($has_permission, $auth_approve[0][$this->permission]));
}
+ sort($has_permission);
- return $this->check_user_notification_options($has_permission, array_merge($options, array(
+ $auth_read = $this->auth->acl_get_list($has_permission, 'f_read', $post['forum_id']);
+ if (empty($auth_read))
+ {
+ return array();
+ }
+
+ return $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], array_merge($options, array(
'item_type' => self::$notification_option['id'],
)));
}
diff --git a/phpBB/includes/notification/type/quote.php b/phpBB/includes/notification/type/quote.php
index 5453b267c8..e9eb7bea21 100644
--- a/phpBB/includes/notification/type/quote.php
+++ b/phpBB/includes/notification/type/quote.php
@@ -108,6 +108,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
{
return array();
}
+ sort($users);
$auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']);
diff --git a/phpBB/includes/notification/type/topic_in_queue.php b/phpBB/includes/notification/type/topic_in_queue.php
index c501434c43..f735e10c00 100644
--- a/phpBB/includes/notification/type/topic_in_queue.php
+++ b/phpBB/includes/notification/type/topic_in_queue.php
@@ -82,7 +82,7 @@ class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_top
'ignore_users' => array(),
), $options);
- // 0 is for global
+ // 0 is for global moderator permissions
$auth_approve = $this->auth->acl_get_list(false, 'm_approve', array($topic['forum_id'], 0));
if (empty($auth_approve))
@@ -101,8 +101,15 @@ class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_top
{
$has_permission = array_unique(array_merge($has_permission, $auth_approve[0][$this->permission]));
}
+ sort($has_permission);
- return $this->check_user_notification_options($has_permission, array_merge($options, array(
+ $auth_read = $this->auth->acl_get_list($has_permission, 'f_read', $topic['forum_id']);
+ if (empty($auth_read))
+ {
+ return array();
+ }
+
+ return $this->check_user_notification_options($auth_read[$topic['forum_id']]['f_read'], array_merge($options, array(
'item_type' => self::$notification_option['id'],
)));
}
diff --git a/tests/notification/fixtures/submit_post_bookmark.xml b/tests/notification/fixtures/submit_post_bookmark.xml
new file mode 100644
index 0000000000..b669d4c1b6
--- /dev/null
+++ b/tests/notification/fixtures/submit_post_bookmark.xml
@@ -0,0 +1,173 @@
+
+
+
+ topic_id
+ user_id
+
+ 1
+ 2
+
+
+ 1
+ 3
+
+
+ 1
+ 4
+
+
+ 1
+ 5
+
+
+ 1
+ 6
+
+
+ 1
+ 7
+
+
+
+ item_type
+ user_id
+ item_id
+ item_parent_id
+ notification_read
+ notification_data
+
+ bookmark
+ 5
+ 1
+ 1
+ 0
+
+
+
+
+ notification_type
+ notification_type_enabled
+
+ bookmark
+ 1
+
+
+
+ post_id
+ topic_id
+ forum_id
+ post_text
+
+ 1
+ 1
+ 1
+
+
+
+
+ topic_id
+ forum_id
+
+ 1
+ 1
+
+
+
+ user_id
+ username_clean
+ user_permissions
+ user_sig
+ user_occ
+ user_interests
+
+ 2
+ poster
+
+
+
+
+
+
+ 3
+ test
+
+
+
+
+
+
+ 4
+ unauthorized
+
+
+
+
+
+
+ 5
+ notified
+
+
+
+
+
+
+ 6
+ disabled
+
+
+
+
+
+
+ 7
+ default
+
+
+
+
+
+
+
+ item_type
+ item_id
+ user_id
+ method
+ notify
+
+ bookmark
+ 0
+ 2
+
+ 1
+
+
+ bookmark
+ 0
+ 3
+
+ 1
+
+
+ bookmark
+ 0
+ 4
+
+ 1
+
+
+ bookmark
+ 0
+ 5
+
+ 1
+
+
+ bookmark
+ 0
+ 6
+
+ 0
+
+
+
diff --git a/tests/notification/fixtures/submit_post_post.xml b/tests/notification/fixtures/submit_post_post.xml
new file mode 100644
index 0000000000..cead4f7c26
--- /dev/null
+++ b/tests/notification/fixtures/submit_post_post.xml
@@ -0,0 +1,217 @@
+
+
+
+ forum_id
+ user_id
+ notify_status
+
+ 1
+ 6
+ 0
+
+
+ 1
+ 7
+ 0
+
+
+ 1
+ 8
+ 0
+
+
+
+ item_type
+ user_id
+ item_id
+ item_parent_id
+ notification_read
+ notification_data
+
+ post
+ 5
+ 1
+ 1
+ 0
+
+
+
+ post
+ 8
+ 1
+ 1
+ 0
+
+
+
+
+ notification_type
+ notification_type_enabled
+
+ post
+ 1
+
+
+
+ post_id
+ topic_id
+ forum_id
+ post_text
+
+ 1
+ 1
+ 1
+
+
+
+
+ topic_id
+ forum_id
+
+ 1
+ 1
+
+
+
+ topic_id
+ user_id
+ notify_status
+
+ 1
+ 2
+ 0
+
+
+ 1
+ 3
+ 0
+
+
+ 1
+ 4
+ 0
+
+
+ 1
+ 5
+ 0
+
+
+ 1
+ 6
+ 0
+
+
+
+ user_id
+ username_clean
+ user_permissions
+ user_sig
+ user_occ
+ user_interests
+
+ 2
+ poster
+
+
+
+
+
+
+ 3
+ test
+
+
+
+
+
+
+ 4
+ unauthorized
+
+
+
+
+
+
+ 5
+ notified
+
+
+
+
+
+
+ 6
+ disabled
+
+
+
+
+
+
+ 7
+ default
+
+
+
+
+
+
+
+ item_type
+ item_id
+ user_id
+ method
+ notify
+
+ post
+ 0
+ 2
+
+ 1
+
+
+ post
+ 0
+ 3
+
+ 1
+
+
+ post
+ 0
+ 4
+
+ 1
+
+
+ post
+ 0
+ 5
+
+ 1
+
+
+ post
+ 0
+ 6
+
+ 1
+
+
+ post
+ 0
+ 7
+
+ 1
+
+
+ post
+ 0
+ 8
+
+ 1
+
+
+
diff --git a/tests/notification/fixtures/submit_post_post_in_queue.xml b/tests/notification/fixtures/submit_post_post_in_queue.xml
new file mode 100644
index 0000000000..eedcebf71d
--- /dev/null
+++ b/tests/notification/fixtures/submit_post_post_in_queue.xml
@@ -0,0 +1,175 @@
+
+
+
+ item_type
+ user_id
+ item_id
+ item_parent_id
+ notification_read
+ notification_data
+
+ post_in_queue
+ 6
+ 1
+ 1
+ 0
+
+
+
+
+ notification_type
+ notification_type_enabled
+
+ post_in_queue
+ 1
+
+
+
+ post_id
+ topic_id
+ forum_id
+ post_text
+
+ 1
+ 1
+ 1
+
+
+
+
+ topic_id
+ forum_id
+
+ 1
+ 1
+
+
+
+ user_id
+ username_clean
+ user_permissions
+ user_sig
+ user_occ
+ user_interests
+
+ 2
+ poster
+
+
+
+
+
+
+ 3
+ test
+
+
+
+
+
+
+ 4
+ unauthorized-mod
+
+
+
+
+
+
+ 5
+ unauthorized-read
+
+
+
+
+
+
+ 6
+ notified
+
+
+
+
+
+
+ 7
+ disabled
+
+
+
+
+
+
+ 8
+ default
+
+
+
+
+
+
+ 9
+ test glboal-permissions
+
+
+
+
+
+
+
+ item_type
+ item_id
+ user_id
+ method
+ notify
+
+ needs_approval
+ 0
+ 2
+
+ 1
+
+
+ needs_approval
+ 0
+ 3
+
+ 1
+
+
+ needs_approval
+ 0
+ 4
+
+ 1
+
+
+ needs_approval
+ 0
+ 5
+
+ 1
+
+
+ needs_approval
+ 0
+ 6
+
+ 1
+
+
+ needs_approval
+ 0
+ 7
+
+ 0
+
+
+ needs_approval
+ 0
+ 9
+
+ 1
+
+
+
diff --git a/tests/notification/fixtures/submit_post_quote.xml b/tests/notification/fixtures/submit_post_quote.xml
new file mode 100644
index 0000000000..884a84af4a
--- /dev/null
+++ b/tests/notification/fixtures/submit_post_quote.xml
@@ -0,0 +1,145 @@
+
+
+
+ item_type
+ user_id
+ item_id
+ item_parent_id
+ notification_read
+ notification_data
+
+ quote
+ 5
+ 1
+ 1
+ 0
+
+
+
+
+ notification_type
+ notification_type_enabled
+
+ quote
+ 1
+
+
+
+ post_id
+ topic_id
+ forum_id
+ post_text
+
+ 1
+ 1
+ 1
+
+
+
+
+ topic_id
+ forum_id
+
+ 1
+ 1
+
+
+
+ user_id
+ username_clean
+ user_permissions
+ user_sig
+ user_occ
+ user_interests
+
+ 2
+ poster
+
+
+
+
+
+
+ 3
+ test
+
+
+
+
+
+
+ 4
+ unauthorized
+
+
+
+
+
+
+ 5
+ notified
+
+
+
+
+
+
+ 6
+ disabled
+
+
+
+
+
+
+ 7
+ default
+
+
+
+
+
+
+
+ item_type
+ item_id
+ user_id
+ method
+ notify
+
+ quote
+ 0
+ 2
+
+ 1
+
+
+ quote
+ 0
+ 3
+
+ 1
+
+
+ quote
+ 0
+ 4
+
+ 1
+
+
+ quote
+ 0
+ 5
+
+ 1
+
+
+ quote
+ 0
+ 6
+
+ 0
+
+
+
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
new file mode 100644
index 0000000000..c5b2450e1c
--- /dev/null
+++ b/tests/notification/submit_post_base.php
@@ -0,0 +1,141 @@
+ 1,
+ 'topic_id' => 1,
+ 'topic_title' => 'topic_title',
+ 'icon_id' => 0,
+ 'enable_bbcode' => 0,
+ 'enable_smilies' => 0,
+ 'enable_urls' => 0,
+ 'enable_sig' => 0,
+ 'message' => '',
+ 'message_md5' => '',
+ 'attachment_data' => array(),
+ 'bbcode_bitfield' => '',
+ 'bbcode_uid' => '',
+ 'post_edit_locked' => false,
+ //'force_approved_state' => 1,
+ );
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/submit_post_' . $this->item_type . '.xml');
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path;
+
+ // Database
+ $this->db = $this->new_dbal();
+ $db = $this->db;
+
+ // Cache
+ $cache = new phpbb_mock_cache();
+
+ // Auth
+ $auth = $this->getMock('phpbb_auth');
+ $auth->expects($this->any())
+ ->method('acl_get')
+ ->with($this->stringContains('_'),
+ $this->anything())
+ ->will($this->returnValueMap(array(
+ array('f_noapprove', 1, true),
+ array('f_postcount', 1, true),
+ array('m_edit', 1, false),
+ )));
+
+ // Config
+ $config = new phpbb_config(array('num_topics' => 1,'num_posts' => 1,));
+ set_config(null, null, null, $config);
+ set_config_count(null, null, null, $config);
+
+ // Event dispatcher
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+
+ // User
+ $user = $this->getMock('phpbb_user');
+ $user->ip = '';
+ $user->data = array(
+ 'user_id' => 2,
+ 'username' => 'user-name',
+ 'is_registered' => true,
+ 'user_colour' => '',
+ );
+
+ // Request
+ $type_cast_helper = $this->getMock('phpbb_request_type_cast_helper_interface');
+ $request = $this->getMock('phpbb_request');
+
+ // Container
+ $phpbb_container = new phpbb_mock_container_builder();
+
+ $user_loader = new phpbb_user_loader($db, $phpbb_root_path, '.' . $phpEx, USERS_TABLE);
+
+ // Notification Manager
+ $phpbb_notifications = new phpbb_notification_manager(array(), array(),
+ $phpbb_container, $user_loader, $db, $user,
+ $phpbb_root_path, '.' . $phpEx,
+ NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
+ $phpbb_container->set('notification_manager', $phpbb_notifications);
+
+ // Notification Types
+ $notification_types = array('quote', 'bookmark', 'post', 'post_in_queue');
+ foreach ($notification_types as $type)
+ {
+ $class_name = 'phpbb_notification_type_' . $type;
+ $phpbb_container->set('notification.type.' . $type, new $class_name(
+ $user_loader, $db, $cache, $user, $auth, $config,
+ $phpbb_root_path, '.' . $phpEx,
+ NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE));
+ }
+ }
+
+ /**
+ * @dataProvider submit_post_data
+ */
+ public function test_submit_post($additional_post_data, $expected_before, $expected_after)
+ {
+ $sql = 'SELECT user_id, item_id, item_parent_id
+ FROM ' . NOTIFICATIONS_TABLE . "
+ WHERE item_type = '" . $this->item_type . "'
+ ORDER BY user_id, item_id ASC";
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_before, $this->db->sql_fetchrowset($result));
+ $this->db->sql_freeresult($result);
+
+ $poll_data = $this->poll_data;
+ $post_data = array_merge($this->post_data, $additional_post_data);
+ submit_post('reply', '', 'poster-name', POST_NORMAL, $poll_data, $post_data, false, false);
+
+ $sql = 'SELECT user_id, item_id, item_parent_id
+ FROM ' . NOTIFICATIONS_TABLE . "
+ WHERE item_type = '" . $this->item_type . "'
+ ORDER BY user_id ASC, item_id ASC";
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_after, $this->db->sql_fetchrowset($result));
+ $this->db->sql_freeresult($result);
+ }
+}
diff --git a/tests/notification/submit_post_type_bookmark_test.php b/tests/notification/submit_post_type_bookmark_test.php
new file mode 100644
index 0000000000..861017ff5f
--- /dev/null
+++ b/tests/notification/submit_post_type_bookmark_test.php
@@ -0,0 +1,90 @@
+expects($this->any())
+ ->method('acl_get_list')
+ ->with($this->anything(),
+ $this->stringContains('_'),
+ $this->greaterThan(0))
+ ->will($this->returnValueMap(array(
+ array(
+ array('3', '4', '5', '6', '7'),
+ 'f_read',
+ 1,
+ array(
+ 1 => array(
+ 'f_read' => array(3, 5, 6, 7),
+ ),
+ ),
+ ),
+ )));
+ }
+
+ /**
+ * submit_post() Notifications test
+ *
+ * submit_post() $mode = 'reply'
+ * Notification item_type = 'bookmark'
+ */
+ public function submit_post_data()
+ {
+ return array(
+ /**
+ * Normal post
+ *
+ * User => State description
+ * 2 => Poster, should NOT receive a notification
+ * 3 => Bookmarked, should receive a notification
+ * 4 => Bookmarked, but unauthed to read, should NOT receive a notification
+ * 5 => Bookmarked, but already notified, should NOT receive a new notification
+ * 6 => Bookmarked, but option disabled, should NOT receive a notification
+ * 7 => Bookmarked, option set to default, should receive a notification
+ */
+ array(
+ array(),
+ array(
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ array(
+ array('user_id' => 3, 'item_id' => 2, 'item_parent_id' => 1),
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ array('user_id' => 7, 'item_id' => 2, 'item_parent_id' => 1),
+ ),
+ ),
+
+ /**
+ * Unapproved post
+ *
+ * No new notifications
+ */
+ array(
+ array('force_approved_state' => false),
+ array(
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ array(
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/notification/submit_post_type_post_in_queue_test.php b/tests/notification/submit_post_type_post_in_queue_test.php
new file mode 100644
index 0000000000..6a7ac44e39
--- /dev/null
+++ b/tests/notification/submit_post_type_post_in_queue_test.php
@@ -0,0 +1,107 @@
+expects($this->any())
+ ->method('acl_get_list')
+ ->with($this->anything(),
+ $this->stringContains('_'),
+ $this->greaterThan(0))
+ ->will($this->returnValueMap(array(
+ array(
+ false,
+ 'm_approve',
+ array(1, 0),
+ array(
+ 0 => array(
+ 'm_approve' => array(9),
+ ),
+ 1 => array(
+ 'm_approve' => array(3, 4, 6, 7, 8),
+ ),
+ ),
+ ),
+ array(
+ array(3, 4, 6, 7, 8, 9),
+ 'f_read',
+ 1,
+ array(
+ 1 => array(
+ 'f_read' => array(3, 6, 7, 8, 9),
+ ),
+ ),
+ ),
+ )));
+ }
+
+ /**
+ * submit_post() Notifications test
+ *
+ * submit_post() $mode = 'reply'
+ * Notification item_type = 'post_in_queue'
+ */
+ public function submit_post_data()
+ {
+ return array(
+ /**
+ * Normal post
+ *
+ * No new notifications
+ */
+ array(
+ array(),
+ array(
+ array('user_id' => 6, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ array(
+ array('user_id' => 6, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ ),
+
+ /**
+ * Unapproved post
+ *
+ * User => State description
+ * 2 => Poster, should NOT receive a notification
+ * 3 => Moderator, should receive a notification
+ * 4 => Moderator, but unauthed to read, should NOT receive a notification
+ * 5 => Moderator, but unauthed to approve, should NOT receive a notification
+ * 6 => Moderator, but already notified, should STILL receive a new notification
+ * 7 => Moderator, but option disabled, should NOT receive a notification
+ * 8 => Moderator, option set to default, should receive a notification
+ * 9 => Moderator, has only global mod permissions, should receive a notification
+ */
+ array(
+ array('force_approved_state' => false),
+ array(
+ array('user_id' => 6, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ array(
+ array('user_id' => 3, 'item_id' => 2, 'item_parent_id' => 1),
+ array('user_id' => 6, 'item_id' => 1, 'item_parent_id' => 1),
+ array('user_id' => 6, 'item_id' => 2, 'item_parent_id' => 1),
+ array('user_id' => 8, 'item_id' => 2, 'item_parent_id' => 1),
+ array('user_id' => 9, 'item_id' => 2, 'item_parent_id' => 1),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/notification/submit_post_type_post_test.php b/tests/notification/submit_post_type_post_test.php
new file mode 100644
index 0000000000..473247a764
--- /dev/null
+++ b/tests/notification/submit_post_type_post_test.php
@@ -0,0 +1,96 @@
+expects($this->any())
+ ->method('acl_get_list')
+ ->with($this->anything(),
+ $this->stringContains('_'),
+ $this->greaterThan(0))
+ ->will($this->returnValueMap(array(
+ array(
+ array('3', '4', '5', '6', '7', '8'),
+ 'f_read',
+ 1,
+ array(
+ 1 => array(
+ 'f_read' => array(3, 5, 6, 7, 8),
+ ),
+ ),
+ ),
+ )));
+ }
+
+ /**
+ * submit_post() Notifications test
+ *
+ * submit_post() $mode = 'reply'
+ * Notification item_type = 'post'
+ */
+ public function submit_post_data()
+ {
+ return array(
+ /**
+ * Normal post
+ *
+ * User => State description
+ * 2 => Poster, should NOT receive a notification
+ * 3 => Topic subscribed, should receive a notification
+ * 4 => Topic subscribed, but unauthed to read, should NOT receive a notification
+ * 5 => Topic subscribed, but already notified, should NOT receive a new notification
+ * 6 => Topic and forum subscribed, should receive ONE notification
+ * 7 => Forum subscribed, should receive a notification
+ * 8 => Forum subscribed, but already notified, should NOT receive a new notification
+ */
+ array(
+ array(),
+ array(
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ array('user_id' => 8, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ array(
+ array('user_id' => 3, 'item_id' => 2, 'item_parent_id' => 1),
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ array('user_id' => 6, 'item_id' => 2, 'item_parent_id' => 1),
+ array('user_id' => 7, 'item_id' => 2, 'item_parent_id' => 1),
+ array('user_id' => 8, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ ),
+
+ /**
+ * Unapproved post
+ *
+ * No new notifications
+ */
+ array(
+ array('force_approved_state' => false),
+ array(
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ array('user_id' => 8, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ array(
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ array('user_id' => 8, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/notification/submit_post_type_quote_test.php b/tests/notification/submit_post_type_quote_test.php
new file mode 100644
index 0000000000..2b66d9c6a1
--- /dev/null
+++ b/tests/notification/submit_post_type_quote_test.php
@@ -0,0 +1,113 @@
+expects($this->any())
+ ->method('acl_get_list')
+ ->with($this->anything(),
+ $this->stringContains('_'),
+ $this->greaterThan(0))
+ ->will($this->returnValueMap(array(
+ array(
+ array('3', '4', '5', '6', '7'),
+ 'f_read',
+ 1,
+ array(
+ 1 => array(
+ 'f_read' => array(3, 5, 6, 7),
+ ),
+ ),
+ ),
+ )));
+ }
+
+ /**
+ * submit_post() Notifications test
+ *
+ * submit_post() $mode = 'reply'
+ * Notification item_type = 'quote'
+ */
+ public function submit_post_data()
+ {
+ return array(
+ /**
+ * Normal post
+ *
+ * User => State description
+ * 2 => Poster, should NOT receive a notification
+ * 3 => Quoted, should receive a notification
+ * 4 => Quoted, but unauthed to read, should NOT receive a notification
+ * 5 => Quoted, but already notified, should NOT receive a new notification
+ * 6 => Quoted, but option disabled, should NOT receive a notification
+ * 7 => Quoted, option set to default, should receive a 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]',
+ )),
+ 'bbcode_uid' => 'uid',
+ ),
+ array(
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ array(
+ array('user_id' => 3, 'item_id' => 2, 'item_parent_id' => 1),
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ array('user_id' => 7, 'item_id' => 2, 'item_parent_id' => 1),
+ ),
+ ),
+
+ /**
+ * Unapproved post
+ *
+ * No new notifications
+ */
+ 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]',
+ )),
+ 'bbcode_uid' => 'uid',
+ 'force_approved_state' => false,
+ ),
+ array(
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ array(
+ array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ ),
+ );
+ }
+}