aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-07-05 15:15:25 +0200
committerGitHub <noreply@github.com>2017-07-05 15:15:25 +0200
commit7d58bb7db513c2a488ce41efcd6833b9dfaa86da (patch)
tree3c9adb889eaf368e80c425f670ebbe148ebb3eec /tests/lib
parentefa52ec1113eeccbd3935a8c96ea23c47ca190ab (diff)
parentf2b8535c7e6ab070465933ccee558dcfbeb7e8bb (diff)
downloadnextcloud-server-7d58bb7db513c2a488ce41efcd6833b9dfaa86da.tar.gz
nextcloud-server-7d58bb7db513c2a488ce41efcd6833b9dfaa86da.zip
Merge pull request #5342 from nextcloud/userlist-used-space
show used space in user list
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Files/Config/UserMountCacheTest.php35
1 files changed, 33 insertions, 2 deletions
diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php
index f38bd3fcdc3..f455dc987af 100644
--- a/tests/lib/Files/Config/UserMountCacheTest.php
+++ b/tests/lib/Files/Config/UserMountCacheTest.php
@@ -13,6 +13,7 @@ use OC\Files\Mount\MountPoint;
use OC\Log;
use OC\User\Manager;
use OCP\Files\Config\ICachedMountInfo;
+use OC\Files\Storage\Storage;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUserManager;
@@ -310,7 +311,7 @@ class UserMountCacheTest extends TestCase {
});
}
- private function createCacheEntry($internalPath, $storageId) {
+ private function createCacheEntry($internalPath, $storageId, $size = 0) {
$internalPath = trim($internalPath, '/');
$inserted = $this->connection->insertIfNotExist('*PREFIX*filecache', [
'storage' => $storageId,
@@ -320,7 +321,7 @@ class UserMountCacheTest extends TestCase {
'name' => basename($internalPath),
'mimetype' => 0,
'mimepart' => 0,
- 'size' => 0,
+ 'size' => $size,
'storage_mtime' => 0,
'encrypted' => 0,
'unencrypted_size' => 0,
@@ -455,4 +456,34 @@ class UserMountCacheTest extends TestCase {
$cachedMounts = $this->cache->getMountsForFileId($rootId);
$this->assertEmpty($cachedMounts);
}
+
+ public function testGetUsedSpaceForUsers() {
+ $user1 = $this->userManager->get('u1');
+ $user2 = $this->userManager->get('u2');
+
+ /** @var Storage $storage1 */
+ list($storage1, $rootId) = $this->getStorage(2);
+ $folderId = $this->createCacheEntry('files', 2, 100);
+ $fileId = $this->createCacheEntry('files/foo', 2, 7);
+ $storage1->getCache()->put($folderId, ['size' => 100]);
+ $storage1->getCache()->update($fileId, ['size' => 70]);
+
+ $mount1 = $this->getMockBuilder(MountPoint::class)
+ ->setConstructorArgs([$storage1, '/u1/'])
+ ->setMethods(['getStorageRootId', 'getNumericStorageId'])
+ ->getMock();
+
+ $mount1->expects($this->any())
+ ->method('getStorageRootId')
+ ->will($this->returnValue($rootId));
+
+ $mount1->expects($this->any())
+ ->method('getNumericStorageId')
+ ->will($this->returnValue(2));
+
+ $this->cache->registerMounts($user1, [$mount1]);
+
+ $result = $this->cache->getUsedSpaceForUsers([$user1, $user2]);
+ $this->assertEquals(['u1' => 100], $result);
+ }
}