summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-02-15 20:49:07 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-02-16 09:18:38 +0100
commit47d28155a8c07a208bf30f16a03efc2843dec408 (patch)
treefdf14bcc7d2db6f7a4a7efa873fba7a91645ac34 /tests
parent907430a80812bbf5378a4c5d10de6ab7ddf6f8e4 (diff)
downloadnextcloud-server-47d28155a8c07a208bf30f16a03efc2843dec408.tar.gz
nextcloud-server-47d28155a8c07a208bf30f16a03efc2843dec408.zip
Do not copy skeleton on avatar access
Fixes #22119 Just try to get the folder of the user. If it is not there a NotFoundException will be thrown. Which will be handled by the avatar endpoint.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/avatarmanagertest.php51
1 files changed, 20 insertions, 31 deletions
diff --git a/tests/lib/avatarmanagertest.php b/tests/lib/avatarmanagertest.php
index cb9068c46a6..f5cdd99176d 100644
--- a/tests/lib/avatarmanagertest.php
+++ b/tests/lib/avatarmanagertest.php
@@ -19,30 +19,32 @@
*
*/
use OC\AvatarManager;
-use OCP\Files\IRootFolder;
-use OCP\IUserManager;
+use Test\Traits\UserTrait;
+use Test\Traits\MountProviderTrait;
+/**
+ * Class AvatarManagerTest
+ * @group DB
+ */
class AvatarManagerTest extends \Test\TestCase {
- /** @var IRootFolder */
- private $rootFolder;
+ use UserTrait;
+ use MountProviderTrait;
- /** @var AvatarManager */
+ /** @var AvatarManager */
private $avatarManager;
- /** @var IUserManager */
- private $userManager;
+ /** @var \OC\Files\Storage\Temporary */
+ private $storage;
public function setUp() {
parent::setUp();
- $this->rootFolder = $this->getMock('\OCP\Files\IRootFolder');
- $this->userManager = $this->getMock('\OCP\IUserManager');
- $l = $this->getMock('\OCP\IL10N');
- $l->method('t')->will($this->returnArgument(0));
- $this->avatarManager = new \OC\AvatarManager(
- $this->userManager,
- $this->rootFolder,
- $l);;
+ $this->createUser('valid-user', 'valid-user');
+
+ $this->storage = new \OC\Files\Storage\Temporary();
+ $this->registerMount('valid-user', $this->storage, '/valid-user/');
+
+ $this->avatarManager = \OC::$server->getAvatarManager();
}
/**
@@ -54,23 +56,10 @@ class AvatarManagerTest extends \Test\TestCase {
}
public function testGetAvatarValidUser() {
- $this->userManager->expects($this->once())
- ->method('get')
- ->with('validUser')
- ->willReturn(true);
-
- $folder = $this->getMock('\OCP\Files\Folder');
- $this->rootFolder->expects($this->once())
- ->method('getUserFolder')
- ->with('validUser')
- ->willReturn($folder);
-
- $folder->expects($this->once())
- ->method('getParent')
- ->will($this->returnSelf());
-
- $this->avatarManager->getAvatar('validUser');
+ $avatar = $this->avatarManager->getAvatar('valid-user');
+ $this->assertInstanceOf('\OCP\IAvatar', $avatar);
+ $this->assertFalse($this->storage->file_exists('files'));
}
}