From 9d4ba1471dd8410e1597a18478dbb3b7789d4ec7 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 19 Mar 2016 11:17:58 -0400 Subject: Added letter based avatar provider --- .../units/User/Avatar/LetterAvatarProviderTest.php | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/units/User/Avatar/LetterAvatarProviderTest.php (limited to 'tests/units') 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 @@ +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 = '
KA
'; + $this->assertEquals($expected, $provider->render($user, 48)); + } + + public function testRenderWithUsername() + { + $provider = new LetterAvatarProvider($this->container); + $user = array('id' => 123, 'name' => '', 'username' => 'admin', 'email' => ''); + $expected = '
A
'; + $this->assertEquals($expected, $provider->render($user, 48)); + } +} -- cgit v1.2.3