aboutsummaryrefslogtreecommitdiffstats
path: root/tests/notification
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-03-26 12:59:35 +0100
committerJoas Schilling <nickvergessen@gmx.de>2013-03-26 12:59:35 +0100
commit7e2f80ec0ab69c512383602c42b84db1c767180e (patch)
treefc56624ad207b9ddbdf5129cf3bf2769a91668f4 /tests/notification
parentcdd45cb8ba4d420bfc44a9bb7a4c43662ec78156 (diff)
downloadforums-7e2f80ec0ab69c512383602c42b84db1c767180e.tar
forums-7e2f80ec0ab69c512383602c42b84db1c767180e.tar.gz
forums-7e2f80ec0ab69c512383602c42b84db1c767180e.tar.bz2
forums-7e2f80ec0ab69c512383602c42b84db1c767180e.tar.xz
forums-7e2f80ec0ab69c512383602c42b84db1c767180e.zip
[ticket/11405] Add unit tests for bookmarking
PHPBB3-11405
Diffstat (limited to 'tests/notification')
-rw-r--r--tests/notification/fixtures/submit_post_notification.xml75
-rw-r--r--tests/notification/submit_post_type_bookmark_test.php90
2 files changed, 165 insertions, 0 deletions
diff --git a/tests/notification/fixtures/submit_post_notification.xml b/tests/notification/fixtures/submit_post_notification.xml
index 51dd2f8dbd..3f46bc2962 100644
--- a/tests/notification/fixtures/submit_post_notification.xml
+++ b/tests/notification/fixtures/submit_post_notification.xml
@@ -1,5 +1,33 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
+ <table name="phpbb_bookmarks">
+ <column>topic_id</column>
+ <column>user_id</column>
+ <row>
+ <value>1</value>
+ <value>2</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>3</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>4</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>5</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>6</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>7</value>
+ </row>
+ </table>
<table name="phpbb_forums_watch">
<column>forum_id</column>
<column>user_id</column>
@@ -44,6 +72,14 @@
<value></value>
</row>
<row>
+ <value>bookmark</value>
+ <value>5</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value></value>
+ </row>
+ <row>
<value>post</value>
<value>8</value>
<value>1</value>
@@ -63,6 +99,10 @@
<value>quote</value>
<value>1</value>
</row>
+ <row>
+ <value>bookmark</value>
+ <value>1</value>
+ </row>
</table>
<table name="phpbb_posts">
<column>post_id</column>
@@ -191,6 +231,13 @@
<value>1</value>
</row>
<row>
+ <value>bookmark</value>
+ <value>0</value>
+ <value>2</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ <row>
<value>post</value>
<value>0</value>
<value>3</value>
@@ -205,6 +252,13 @@
<value>1</value>
</row>
<row>
+ <value>bookmark</value>
+ <value>0</value>
+ <value>3</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ <row>
<value>post</value>
<value>0</value>
<value>4</value>
@@ -219,6 +273,13 @@
<value>1</value>
</row>
<row>
+ <value>bookmark</value>
+ <value>0</value>
+ <value>4</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ <row>
<value>post</value>
<value>0</value>
<value>5</value>
@@ -233,6 +294,13 @@
<value>1</value>
</row>
<row>
+ <value>bookmark</value>
+ <value>0</value>
+ <value>5</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ <row>
<value>post</value>
<value>0</value>
<value>6</value>
@@ -247,6 +315,13 @@
<value>0</value>
</row>
<row>
+ <value>bookmark</value>
+ <value>0</value>
+ <value>6</value>
+ <value></value>
+ <value>0</value>
+ </row>
+ <row>
<value>post</value>
<value>0</value>
<value>7</value>
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 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/submit_post_base.php';
+
+class phpbb_notification_submit_post_type_bookmark_test extends phpbb_notification_submit_post_base
+{
+ protected $item_type = 'bookmark';
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ global $auth;
+
+ // Add additional permissions
+ $auth->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),
+ ),
+ ),
+ );
+ }
+}