[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; namespace phpbb\notification\type;
use phpbb\textformatter\s9e\mention_helper;
/** /**
* Post mentioning notifications class * Post mentioning notifications class
* This class handles notifying users when they have been mentioned in a post * 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; protected $helper;
/** /**
* Get notification type name * {@inheritDoc}
*
* @return string
*/ */
public function get_type() public function get_type()
{ {
@ -36,25 +36,20 @@ class mention extends \phpbb\notification\type\post
} }
/** /**
* Language key used to output the text * {@inheritDoc}
*
* @var string
*/ */
protected $language_key = 'NOTIFICATION_MENTION'; protected $language_key = 'NOTIFICATION_MENTION';
/** /**
* Notification option data (for outputting to the user) * {@inheritDoc}
*
* @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( public static $notification_option = [
'lang' => 'NOTIFICATION_TYPE_MENTION', 'lang' => 'NOTIFICATION_TYPE_MENTION',
'group' => 'NOTIFICATION_GROUP_POSTING', 'group' => 'NOTIFICATION_GROUP_POSTING',
); ];
/** /**
* Is available * {@inheritDoc}
*/ */
public function is_available() public function is_available()
{ {
@ -62,12 +57,7 @@ class mention extends \phpbb\notification\type\post
} }
/** /**
* Find the users who want to receive notifications * {@inheritDoc}
*
* @param array $post Data from submit_post
* @param array $options Options for finding users for notification
*
* @return array
*/ */
public function find_users_for_notification($post, $options = array()) public function find_users_for_notification($post, $options = array())
{ {
@ -128,7 +118,7 @@ class mention extends \phpbb\notification\type\post
} }
/** /**
* {inheritDoc} * {@inheritDoc}
*/ */
public function get_redirect_url() public function get_redirect_url()
{ {
@ -136,9 +126,7 @@ class mention extends \phpbb\notification\type\post
} }
/** /**
* Get email template * {@inheritDoc}
*
* @return string|bool
*/ */
public function get_email_template() public function get_email_template()
{ {
@ -146,9 +134,7 @@ class mention extends \phpbb\notification\type\post
} }
/** /**
* Get email template variables * {@inheritDoc}
*
* @return array
*/ */
public function get_email_template_variables() public function get_email_template_variables()
{ {
@ -162,9 +148,9 @@ class mention extends \phpbb\notification\type\post
/** /**
* Set the helper service used to retrieve mentioned used * 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; $this->helper = $helper;
} }

View file

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