summaryrefslogtreecommitdiff
path: root/tests/units
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-03-19 11:17:58 -0400
committerFrederic Guillot <fred@kanboard.net>2016-03-19 11:17:58 -0400
commit9d4ba1471dd8410e1597a18478dbb3b7789d4ec7 (patch)
treeb8de40fa34954fd624816795d535bae1df7286c8 /tests/units
parentfa86542f90774d7a7d8f3e81ee35821ca25b7fd4 (diff)
Added letter based avatar provider
Diffstat (limited to 'tests/units')
-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));
+ }
+}