summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-03-25 12:21:03 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-03-29 07:03:36 +0000
commitab22999eb9d7eb684e31d6e5618241eadfd7e370 (patch)
tree3f8f20371ddbec8e3dc6c4830604ee9a0f020051 /tests
parent2613826fccb9ad9e6571a07141391601b28d513f (diff)
downloadnextcloud-server-ab22999eb9d7eb684e31d6e5618241eadfd7e370.tar.gz
nextcloud-server-ab22999eb9d7eb684e31d6e5618241eadfd7e370.zip
Added PlaceholderAvatar with own cached images
When avatar scope is private, the PlaceholderAvatar is used to deliver a placeholder avatar based on the user's initials. This was implemented as a separate class for now to avoid messing with the existing UserAvatar implementation and its generated vs non-generated logic. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Avatar/AvatarManagerTest.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/lib/Avatar/AvatarManagerTest.php b/tests/lib/Avatar/AvatarManagerTest.php
index 0ce0e752569..1b06e786fb1 100644
--- a/tests/lib/Avatar/AvatarManagerTest.php
+++ b/tests/lib/Avatar/AvatarManagerTest.php
@@ -25,7 +25,7 @@
namespace Test\Avatar;
use OC\Avatar\AvatarManager;
-use OC\Avatar\GuestAvatar;
+use OC\Avatar\PlaceholderAvatar;
use OC\Avatar\UserAvatar;
use OC\User\Manager;
use OCP\Accounts\IAccount;
@@ -159,10 +159,13 @@ class AvatarManagerTest extends \Test\TestCase {
->method('get')
->with('valid-user')
->willReturn($user);
+
$folder = $this->createMock(ISimpleFolder::class);
$this->appData
- ->expects($this->never())
- ->method('getFolder');
+ ->expects($this->once())
+ ->method('getFolder')
+ ->with('valid-user')
+ ->willReturn($folder);
$account = $this->createMock(IAccount::class);
$this->accountManager->expects($this->once())
@@ -180,7 +183,7 @@ class AvatarManagerTest extends \Test\TestCase {
->method('getScope')
->willReturn(IAccountManager::SCOPE_PRIVATE);
- $expected = new GuestAvatar('valid-user', $this->createMock(ILogger::class));
+ $expected = new PlaceholderAvatar($folder, $user, $this->createMock(ILogger::class));
$this->assertEquals($expected, $this->avatarManager->getAvatar('valid-user'));
}
}