[ticket/13713] Clean up declarations and adjust tests for latest master

PHPBB3-13713
This commit is contained in:
Marc Alexander 2021-05-03 22:16:15 +02:00
parent c317368a39
commit f27be9a4f1
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
2 changed files with 66 additions and 76 deletions

View file

@ -13,22 +13,22 @@
namespace phpbb\notification\type;
use phpbb\textformatter\s9e\mention_helper;
/**
* Post mentioning notifications class
* This class handles notifying users when they have been mentioned in a post
*/
class mention extends \phpbb\notification\type\post
class mention extends post
{
/**
* @var \phpbb\textformatter\s9e\mention_helper
* @var mention_helper
*/
protected $helper;
/**
* Get notification type name
*
* @return string
* {@inheritDoc}
*/
public function get_type()
{
@ -36,39 +36,29 @@ class mention extends \phpbb\notification\type\post
}
/**
* Language key used to output the text
*
* @var string
*/
* {@inheritDoc}
*/
protected $language_key = 'NOTIFICATION_MENTION';
/**
* Notification option data (for outputting to the user)
*
* @var bool|array False if the service should use it's default data
* Array of data (including keys 'id', 'lang', and 'group')
*/
static public $notification_option = array(
* {@inheritDoc}
*/
public static $notification_option = [
'lang' => 'NOTIFICATION_TYPE_MENTION',
'group' => 'NOTIFICATION_GROUP_POSTING',
);
];
/**
* Is available
*/
* {@inheritDoc}
*/
public function is_available()
{
return $this->config['allow_mentions'] && $this->auth->acl_get('u_mention');
}
/**
* Find the users who want to receive notifications
*
* @param array $post Data from submit_post
* @param array $options Options for finding users for notification
*
* @return array
*/
* {@inheritDoc}
*/
public function find_users_for_notification($post, $options = array())
{
$options = array_merge(array(
@ -128,7 +118,7 @@ class mention extends \phpbb\notification\type\post
}
/**
* {inheritDoc}
* {@inheritDoc}
*/
public function get_redirect_url()
{
@ -136,20 +126,16 @@ class mention extends \phpbb\notification\type\post
}
/**
* Get email template
*
* @return string|bool
*/
* {@inheritDoc}
*/
public function get_email_template()
{
return 'mention';
}
/**
* Get email template variables
*
* @return array
*/
* {@inheritDoc}
*/
public function get_email_template_variables()
{
$user_data = $this->user_loader->get_user($this->get_data('poster_id'));
@ -162,9 +148,9 @@ class mention extends \phpbb\notification\type\post
/**
* Set the helper service used to retrieve mentioned used
*
* @param \phpbb\textformatter\s9e\mention_helper $helper
* @param mention_helper $helper
*/
public function set_helper(\phpbb\textformatter\s9e\mention_helper $helper)
public function set_helper(mention_helper $helper): void
{
$this->helper = $helper;
}

View file

@ -92,10 +92,12 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
$request->expects($this->any())
->method('is_ajax')
->willReturn(true)
;
->willReturn(true);
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
->disableOriginalConstructor()
->getMock();
$user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
$user_loader = new \phpbb\user_loader($avatar_helper, $db, $phpbb_root_path, $phpEx, USERS_TABLE);
// Container
$phpbb_container = new ContainerBuilder();
@ -113,6 +115,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
$phpbb_container->set('request', $request);
$phpbb_container->set('group_helper', new \phpbb\group\helper(
$this->getMockBuilder('\phpbb\auth\auth')->disableOriginalConstructor()->getMock(),
$avatar_helper,
$cache,
$config,
new \phpbb\language\language(
@ -142,6 +145,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
);
$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
$phpbb_container->setParameter('core.php_ext', $phpEx);
$phpbb_container->addCompilerPass(new phpbb\di\pass\markpublic_pass());
$phpbb_container->compile();
// Mention Sources
@ -172,7 +176,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 7,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 1,
@ -205,7 +209,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 6,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 1,
@ -216,7 +220,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 5,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 1,
@ -227,7 +231,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 2,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -238,7 +242,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 3,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -249,7 +253,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 4,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -260,7 +264,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 5,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -271,7 +275,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 6,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -282,7 +286,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 7,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -293,7 +297,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 8,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -304,7 +308,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 9,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -331,7 +335,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 7,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 1,
@ -364,7 +368,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 6,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 1,
@ -375,7 +379,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 5,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 1,
@ -386,7 +390,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 4,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 1,
@ -397,7 +401,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 3,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 5,
@ -408,7 +412,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 2,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -419,7 +423,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 3,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -430,7 +434,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 4,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -441,7 +445,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 5,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -452,7 +456,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 6,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -463,7 +467,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 7,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -474,7 +478,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 8,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -485,7 +489,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 9,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -512,7 +516,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 6,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 1,
@ -523,7 +527,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 5,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 1,
@ -534,7 +538,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 5,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -545,7 +549,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 6,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -556,7 +560,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 8,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -567,7 +571,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 9,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -578,7 +582,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 10,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -589,7 +593,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 11,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -605,7 +609,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 8,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -616,7 +620,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 9,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -627,7 +631,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 10,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -638,7 +642,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 11,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,
@ -653,7 +657,7 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
'id' => 9,
'avatar' => [
'type' => 'user',
'img' => '',
'img' => [],
],
'rank' => '',
'priority' => 0,