2018-09-21 00:15:09 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-08 00:28:15 +00:00
|
|
|
use MediaWiki\Extension\Notifications\Hooks as EchoHooks;
|
|
|
|
|
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,
|
|
|
|
];
|
2022-08-22 22:31:10 +00:00
|
|
|
( new EchoHooks( new HashConfig ) )->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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|