mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-12 09:26:05 +00:00
Merge "Use constant in EchoAttributeManager::getNotificationSection"
This commit is contained in:
commit
25439c471b
|
@ -358,12 +358,11 @@ class EchoAttributeManager {
|
|||
|
||||
/**
|
||||
* Get notification section for a notification type
|
||||
* @todo add a unit test case
|
||||
* @param string $notificationType
|
||||
* @return string
|
||||
*/
|
||||
public function getNotificationSection( $notificationType ) {
|
||||
return $this->notifications[$notificationType]['section'] ?? 'alert';
|
||||
return $this->notifications[$notificationType]['section'] ?? self::$DEFAULT_SECTION;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,13 @@ class EchoAttributeManagerTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserIdentity
|
||||
*/
|
||||
protected function getUser(): UserIdentity {
|
||||
return new UserIdentityValue( 1, 'ExampleUserName' );
|
||||
}
|
||||
|
||||
public static function getUserLocatorsProvider() {
|
||||
return [
|
||||
[
|
||||
|
@ -546,10 +553,28 @@ class EchoAttributeManagerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertEquals( $expected, $actual, $message );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserIdentity
|
||||
*/
|
||||
protected function getUser() {
|
||||
return new UserIdentityValue( 1, 'ExampleUserName' );
|
||||
public function getNotificationSectionProvider() {
|
||||
yield [ 'event_one', 'alert' ];
|
||||
yield [ 'event_two', 'message' ];
|
||||
yield [ 'event_three', 'alert' ];
|
||||
yield [ 'event_undefined', 'alert' ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getNotificationSectionProvider
|
||||
*/
|
||||
public function testGetNotificationSection( $type, $expected ) {
|
||||
$am = $this->getAttributeManager( [
|
||||
'event_one' => [
|
||||
'section' => 'alert',
|
||||
],
|
||||
'event_two' => [
|
||||
'section' => 'message',
|
||||
],
|
||||
'event_three' => [],
|
||||
] );
|
||||
$actual = $am->getNotificationSection( $type );
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue