From 7e2f80ec0ab69c512383602c42b84db1c767180e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 26 Mar 2013 12:59:35 +0100 Subject: [PATCH] [ticket/11405] Add unit tests for bookmarking PHPBB3-11405 --- .../fixtures/submit_post_notification.xml | 75 ++++++++++++++++ .../submit_post_type_bookmark_test.php | 90 +++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 tests/notification/submit_post_type_bookmark_test.php 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 @@ + + topic_id + user_id + + 1 + 2 + + + 1 + 3 + + + 1 + 4 + + + 1 + 5 + + + 1 + 6 + + + 1 + 7 + +
forum_iduser_id @@ -43,6 +71,14 @@ 0 + + bookmark + 5 + 1 + 1 + 0 + + post 8 @@ -63,6 +99,10 @@ quote 1 + + bookmark + 1 +
post_id @@ -190,6 +230,13 @@ 1 + + bookmark + 0 + 2 + + 1 + post 0 @@ -204,6 +251,13 @@ 1 + + bookmark + 0 + 3 + + 1 + post 0 @@ -218,6 +272,13 @@ 1 + + bookmark + 0 + 4 + + 1 + post 0 @@ -232,6 +293,13 @@ 1 + + bookmark + 0 + 5 + + 1 + post 0 @@ -246,6 +314,13 @@ 0 + + bookmark + 0 + 6 + + 0 + post 0 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), + ), + ), + ); + } +}