Merge "Use constant in EchoAttributeManager::getNotificationSection"

This commit is contained in:
jenkins-bot 2021-08-19 02:02:44 +00:00 committed by Gerrit Code Review
commit 25439c471b
2 changed files with 31 additions and 7 deletions

View file

@ -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;
}
/**

View file

@ -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 );
}
}