summaryrefslogtreecommitdiff
path: root/tests/units/User
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/User')
-rw-r--r--tests/units/User/Avatar/LetterAvatarProviderTest.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/units/User/Avatar/LetterAvatarProviderTest.php b/tests/units/User/Avatar/LetterAvatarProviderTest.php
new file mode 100644
index 00000000..0c1bfc4b
--- /dev/null
+++ b/tests/units/User/Avatar/LetterAvatarProviderTest.php
@@ -0,0 +1,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(187, 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(210, 97, 45)" title="admin">A</div>';
+ $this->assertEquals($expected, $provider->render($user, 48));
+ }
+}