Added some unit tests for avatar letter with UTF-8
This commit is contained in:
parent
02cf50de80
commit
679a22c718
|
|
@ -36,10 +36,10 @@ class UserHelper extends Base
|
|||
$initials = '';
|
||||
|
||||
foreach (explode(' ', $name, 2) as $string) {
|
||||
$initials .= mb_substr($string, 0, 1);
|
||||
$initials .= mb_substr($string, 0, 1, 'UTF-8');
|
||||
}
|
||||
|
||||
return mb_strtoupper($initials);
|
||||
return mb_strtoupper($initials, 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -174,7 +174,7 @@ class UserHelper extends Base
|
|||
if (isset($task['creator_id']) && $task['creator_id'] == $this->userSession->getId()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if ($this->userSession->isAdmin() || $this->getProjectUserRole($task['project_id']) === Role::PROJECT_MANAGER) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class UserHelperTest extends Base
|
|||
$this->assertEquals('CN', $helper->getInitials('chuck norris'));
|
||||
$this->assertEquals('CN', $helper->getInitials('chuck norris #2'));
|
||||
$this->assertEquals('A', $helper->getInitials('admin'));
|
||||
$this->assertEquals('Ü君', $helper->getInitials('Ü 君が代'));
|
||||
}
|
||||
|
||||
public function testGetRoleName()
|
||||
|
|
|
|||
|
|
@ -34,4 +34,12 @@ class LetterAvatarProviderTest extends Base
|
|||
$expected = '<div class="avatar-letter" style="background-color: rgb(134, 45, 132)" title="admin">A</div>';
|
||||
$this->assertEquals($expected, $provider->render($user, 48));
|
||||
}
|
||||
|
||||
public function testRenderWithUTF8()
|
||||
{
|
||||
$provider = new LetterAvatarProvider($this->container);
|
||||
$user = array('id' => 123, 'name' => 'ü', 'username' => 'admin', 'email' => '');
|
||||
$expected = '<div class="avatar-letter" style="background-color: rgb(62, 147, 31)" title="ü">Ü</div>';
|
||||
$this->assertEquals($expected, $provider->render($user, 48));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue