Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Shliakhov <husband.sergey@gmail.com>2020-01-08 15:21:50 +0300
committerSergey Shliakhov <husband.sergey@gmail.com>2020-01-27 11:42:45 +0300
commitacc0df1d13a082e5531acf76047ff24c85230289 (patch)
tree43156444c5e8b39a569105ffc8fd0965bebee443 /tests/lib/Avatar
parentaa950ffc044e318ccd8885fe311f46e87277f517 (diff)
Change avatar placeholder from single letter to 2 letters
https://github.com/nextcloud/server/issues/18717 Signed-off-by: Sergey Shliakhov <husband.sergey@gmail.com>
Diffstat (limited to 'tests/lib/Avatar')
-rw-r--r--tests/lib/Avatar/UserAvatarTest.php58
1 files changed, 45 insertions, 13 deletions
diff --git a/tests/lib/Avatar/UserAvatarTest.php b/tests/lib/Avatar/UserAvatarTest.php
index ff6c63df2a8..43e325b0941 100644
--- a/tests/lib/Avatar/UserAvatarTest.php
+++ b/tests/lib/Avatar/UserAvatarTest.php
@@ -35,22 +35,20 @@ class UserAvatarTest extends \Test\TestCase {
parent::setUp();
$this->folder = $this->createMock(SimpleFolder::class);
- /** @var \OCP\IL10N | \PHPUnit_Framework_MockObject_MockObject $l */
- $l = $this->createMock(IL10N::class);
- $l->method('t')->will($this->returnArgument(0));
- $this->user = $this->createMock(User::class);
+ // abcdefghi is a convenient name that our algorithm convert to our nextcloud blue 0082c9
+ $this->user = $this->getUserWithDisplayName('abcdefghi');
$this->config = $this->createMock(IConfig::class);
- $this->avatar = new \OC\Avatar\UserAvatar(
- $this->folder,
- $l,
- $this->user,
- $this->createMock(ILogger::class),
- $this->config
- );
+ $this->avatar = $this->getUserAvatar($this->user);
+ }
- // abcdefghi is a convenient name that our algorithm convert to our nextcloud blue 0082c9
- $this->user->method('getDisplayName')->willReturn('abcdefghi');
+ public function avatarTextData() {
+ return [
+ ['', '?'],
+ ['matchish', 'M'],
+ ['Firstname Lastname', 'FL'],
+ ['Firstname Lastname Rest', 'FL'],
+ ];
}
public function testGetNoAvatar() {
@@ -239,6 +237,18 @@ class UserAvatarTest extends \Test\TestCase {
$this->assertEquals($avatar, $svg);
}
+
+ /**
+ * @dataProvider avatarTextData
+ */
+ public function testGetAvatarText($displayName, $expectedAvatarText) {
+ $user = $this->getUserWithDisplayName($displayName);
+ $avatar = $this->getUserAvatar($user);
+
+ $avatarText = $this->invokePrivate($avatar, 'getAvatarText');
+ $this->assertEquals($expectedAvatarText, $avatarText);
+ }
+
public function testHashToInt() {
$hashToInt = $this->invokePrivate($this->avatar, 'hashToInt', ['abcdef', 18]);
$this->assertTrue(gettype($hashToInt) === 'integer');
@@ -261,4 +271,26 @@ class UserAvatarTest extends \Test\TestCase {
$this->assertTrue(gettype($hashToInt) === 'integer');
}
+ private function getUserWithDisplayName($name)
+ {
+ $user = $this->createMock(User::class);
+ $user->method('getDisplayName')->willReturn($name);
+ return $user;
+ }
+
+ private function getUserAvatar($user)
+ {
+ /** @var \OCP\IL10N | \PHPUnit_Framework_MockObject_MockObject $l */
+ $l = $this->createMock(IL10N::class);
+ $l->method('t')->will($this->returnArgument(0));
+
+ return new \OC\Avatar\UserAvatar(
+ $this->folder,
+ $l,
+ $user,
+ $this->createMock(ILogger::class),
+ $this->config
+ );
+ }
+
}