| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\Notifications\Test; |
| 4 |
|
| 5 |
use MediaWiki\Extension\Notifications\Hooks as EchoHooks; |
| 6 |
use MediaWiki\Extension\Notifications\Services; |
| 7 |
use MediaWiki\MainConfigNames; |
| 8 |
use MediaWikiIntegrationTestCase; |
| 9 |
|
| 10 |
class EchoHooksTest extends MediaWikiIntegrationTestCase { |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
public function testOnUserGetDefaultOptions() { |
| 15 |
$this->overrideConfigValues( [ |
| 16 |
'EchoNotificationCategories' => [ |
| 17 |
'emailuser' => [ |
| 18 |
'priority' => 9, |
| 19 |
'tooltip' => 'echo-pref-tooltip-emailuser', |
| 20 |
], |
| 21 |
'mention' => [ |
| 22 |
'priority' => 4, |
| 23 |
'tooltip' => 'echo-pref-tooltip-mention', |
| 24 |
], |
| 25 |
'system' => [ |
| 26 |
'priority' => 9, |
| 27 |
'no-dismiss' => [ |
| 28 |
'all' |
| 29 |
], |
| 30 |
], |
| 31 |
'some-custom-category' => [ |
| 32 |
'priority' => 9001, |
| 33 |
], |
| 34 |
], |
| 35 |
MainConfigNames::AllowHTMLEmail => true, |
| 36 |
] ); |
| 37 |
|
| 38 |
$defaults = [ |
| 39 |
'something' => 'unrelated', |
| 40 |
|
| 41 |
'echo-subscriptions-web-mention' => false, |
| 42 |
]; |
| 43 |
$hooks = $this->getHooks(); |
| 44 |
$hooks->onUserGetDefaultOptions( $defaults ); |
| 45 |
self::assertEquals( |
| 46 |
[ |
| 47 |
'something' => 'unrelated', |
| 48 |
'echo-email-format' => 'html', |
| 49 |
'echo-subscriptions-email-mention' => false, |
| 50 |
'echo-subscriptions-web-mention' => false, |
| 51 |
'echo-subscriptions-email-emailuser' => false, |
| 52 |
'echo-subscriptions-web-emailuser' => true, |
| 53 |
'echo-subscriptions-email-system' => true, |
| 54 |
'echo-subscriptions-web-system' => true, |
| 55 |
'echo-subscriptions-email-some-custom-category' => false, |
| 56 |
'echo-subscriptions-web-some-custom-category' => true, |
| 57 |
], |
| 58 |
$defaults |
| 59 |
); |
| 60 |
} |
| 61 |
|
| 62 |
public function getHooks() { |
| 63 |
$services = $this->getServiceContainer(); |
| 64 |
$hooks = new EchoHooks( |
| 65 |
$services->getAuthManager(), |
| 66 |
$services->getCentralIdLookup(), |
| 67 |
$services->getMainConfig(), |
| 68 |
Services::wrap( $services )->getAttributeManager(), |
| 69 |
$services->getHookContainer(), |
| 70 |
$services->getContentLanguage(), |
| 71 |
$services->getLinkRenderer(), |
| 72 |
$services->getNamespaceInfo(), |
| 73 |
$services->getPermissionManager(), |
| 74 |
$services->getRevisionStore(), |
| 75 |
$services->getStatsFactory(), |
| 76 |
$services->getTalkPageNotificationManager(), |
| 77 |
$services->getUserEditTracker(), |
| 78 |
$services->getUserFactory(), |
| 79 |
$services->getUserOptionsManager(), |
| 80 |
); |
| 81 |
return $hooks; |
| 82 |
} |
| 83 |
} |