1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<?php
require_once __DIR__.'/../../Base.php';
use Kanboard\User\Avatar\LetterAvatarProvider;
class LetterAvatarProviderTest extends Base
{
public function testGetBackgroundColor()
{
$provider = new LetterAvatarProvider($this->container);
$rgb = $provider->getBackgroundColor('Test');
$this->assertEquals(array(107, 83, 172), $rgb);
}
public function testIsActive()
{
$provider = new LetterAvatarProvider($this->container);
$this->assertTrue($provider->isActive(array()));
}
public function testRenderWithFullName()
{
$provider = new LetterAvatarProvider($this->container);
$user = array('id' => 123, 'name' => 'Kanboard Admin', 'username' => 'bob', 'email' => '');
$expected = '<div class="avatar-letter" style="background-color: rgb(131, 224, 108)" title="Kanboard Admin">KA</div>';
$this->assertEquals($expected, $provider->render($user, 48));
}
public function testRenderWithUsername()
{
$provider = new LetterAvatarProvider($this->container);
$user = array('id' => 123, 'name' => '', 'username' => 'admin', 'email' => '');
$expected = '<div class="avatar-letter" style="background-color: rgb(134, 45, 132)" title="admin">A</div>';
$this->assertEquals($expected, $provider->render($user, 48));
}
}
|