2018-09-21 00:15:09 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-08 00:28:15 +00:00
|
|
|
use MediaWiki\Extension\Notifications\Hooks as EchoHooks;
|
2023-10-14 16:26:42 +00:00
|
|
|
use MediaWiki\Extension\Notifications\Services;
|
2022-04-08 00:28:15 +00:00
|
|
|
|
2021-10-11 22:42:10 +00:00
|
|
|
class EchoHooksTest extends MediaWikiIntegrationTestCase {
|
2018-09-21 00:15:09 +00:00
|
|
|
/**
|
2022-04-08 00:28:15 +00:00
|
|
|
* @covers \MediaWiki\Extension\Notifications\Hooks::onUserGetDefaultOptions()
|
2018-09-21 00:15:09 +00:00
|
|
|
*/
|
|
|
|
public function testOnUserGetDefaultOptions() {
|
|
|
|
$this->setMwGlobals( [
|
|
|
|
'wgEchoNotificationCategories' => [
|
|
|
|
'emailuser' => [
|
|
|
|
'priority' => 9,
|
|
|
|
'tooltip' => 'echo-pref-tooltip-emailuser',
|
|
|
|
],
|
|
|
|
'mention' => [
|
|
|
|
'priority' => 4,
|
|
|
|
'tooltip' => 'echo-pref-tooltip-mention',
|
|
|
|
],
|
|
|
|
'system' => [
|
|
|
|
'priority' => 9,
|
|
|
|
'no-dismiss' => [
|
|
|
|
'all'
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'some-custom-category' => [
|
|
|
|
'priority' => 9001,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'wgAllowHTMLEmail' => true,
|
|
|
|
] );
|
|
|
|
|
|
|
|
$defaults = [
|
|
|
|
'something' => 'unrelated',
|
|
|
|
// T174220: don't overwrite defaults set elsewhere
|
|
|
|
'echo-subscriptions-web-mention' => false,
|
|
|
|
];
|
2023-10-14 16:26:42 +00:00
|
|
|
$hooks = $this->getHooks();
|
|
|
|
$hooks->onUserGetDefaultOptions( $defaults );
|
2018-09-21 00:15:09 +00:00
|
|
|
self::assertEquals(
|
|
|
|
[
|
|
|
|
'something' => 'unrelated',
|
|
|
|
'echo-email-format' => 'html',
|
|
|
|
'echo-subscriptions-email-mention' => false,
|
|
|
|
'echo-subscriptions-web-mention' => false,
|
|
|
|
'echo-subscriptions-email-emailuser' => false,
|
|
|
|
'echo-subscriptions-web-emailuser' => true,
|
|
|
|
'echo-subscriptions-email-system' => true,
|
|
|
|
'echo-subscriptions-web-system' => true,
|
|
|
|
'echo-subscriptions-email-some-custom-category' => false,
|
|
|
|
'echo-subscriptions-web-some-custom-category' => true,
|
|
|
|
],
|
|
|
|
$defaults
|
|
|
|
);
|
|
|
|
}
|
2023-10-14 16:26:42 +00:00
|
|
|
|
|
|
|
public function getHooks() {
|
|
|
|
$services = $this->getServiceContainer();
|
|
|
|
$hooks = new EchoHooks(
|
|
|
|
$services->getAuthManager(),
|
|
|
|
$services->getCentralIdLookup(),
|
|
|
|
$services->getMainConfig(),
|
|
|
|
Services::wrap( $services )->getAttributeManager(),
|
|
|
|
$services->getHookContainer(),
|
|
|
|
$services->getContentLanguage(),
|
|
|
|
$services->getLinkRenderer(),
|
|
|
|
$services->getNamespaceInfo(),
|
|
|
|
$services->getPermissionManager(),
|
|
|
|
$services->getRevisionStore(),
|
2024-05-04 06:42:08 +00:00
|
|
|
$services->getStatsFactory(),
|
2023-10-14 16:26:42 +00:00
|
|
|
$services->getTalkPageNotificationManager(),
|
|
|
|
$services->getUserEditTracker(),
|
|
|
|
$services->getUserFactory(),
|
|
|
|
$services->getUserOptionsManager(),
|
|
|
|
);
|
|
|
|
return $hooks;
|
|
|
|
}
|
2018-09-21 00:15:09 +00:00
|
|
|
}
|