2014-07-22 21:33:22 +00:00
|
|
|
<?php
|
|
|
|
|
2021-02-25 02:46:03 +00:00
|
|
|
use MediaWiki\User\UserGroupManager;
|
|
|
|
|
2018-01-24 00:31:53 +00:00
|
|
|
/**
|
2019-10-23 10:23:09 +00:00
|
|
|
* @covers \EchoAttributeManager
|
2018-01-24 00:31:53 +00:00
|
|
|
*/
|
2021-02-25 01:55:40 +00:00
|
|
|
class EchoAttributeManagerTest extends MediaWikiUnitTestCase {
|
2014-07-22 21:33:22 +00:00
|
|
|
|
2014-07-29 23:54:00 +00:00
|
|
|
public static function getUserLocatorsProvider() {
|
2016-12-05 18:51:07 +00:00
|
|
|
return [
|
|
|
|
[
|
2014-07-29 23:54:00 +00:00
|
|
|
'No errors when requesting unknown type',
|
|
|
|
// expected result
|
2016-12-05 18:51:07 +00:00
|
|
|
[],
|
2014-07-29 23:54:00 +00:00
|
|
|
// event type
|
|
|
|
'foo',
|
|
|
|
// notification configuration
|
2016-12-05 18:51:07 +00:00
|
|
|
[],
|
|
|
|
],
|
2014-07-29 23:54:00 +00:00
|
|
|
|
2016-12-05 18:51:07 +00:00
|
|
|
[
|
2014-07-29 23:54:00 +00:00
|
|
|
'Returns selected notification configuration',
|
|
|
|
// expected result
|
2016-12-05 18:51:07 +00:00
|
|
|
[ 'woot!' ],
|
2014-07-29 23:54:00 +00:00
|
|
|
// event type
|
|
|
|
'magic',
|
|
|
|
// notification configuration
|
2016-12-05 18:51:07 +00:00
|
|
|
[
|
|
|
|
'foo' => [
|
|
|
|
EchoAttributeManager::ATTR_LOCATORS => [ 'frown' ],
|
|
|
|
],
|
|
|
|
'magic' => [
|
|
|
|
EchoAttributeManager::ATTR_LOCATORS => [ 'woot!' ],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
2014-07-29 23:54:00 +00:00
|
|
|
|
2016-12-05 18:51:07 +00:00
|
|
|
[
|
2014-07-29 23:54:00 +00:00
|
|
|
'Accepts user-locators as string and returns array',
|
|
|
|
// expected result
|
2016-12-05 18:51:07 +00:00
|
|
|
[ 'sagen' ],
|
2014-07-29 23:54:00 +00:00
|
|
|
// event type
|
|
|
|
'challah',
|
|
|
|
// notification configuration
|
2016-12-05 18:51:07 +00:00
|
|
|
[
|
|
|
|
'challah' => [
|
Allow certain users to be excluded
Right now, if certain users should be excluded, that would have
to be part of the user-locators already. This is annoying because
it's hard to write "generic" user locators when you want to exclude
just a couple of people in certain cases.
In Flow, for example, we have user-locators for users watching a
board or topic. We don't want to send the notification to people
that have also been mentioned in that post (they'll get a separate
notification). We could build that exception into those
user-locators, but then we couldn't re-use them in other places...
This basically means we couldn't use EchoUserLocator::locateUsersWatchingTitle,
we would have to roll our own that also excludes mentioned users.
Instead, this lets you add 'user-filters' (that functionality
actually exists already, but is not currently exposed), which
lists users to not send the notification to, even though they could
be in a user-locator.
Bug: T125428
Change-Id: Ifa0e2d3283f57624af4c5ec264f9f66223508e83
2016-02-02 13:16:39 +00:00
|
|
|
EchoAttributeManager::ATTR_LOCATORS => 'sagen',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
2014-07-29 23:54:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider getUserLocatorsProvider
|
|
|
|
*/
|
2015-10-01 13:48:52 +00:00
|
|
|
public function testGetUserLocators( $message, $expect, $type, $notifications ) {
|
2021-02-25 02:46:03 +00:00
|
|
|
$manager = new EchoAttributeManager( $notifications, [], [], [], $this->mockUserGroupManager() );
|
2014-07-29 23:54:00 +00:00
|
|
|
|
Allow certain users to be excluded
Right now, if certain users should be excluded, that would have
to be part of the user-locators already. This is annoying because
it's hard to write "generic" user locators when you want to exclude
just a couple of people in certain cases.
In Flow, for example, we have user-locators for users watching a
board or topic. We don't want to send the notification to people
that have also been mentioned in that post (they'll get a separate
notification). We could build that exception into those
user-locators, but then we couldn't re-use them in other places...
This basically means we couldn't use EchoUserLocator::locateUsersWatchingTitle,
we would have to roll our own that also excludes mentioned users.
Instead, this lets you add 'user-filters' (that functionality
actually exists already, but is not currently exposed), which
lists users to not send the notification to, even though they could
be in a user-locator.
Bug: T125428
Change-Id: Ifa0e2d3283f57624af4c5ec264f9f66223508e83
2016-02-02 13:16:39 +00:00
|
|
|
$result = $manager->getUserCallable( $type, EchoAttributeManager::ATTR_LOCATORS );
|
2014-07-29 23:54:00 +00:00
|
|
|
$this->assertEquals( $expect, $result, $message );
|
|
|
|
}
|
|
|
|
|
2014-07-22 21:33:22 +00:00
|
|
|
public function testGetCategoryEligibility() {
|
2016-12-05 18:51:07 +00:00
|
|
|
$notif = [
|
|
|
|
'event_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'category' => 'category_one'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
];
|
|
|
|
$category = [
|
|
|
|
'category_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => 10
|
2016-12-05 18:51:07 +00:00
|
|
|
]
|
|
|
|
];
|
2021-02-25 02:46:03 +00:00
|
|
|
$manager = new EchoAttributeManager( $notif, $category, [], [], $this->mockUserGroupManager() );
|
2014-07-22 21:33:22 +00:00
|
|
|
$this->assertTrue( $manager->getCategoryEligibility( $this->mockUser(), 'category_one' ) );
|
2016-12-05 18:51:07 +00:00
|
|
|
$category = [
|
|
|
|
'category_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => 10,
|
2016-12-05 18:51:07 +00:00
|
|
|
'usergroups' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'sysop'
|
2016-12-05 18:51:07 +00:00
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
2021-02-25 02:46:03 +00:00
|
|
|
$manager = new EchoAttributeManager( $notif, $category, [], [], $this->mockUserGroupManager() );
|
2014-07-22 21:33:22 +00:00
|
|
|
$this->assertFalse( $manager->getCategoryEligibility( $this->mockUser(), 'category_one' ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetNotificationCategory() {
|
2016-12-05 18:51:07 +00:00
|
|
|
$notif = [
|
|
|
|
'event_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'category' => 'category_one'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
];
|
|
|
|
$category = [
|
|
|
|
'category_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => 10
|
2016-12-05 18:51:07 +00:00
|
|
|
]
|
|
|
|
];
|
2021-02-25 02:46:03 +00:00
|
|
|
$manager = new EchoAttributeManager( $notif, $category, [], [], $this->mockUserGroupManager() );
|
2014-07-22 21:33:22 +00:00
|
|
|
$this->assertEquals( $manager->getNotificationCategory( 'event_one' ), 'category_one' );
|
|
|
|
|
2021-02-25 02:46:03 +00:00
|
|
|
$manager = new EchoAttributeManager( $notif, [], [], [], $this->mockUserGroupManager() );
|
2014-07-22 21:33:22 +00:00
|
|
|
$this->assertEquals( $manager->getNotificationCategory( 'event_one' ), 'other' );
|
|
|
|
|
2016-12-05 18:51:07 +00:00
|
|
|
$notif = [
|
|
|
|
'event_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'category' => 'category_two'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
];
|
|
|
|
$category = [
|
|
|
|
'category_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => 10
|
2016-12-05 18:51:07 +00:00
|
|
|
]
|
|
|
|
];
|
2021-02-25 02:46:03 +00:00
|
|
|
$manager = new EchoAttributeManager( $notif, $category, [], [], $this->mockUserGroupManager() );
|
2014-07-22 21:33:22 +00:00
|
|
|
$this->assertEquals( $manager->getNotificationCategory( 'event_one' ), 'other' );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetCategoryPriority() {
|
2016-12-05 18:51:07 +00:00
|
|
|
$notif = [
|
|
|
|
'event_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'category' => 'category_two'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
];
|
|
|
|
$category = [
|
|
|
|
'category_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => 6
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'category_two' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => 100
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'category_three' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => -10
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'category_four' => []
|
|
|
|
];
|
2021-02-25 02:46:03 +00:00
|
|
|
$manager = new EchoAttributeManager( $notif, $category, [], [], $this->mockUserGroupManager() );
|
2019-10-23 10:28:30 +00:00
|
|
|
$this->assertSame( 6, $manager->getCategoryPriority( 'category_one' ) );
|
|
|
|
$this->assertSame( 10, $manager->getCategoryPriority( 'category_two' ) );
|
|
|
|
$this->assertSame( 10, $manager->getCategoryPriority( 'category_three' ) );
|
|
|
|
$this->assertSame( 10, $manager->getCategoryPriority( 'category_four' ) );
|
2014-07-22 21:33:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetNotificationPriority() {
|
2016-12-05 18:51:07 +00:00
|
|
|
$notif = [
|
|
|
|
'event_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'category' => 'category_one'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_two' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'category' => 'category_two'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_three' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'category' => 'category_three'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_four' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'category' => 'category_four'
|
2016-12-05 18:51:07 +00:00
|
|
|
]
|
|
|
|
];
|
|
|
|
$category = [
|
|
|
|
'category_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => 6
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'category_two' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => 100
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'category_three' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => -10
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'category_four' => []
|
|
|
|
];
|
2021-02-25 02:46:03 +00:00
|
|
|
$manager = new EchoAttributeManager( $notif, $category, [], [], $this->mockUserGroupManager() );
|
2019-10-23 10:28:30 +00:00
|
|
|
$this->assertSame( 6, $manager->getNotificationPriority( 'event_one' ) );
|
|
|
|
$this->assertSame( 10, $manager->getNotificationPriority( 'event_two' ) );
|
|
|
|
$this->assertSame( 10, $manager->getNotificationPriority( 'event_three' ) );
|
|
|
|
$this->assertSame( 10, $manager->getNotificationPriority( 'event_four' ) );
|
2014-07-22 21:33:22 +00:00
|
|
|
}
|
|
|
|
|
2016-04-27 21:43:00 +00:00
|
|
|
public static function getEventsForSectionProvider() {
|
2016-12-05 18:51:07 +00:00
|
|
|
$notifications = [
|
|
|
|
'event_one' => [
|
2014-08-05 21:50:54 +00:00
|
|
|
'category' => 'category_one',
|
2016-04-27 21:43:00 +00:00
|
|
|
'section' => 'message',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_two' => [
|
2016-04-27 21:43:00 +00:00
|
|
|
'category' => 'category_two',
|
|
|
|
'section' => 'invalid',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_three' => [
|
2014-08-05 21:50:54 +00:00
|
|
|
'category' => 'category_three',
|
2016-04-27 21:43:00 +00:00
|
|
|
'section' => 'message',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_four' => [
|
2016-04-27 21:43:00 +00:00
|
|
|
'category' => 'category_four',
|
|
|
|
// Omitted
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_five' => [
|
2016-04-27 21:43:00 +00:00
|
|
|
'category' => 'category_two',
|
|
|
|
'section' => 'alert',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
];
|
2014-08-05 21:50:54 +00:00
|
|
|
|
2016-12-05 18:51:07 +00:00
|
|
|
return [
|
|
|
|
[
|
|
|
|
[ 'event_one', 'event_three' ],
|
2016-04-27 21:43:00 +00:00
|
|
|
$notifications,
|
|
|
|
'message',
|
|
|
|
'Messages',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
2016-04-27 21:43:00 +00:00
|
|
|
|
2016-12-05 18:51:07 +00:00
|
|
|
[
|
|
|
|
[ 'event_two', 'event_four', 'event_five' ],
|
2016-04-27 21:43:00 +00:00
|
|
|
$notifications,
|
|
|
|
'alert',
|
|
|
|
'Alerts',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
];
|
2016-04-27 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider getEventsForSectionProvider
|
|
|
|
*/
|
|
|
|
public function testGetEventsForSection( $expected, $notificationTypes, $section, $message ) {
|
2021-02-25 02:46:03 +00:00
|
|
|
$am = new EchoAttributeManager( $notificationTypes, [], [], [], $this->mockUserGroupManager() );
|
2016-04-27 21:43:00 +00:00
|
|
|
$actual = $am->getEventsForSection( $section );
|
|
|
|
$this->assertEquals( $expected, $actual, $message );
|
2014-08-05 21:50:54 +00:00
|
|
|
}
|
|
|
|
|
2014-07-22 21:33:22 +00:00
|
|
|
public function testGetUserEnabledEvents() {
|
2016-12-05 18:51:07 +00:00
|
|
|
$notif = [
|
|
|
|
'event_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'category' => 'category_one'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_two' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'category' => 'category_two'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_three' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'category' => 'category_three'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
2019-04-12 22:34:28 +00:00
|
|
|
'event_four' => [
|
|
|
|
'category' => 'category_four'
|
|
|
|
]
|
2016-12-05 18:51:07 +00:00
|
|
|
];
|
|
|
|
$category = [
|
|
|
|
'category_one' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => 10,
|
2016-12-05 18:51:07 +00:00
|
|
|
'usergroups' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'sysop'
|
2016-12-05 18:51:07 +00:00
|
|
|
]
|
|
|
|
],
|
|
|
|
'category_two' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => 10,
|
2016-12-05 18:51:07 +00:00
|
|
|
'usergroups' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'echo_group'
|
2016-12-05 18:51:07 +00:00
|
|
|
]
|
|
|
|
],
|
|
|
|
'category_three' => [
|
2014-07-22 21:33:22 +00:00
|
|
|
'priority' => 10,
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
2019-04-12 22:34:28 +00:00
|
|
|
'category_four' => [
|
|
|
|
'priority' => 10,
|
|
|
|
]
|
2016-12-05 18:51:07 +00:00
|
|
|
];
|
2019-04-12 22:34:28 +00:00
|
|
|
$defaultNotifyTypeAvailability = [
|
|
|
|
'web' => true,
|
|
|
|
'email' => true,
|
|
|
|
];
|
|
|
|
$notifyTypeAvailabilityByCategory = [
|
|
|
|
'category_three' => [
|
|
|
|
'web' => false,
|
|
|
|
'email' => true,
|
|
|
|
]
|
|
|
|
];
|
2020-06-27 10:05:03 +00:00
|
|
|
$manager = new EchoAttributeManager(
|
|
|
|
$notif,
|
|
|
|
$category,
|
|
|
|
$defaultNotifyTypeAvailability,
|
2021-02-25 02:46:03 +00:00
|
|
|
$notifyTypeAvailabilityByCategory,
|
|
|
|
$this->mockUserGroupManager()
|
2020-06-27 10:05:03 +00:00
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
[ 'event_two', 'event_four' ],
|
|
|
|
$manager->getUserEnabledEvents( $this->mockUser(), 'web' )
|
|
|
|
);
|
2014-07-22 21:33:22 +00:00
|
|
|
}
|
|
|
|
|
2014-08-05 21:50:54 +00:00
|
|
|
public function testGetUserEnabledEventsbySections() {
|
2016-12-05 18:51:07 +00:00
|
|
|
$notif = [
|
|
|
|
'event_one' => [
|
2014-08-05 21:50:54 +00:00
|
|
|
'category' => 'category_one'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_two' => [
|
2014-08-05 21:50:54 +00:00
|
|
|
'category' => 'category_two',
|
|
|
|
'section' => 'message'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_three' => [
|
2014-08-05 21:50:54 +00:00
|
|
|
'category' => 'category_three',
|
|
|
|
'section' => 'alert'
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_four' => [
|
2014-08-05 21:50:54 +00:00
|
|
|
'category' => 'category_three',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
2019-04-12 22:34:28 +00:00
|
|
|
'event_five' => [
|
|
|
|
'category' => 'category_five'
|
|
|
|
]
|
2016-12-05 18:51:07 +00:00
|
|
|
];
|
|
|
|
$category = [
|
|
|
|
'category_one' => [
|
2014-08-05 21:50:54 +00:00
|
|
|
'priority' => 10,
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'category_two' => [
|
2014-08-05 21:50:54 +00:00
|
|
|
'priority' => 10,
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'category_three' => [
|
2014-08-05 21:50:54 +00:00
|
|
|
'priority' => 10
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
2019-04-12 22:34:28 +00:00
|
|
|
'category_five' => [
|
|
|
|
'priority' => 10
|
|
|
|
]
|
2016-12-05 18:51:07 +00:00
|
|
|
];
|
2019-04-12 22:34:28 +00:00
|
|
|
$defaultNotifyTypeAvailability = [
|
|
|
|
'web' => true,
|
|
|
|
'email' => true,
|
|
|
|
];
|
|
|
|
$notifyTypeAvailabilityByCategory = [
|
|
|
|
'category_five' => [
|
|
|
|
'web' => false,
|
|
|
|
'email' => true,
|
|
|
|
]
|
|
|
|
];
|
2020-06-27 10:05:03 +00:00
|
|
|
$manager = new EchoAttributeManager(
|
|
|
|
$notif,
|
|
|
|
$category,
|
|
|
|
$defaultNotifyTypeAvailability,
|
2021-02-25 02:46:03 +00:00
|
|
|
$notifyTypeAvailabilityByCategory,
|
|
|
|
$this->mockUserGroupManager()
|
2020-06-27 10:05:03 +00:00
|
|
|
);
|
2016-12-05 18:51:07 +00:00
|
|
|
$expected = [ 'event_one', 'event_three', 'event_four' ];
|
2019-06-11 21:43:05 +00:00
|
|
|
$actual = $manager->getUserEnabledEventsbySections( $this->mockUser(), 'web', [ 'alert' ] );
|
2014-08-05 21:50:54 +00:00
|
|
|
sort( $expected );
|
|
|
|
sort( $actual );
|
2019-04-12 22:34:28 +00:00
|
|
|
$this->assertEquals( $expected, $actual );
|
2014-08-05 21:50:54 +00:00
|
|
|
|
2016-12-05 18:51:07 +00:00
|
|
|
$expected = [ 'event_two' ];
|
2019-06-11 21:43:05 +00:00
|
|
|
$actual = $manager->getUserEnabledEventsbySections( $this->mockUser(), 'web', [ 'message' ] );
|
2014-08-05 21:50:54 +00:00
|
|
|
sort( $expected );
|
|
|
|
sort( $actual );
|
2019-04-12 22:34:28 +00:00
|
|
|
$this->assertEquals( $expected, $actual );
|
2014-08-05 21:50:54 +00:00
|
|
|
|
2016-12-05 18:51:07 +00:00
|
|
|
$expected = [ 'event_one', 'event_two', 'event_three', 'event_four' ];
|
2019-06-11 21:43:05 +00:00
|
|
|
$actual = $manager->getUserEnabledEventsbySections( $this->mockUser(), 'web',
|
2018-08-25 10:51:14 +00:00
|
|
|
[ 'message', 'alert' ] );
|
2014-08-05 21:50:54 +00:00
|
|
|
sort( $expected );
|
|
|
|
sort( $actual );
|
2019-04-12 22:34:28 +00:00
|
|
|
$this->assertEquals( $expected, $actual );
|
2014-08-05 21:50:54 +00:00
|
|
|
}
|
|
|
|
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
public static function getEventsByCategoryProvider() {
|
2016-12-05 18:51:07 +00:00
|
|
|
return [
|
|
|
|
[
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'Mix of populated and empty categories handled appropriately',
|
2016-12-05 18:51:07 +00:00
|
|
|
[
|
|
|
|
'category_one' => [
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'event_two',
|
|
|
|
'event_five',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'category_two' => [
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'event_one',
|
|
|
|
'event_three',
|
|
|
|
'event_four',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'category_three' => [],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'category_one' => [],
|
|
|
|
'category_two' => [],
|
|
|
|
'category_three' => [],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_one' => [
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'category' => 'category_two',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_two' => [
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'category' => 'category_one',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_three' => [
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'category' => 'category_two',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_four' => [
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'category' => 'category_two',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
'event_five' => [
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'category' => 'category_one',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider getEventsByCategoryProvider
|
|
|
|
*/
|
2018-08-25 10:51:14 +00:00
|
|
|
public function testGetEventsByCategory(
|
|
|
|
$message,
|
|
|
|
$expectedMapping,
|
|
|
|
$categories,
|
|
|
|
$notifications
|
|
|
|
) {
|
2021-02-25 02:46:03 +00:00
|
|
|
$am = new EchoAttributeManager( $notifications, $categories, [], [], $this->mockUserGroupManager() );
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
$actualMapping = $am->getEventsByCategory();
|
|
|
|
$this->assertEquals( $expectedMapping, $actualMapping, $message );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function isNotifyTypeAvailableForCategoryProvider() {
|
2016-12-05 18:51:07 +00:00
|
|
|
return [
|
|
|
|
[
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'Fallback to default entirely',
|
|
|
|
true,
|
|
|
|
'category_one',
|
|
|
|
'web',
|
2016-12-05 18:51:07 +00:00
|
|
|
[ 'web' => true, 'email' => true ],
|
|
|
|
[]
|
|
|
|
],
|
|
|
|
[
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'Fallback to default for single type',
|
|
|
|
false,
|
|
|
|
'category_two',
|
|
|
|
'email',
|
2016-12-05 18:51:07 +00:00
|
|
|
[ 'web' => true, 'email' => false ],
|
|
|
|
[
|
|
|
|
'category_two' => [
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'web' => true,
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'Use override',
|
|
|
|
false,
|
|
|
|
'category_three',
|
|
|
|
'web',
|
2016-12-05 18:51:07 +00:00
|
|
|
[ 'web' => true, 'email' => true ],
|
|
|
|
[
|
|
|
|
'category_three' => [
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'web' => false,
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-01-14 05:09:42 +00:00
|
|
|
* @dataProvider isNotifyTypeAvailableForCategoryProvider
|
|
|
|
*/
|
2018-08-25 10:51:14 +00:00
|
|
|
public function testIsNotifyTypeAvailableForCategory(
|
|
|
|
$message,
|
|
|
|
$expected,
|
|
|
|
$categoryName,
|
|
|
|
$notifyType,
|
|
|
|
$defaultNotifyTypeAvailability,
|
|
|
|
$notifyTypeAvailabilityByCategory
|
|
|
|
) {
|
|
|
|
$am = new EchoAttributeManager( [], [], $defaultNotifyTypeAvailability,
|
2021-02-25 02:46:03 +00:00
|
|
|
$notifyTypeAvailabilityByCategory, $this->mockUserGroupManager() );
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
$actual = $am->isNotifyTypeAvailableForCategory( $categoryName, $notifyType );
|
|
|
|
$this->assertEquals( $expected, $actual, $message );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function isNotifyTypeDismissableForCategoryProvider() {
|
2016-12-05 18:51:07 +00:00
|
|
|
return [
|
|
|
|
[
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'Not dismissable because of all',
|
|
|
|
false,
|
2016-12-05 18:51:07 +00:00
|
|
|
[
|
|
|
|
'category_one' => [
|
|
|
|
'no-dismiss' => [ 'all' ],
|
|
|
|
]
|
|
|
|
],
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'category_one',
|
|
|
|
'web',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
[
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'Not dismissable because of specific notify type',
|
|
|
|
false,
|
2016-12-05 18:51:07 +00:00
|
|
|
[
|
|
|
|
'category_two' => [
|
|
|
|
'no-dismiss' => [ 'email' ],
|
|
|
|
]
|
|
|
|
],
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'category_two',
|
|
|
|
'email',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
[
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'Dismissable because of different affected notify type',
|
|
|
|
true,
|
2016-12-05 18:51:07 +00:00
|
|
|
[
|
|
|
|
'category_three' => [
|
|
|
|
'no-dismiss' => [ 'web' ],
|
|
|
|
]
|
|
|
|
],
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
'category_three',
|
|
|
|
'email',
|
2016-12-05 18:51:07 +00:00
|
|
|
],
|
|
|
|
];
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider isNotifyTypeDismissableForCategoryProvider
|
|
|
|
*/
|
2018-08-25 10:51:14 +00:00
|
|
|
public function testIsNotifyTypeDismissableForCategory(
|
|
|
|
$message,
|
|
|
|
$expected,
|
|
|
|
$categories,
|
|
|
|
$categoryName,
|
|
|
|
$notifyType
|
|
|
|
) {
|
2021-02-25 02:46:03 +00:00
|
|
|
$am = new EchoAttributeManager( [], $categories, [], [], $this->mockUserGroupManager() );
|
BREAKING CHANGE: Change $wgEchoDefaultNotificationTypes to be logical
Merge and deploy at the *same time* as:
* BounceHandler - I3c669945080d8e1f67880bd8a31af7f88a70904d
* mediawiki-config - I13817c139967ed9e230cfb0c87c5de66da793c96
Despite claiming to be about categories, $wgEchoDefaultNotificationTypes
was actually configuring both categories and types (which go inside
categories).
For example, 'thank-you-edit' is a type, but 'emailuser' is both
a category and a type (when used as a category, this has special
effects at Special:Preferences).
Since types and categories can and sometimes do have the same names,
this leaves no way to properly and clearly configure them. It also
makes it difficult to document what is going on (as required by
T132127).
Split into three variables:
$wgDefaultNotifyTypeAvailability - Applies unless overriden
$wgNotifyTypeAvailabilityByCategory - By category; this can be and is
displayed at Special:Preferences
$wgNotifyTypeAvailabilityByNotificationType - By type; this cannot
be displayed at Special:Preferences. To avoid confusing the user,
we introduce a restriction (which was previously followed in practice,
AFAICT) that types can only be overridden if the category is not
displayed in preferences.
Otherwise, it can look to the user like a category is on/off, but the
types within might have the opposite state.
Due to this configuration change, this is a breaking change, and needs
coordinated deployments.
This also lays the groundwork for T132127
Also change terminology to consistently use "notify type" for web/email.
It was mixing between that and output format (which unfortunately
sounds like the API format, e.g. 'model').
Bug: T132820
Bug: T132127
Change-Id: I09f39f5fc5f13f3253af9f7819bca81f1601da93
2016-04-19 02:54:15 +00:00
|
|
|
$actual = $am->isNotifyTypeDismissableForCategory( $categoryName, $notifyType );
|
|
|
|
$this->assertEquals( $expected, $actual, $message );
|
|
|
|
}
|
|
|
|
|
2014-07-22 21:33:22 +00:00
|
|
|
/**
|
|
|
|
* Mock object of User
|
2021-01-23 11:54:27 +00:00
|
|
|
* @return User
|
2014-07-22 21:33:22 +00:00
|
|
|
*/
|
|
|
|
protected function mockUser() {
|
2019-02-19 10:35:54 +00:00
|
|
|
$user = $this->getMockBuilder( User::class )
|
2014-07-22 21:33:22 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$user->expects( $this->any() )
|
|
|
|
->method( 'getID' )
|
|
|
|
->will( $this->returnValue( 1 ) );
|
|
|
|
$user->expects( $this->any() )
|
|
|
|
->method( 'getOption' )
|
|
|
|
->will( $this->returnValue( true ) );
|
2015-10-01 13:48:52 +00:00
|
|
|
|
2014-07-22 21:33:22 +00:00
|
|
|
return $user;
|
|
|
|
}
|
2021-02-25 02:46:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mock object of UserGroupManager
|
|
|
|
* @return UserGroupManager
|
|
|
|
*/
|
|
|
|
protected function mockUserGroupManager() {
|
|
|
|
$userGroupManager = $this->createNoOpMock( UserGroupManager::class, [ 'getUserGroups' ] );
|
|
|
|
$userGroupManager->method( 'getUserGroups' )
|
|
|
|
->willReturn( [ 'echo_group' ] );
|
|
|
|
|
|
|
|
return $userGroupManager;
|
|
|
|
}
|
2014-07-22 21:33:22 +00:00
|
|
|
}
|