diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-03-26 13:33:32 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-03-26 20:17:26 +0100 |
commit | 8a94e08e3009fece3f9de2d28c8f873dc4471b52 (patch) | |
tree | 4cdae6c6bcd471cae138dea8f4ee3bc5995e5a51 /tests/notification | |
parent | 0f204595d9b69c29716e8cf0ccf5033e66f5294f (diff) | |
download | forums-8a94e08e3009fece3f9de2d28c8f873dc4471b52.tar forums-8a94e08e3009fece3f9de2d28c8f873dc4471b52.tar.gz forums-8a94e08e3009fece3f9de2d28c8f873dc4471b52.tar.bz2 forums-8a94e08e3009fece3f9de2d28c8f873dc4471b52.tar.xz forums-8a94e08e3009fece3f9de2d28c8f873dc4471b52.zip |
[ticket/11405] Add unit tests for post_in_queue
PHPBB3-11405
Diffstat (limited to 'tests/notification')
-rw-r--r-- | tests/notification/fixtures/submit_post_post_in_queue.xml | 160 | ||||
-rw-r--r-- | tests/notification/submit_post_type_post_in_queue_test.php | 102 |
2 files changed, 262 insertions, 0 deletions
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..4162d01d7f --- /dev/null +++ b/tests/notification/fixtures/submit_post_post_in_queue.xml @@ -0,0 +1,160 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_notifications"> + <column>item_type</column> + <column>user_id</column> + <column>item_id</column> + <column>item_parent_id</column> + <column>notification_read</column> + <column>notification_data</column> + <row> + <value>post_in_queue</value> + <value>6</value> + <value>1</value> + <value>1</value> + <value>0</value> + <value></value> + </row> + </table> + <table name="phpbb_notification_types"> + <column>notification_type</column> + <column>notification_type_enabled</column> + <row> + <value>post_in_queue</value> + <value>1</value> + </row> + </table> + <table name="phpbb_posts"> + <column>post_id</column> + <column>topic_id</column> + <column>forum_id</column> + <column>post_text</column> + <row> + <value>1</value> + <value>1</value> + <value>1</value> + <value></value> + </row> + </table> + <table name="phpbb_topics"> + <column>topic_id</column> + <column>forum_id</column> + <row> + <value>1</value> + <value>1</value> + </row> + </table> + <table name="phpbb_users"> + <column>user_id</column> + <column>username_clean</column> + <column>user_permissions</column> + <column>user_sig</column> + <column>user_occ</column> + <column>user_interests</column> + <row> + <value>2</value> + <value>poster</value> + <value></value> + <value></value> + <value></value> + <value></value> + </row> + <row> + <value>3</value> + <value>test</value> + <value></value> + <value></value> + <value></value> + <value></value> + </row> + <row> + <value>4</value> + <value>unauthorized-mod</value> + <value></value> + <value></value> + <value></value> + <value></value> + </row> + <row> + <value>5</value> + <value>unauthorized-read</value> + <value></value> + <value></value> + <value></value> + <value></value> + </row> + <row> + <value>6</value> + <value>notified</value> + <value></value> + <value></value> + <value></value> + <value></value> + </row> + <row> + <value>7</value> + <value>disabled</value> + <value></value> + <value></value> + <value></value> + <value></value> + </row> + <row> + <value>8</value> + <value>default</value> + <value></value> + <value></value> + <value></value> + <value></value> + </row> + </table> + <table name="phpbb_user_notifications"> + <column>item_type</column> + <column>item_id</column> + <column>user_id</column> + <column>method</column> + <column>notify</column> + <row> + <value>needs_approval</value> + <value>0</value> + <value>2</value> + <value></value> + <value>1</value> + </row> + <row> + <value>needs_approval</value> + <value>0</value> + <value>3</value> + <value></value> + <value>1</value> + </row> + <row> + <value>needs_approval</value> + <value>0</value> + <value>4</value> + <value></value> + <value>1</value> + </row> + <row> + <value>needs_approval</value> + <value>0</value> + <value>5</value> + <value></value> + <value>1</value> + </row> + <row> + <value>needs_approval</value> + <value>0</value> + <value>6</value> + <value></value> + <value>1</value> + </row> + <row> + <value>needs_approval</value> + <value>0</value> + <value>7</value> + <value></value> + <value>0</value> + </row> + </table> +</dataset> 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..375ee3fbef --- /dev/null +++ b/tests/notification/submit_post_type_post_in_queue_test.php @@ -0,0 +1,102 @@ +<?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_post_in_queue_test extends phpbb_notification_submit_post_base +{ + protected $item_type = 'post_in_queue'; + + 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( + false, + 'm_approve', + array(1, 0), + array( + 1 => array( + 'm_approve' => array(3, 4, 6, 7, 8), + ), + ), + ), + array( + array(3, 4, 6, 7, 8), + 'f_read', + 1, + array( + 1 => array( + 'f_read' => array(3, 6, 7, 8), + ), + ), + ), + ))); + } + + /** + * 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 + */ + 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), + ), + ), + ); + } +} |