mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/13713] Introduce tests for user notifications
PHPBB3-13713
This commit is contained in:
parent
99d57e2743
commit
0fd78c5c87
5 changed files with 262 additions and 0 deletions
|
@ -74,6 +74,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
|
|||
'allow_topic_notify' => true,
|
||||
'allow_forum_notify' => true,
|
||||
'allow_board_notifications' => true,
|
||||
'allow_mentions' => true,
|
||||
));
|
||||
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||
$lang = new \phpbb\language\language($lang_loader);
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_notifications">
|
||||
<column>notification_id</column>
|
||||
<column>notification_type_id</column>
|
||||
<column>user_id</column>
|
||||
<column>item_id</column>
|
||||
<column>item_parent_id</column>
|
||||
<column>notification_read</column>
|
||||
<column>notification_data</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>5</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_notification_types">
|
||||
<column>notification_type_id</column>
|
||||
<column>notification_type_name</column>
|
||||
<column>notification_type_enabled</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>notification.type.mention</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>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>poster</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>test</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>4</value>
|
||||
<value>unauthorized</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>5</value>
|
||||
<value>notified</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>6</value>
|
||||
<value>disabled</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>7</value>
|
||||
<value>default</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>notification.type.mention</value>
|
||||
<value>0</value>
|
||||
<value>2</value>
|
||||
<value>notification.method.board</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>notification.type.mention</value>
|
||||
<value>0</value>
|
||||
<value>3</value>
|
||||
<value>notification.method.board</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>notification.type.mention</value>
|
||||
<value>0</value>
|
||||
<value>4</value>
|
||||
<value>notification.method.board</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>notification.type.mention</value>
|
||||
<value>0</value>
|
||||
<value>5</value>
|
||||
<value>notification.method.board</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>notification.type.mention</value>
|
||||
<value>0</value>
|
||||
<value>6</value>
|
||||
<value>notification.method.board</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
|
@ -59,6 +59,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base
|
|||
self::assertArrayHasKey('NOTIFICATION_GROUP_POSTING', $subscription_types);
|
||||
|
||||
self::assertArrayHasKey('notification.type.bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']);
|
||||
self::assertArrayHasKey('notification.type.mention', $subscription_types['NOTIFICATION_GROUP_POSTING']);
|
||||
self::assertArrayHasKey('notification.type.post', $subscription_types['NOTIFICATION_GROUP_POSTING']);
|
||||
self::assertArrayHasKey('notification.type.quote', $subscription_types['NOTIFICATION_GROUP_POSTING']);
|
||||
self::assertArrayHasKey('notification.type.topic', $subscription_types['NOTIFICATION_GROUP_POSTING']);
|
||||
|
@ -73,6 +74,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base
|
|||
{
|
||||
$expected_subscriptions = array(
|
||||
'notification.type.forum' => array('notification.method.board'),
|
||||
'notification.type.mention' => array('notification.method.board'),
|
||||
'notification.type.post' => array('notification.method.board'),
|
||||
'notification.type.topic' => array('notification.method.board'),
|
||||
'notification.type.quote' => array('notification.method.board'),
|
||||
|
|
|
@ -70,6 +70,8 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
|
|||
array('f_noapprove', 1, true),
|
||||
array('f_postcount', 1, true),
|
||||
array('m_edit', 1, false),
|
||||
array('f_mention', 1, true),
|
||||
array('u_mention', 0, true),
|
||||
)));
|
||||
|
||||
// Config
|
||||
|
@ -77,6 +79,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
|
|||
'num_topics' => 1,
|
||||
'num_posts' => 1,
|
||||
'allow_board_notifications' => true,
|
||||
'allow_mentions' => true,
|
||||
));
|
||||
|
||||
$cache_driver = new \phpbb\cache\driver\dummy();
|
||||
|
|
121
tests/notification/submit_post_type_mention_test.php
Normal file
121
tests/notification/submit_post_type_mention_test.php
Normal file
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/submit_post_base.php';
|
||||
|
||||
class phpbb_notification_submit_post_type_mention_test extends phpbb_notification_submit_post_base
|
||||
{
|
||||
protected $item_type = 'notification.type.mention';
|
||||
|
||||
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, 8),
|
||||
'f_read',
|
||||
1,
|
||||
array(
|
||||
1 => array(
|
||||
'f_read' => array(3, 5, 6, 7),
|
||||
),
|
||||
),
|
||||
),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* submit_post() Notifications test
|
||||
*
|
||||
* submit_post() $mode = 'reply'
|
||||
* Notification item_type = 'mention'
|
||||
*/
|
||||
public function submit_post_data()
|
||||
{
|
||||
// The new mock container is needed because the data providers may be executed before phpunit call setUp()
|
||||
$parser = $this->get_test_case_helpers()->set_s9e_services(new phpbb_mock_container_builder())->get('text_formatter.parser');
|
||||
|
||||
return array(
|
||||
/**
|
||||
* Normal post
|
||||
*
|
||||
* User => State description
|
||||
* 2 => Poster, should NOT receive a notification
|
||||
* 3 => mentioned, should receive a notification
|
||||
* 4 => mentioned, but unauthed to read, should NOT receive a notification
|
||||
* 5 => mentioned, but already notified, should STILL receive a new notification
|
||||
* 6 => mentioned, but option disabled, should NOT receive a notification
|
||||
* 7 => mentioned, option set to default, should receive a notification
|
||||
*/
|
||||
array(
|
||||
array(
|
||||
'message' => $parser->parse(implode(' ', array(
|
||||
'[mention=u:2]poster[/mention] poster should not be notified',
|
||||
'[mention=u:3]test[/mention] test should be notified',
|
||||
'[mention=u:4]unauthorized[/mention] unauthorized to read, should not receive a notification',
|
||||
'[mention=u:5]notified[/mention] already notified, should not receive a new notification',
|
||||
'[mention=u:6]disabled[/mention] option disabled, should not receive a notification',
|
||||
'[mention=u:7]default[/mention] option set to default, should receive a notification',
|
||||
'[mention=u:8]doesn\'t exist[/mention] user does not exist, should not receive a notification',
|
||||
))),
|
||||
'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' => 5, 'item_id' => 2, 'item_parent_id' => 1),
|
||||
array('user_id' => 7, 'item_id' => 2, 'item_parent_id' => 1),
|
||||
),
|
||||
),
|
||||
|
||||
/**
|
||||
* Unapproved post
|
||||
*
|
||||
* No new notifications
|
||||
*/
|
||||
array(
|
||||
array(
|
||||
'message' => $parser->parse(implode(' ', array(
|
||||
'[mention=u:2]poster[/mention] poster should not be notified',
|
||||
'[mention=u:3]test[/mention] test should be notified',
|
||||
'[mention=u:4]unauthorized[/mention] unauthorized to read, should not receive a notification',
|
||||
'[mention=u:5]notified[/mention] already notified, should not receive a new notification',
|
||||
'[mention=u:6]disabled[/mention] option disabled, should not receive a notification',
|
||||
'[mention=u:7]default[/mention] option set to default, should receive a notification',
|
||||
'[mention=u:8]doesn\'t exist[/mention] user does not exist, should not receive a notification',
|
||||
))),
|
||||
'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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue