Extract function to get a person's initials to a dedicated ToAcronym function in \utils

This commit is contained in:
Molkobain
2021-04-05 21:05:46 +02:00
parent a67bff3959
commit 8b25679df8
4 changed files with 92 additions and 88 deletions

View File

@@ -249,60 +249,4 @@ class UserRightsTest extends ItopDataTestCase
return $aClassActionResult;
}
/**
* @dataProvider GetUserInitialsProvider
*
* @param string $sLogin
* @param string $sExceptedInitials
*
* @throws \OQLException
*/
public function testGetUserInitials(string $sLogin, string $sExceptedInitials)
{
$sTestedInitials = UserRights::GetUserInitials($sLogin);
$this->assertEquals($sTestedInitials, $sExceptedInitials, "Initials for '$sLogin' don't match. Got '$sTestedInitials', expected '$sExceptedInitials'.");
}
public function GetUserInitialsProvider()
{
return [
'One word, upper case letter' => [
'Carrie',
'C',
],
'One word, lower case letter' => [
'carrie',
'C',
],
'Application name' => [
'iTop',
'I',
],
'Several words, upper case letters' => [
'Carrie Ann Moss',
'CAM',
],
'Several words, mixed case letters' => [
'My name My name',
'MM',
],
'Several words, upper case letters, two first hyphened' => [
'Lily-Rose Depp',
'LRD',
],
'Several words, mixed case letters, two first hyphened' => [
'Lily-rose Depp',
'LD',
],
'Several words, upper case letetrs, two last hypened' => [
'Jada Pinkett-Smith',
'JPS',
],
'Several words, mixed case letters, two last hyphened' => [
'Jada Pinkett-smith',
'JP',
],
];
}
}