Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use OCA\DAV\Connector\Sabre\Directory;
use OCP\Files\ForbiddenException;
use OCP\Files\Mount\IMountPoint;
use Test\Traits\UserTrait;

class TestViewDirectory extends \OC\Files\View {
private $updatables;
Expand Down Expand Up @@ -73,6 +74,8 @@ public function getRelativePath($path) {
*/
class DirectoryTest extends \Test\TestCase {

use UserTrait;

/** @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject */
private $view;
/** @var \OC\Files\FileInfo | \PHPUnit\Framework\MockObject\MockObject */
Expand Down Expand Up @@ -274,6 +277,8 @@ public function testGetChildThrowInvalidPath() {
}

public function testGetQuotaInfoUnlimited() {
self::createUser('user', 'password');
self::loginAsUser('user');
$mountPoint = $this->createMock(IMountPoint::class);
$storage = $this->getMockBuilder(Quota::class)
->disableOriginalConstructor()
Expand All @@ -288,6 +293,10 @@ public function testGetQuotaInfoUnlimited() {
'\OC\Files\Storage\Wrapper\Quota' => false,
]);

$storage->expects($this->once())
->method('getOwner')
->willReturn('user');

$storage->expects($this->never())
->method('getQuota');

Expand All @@ -311,6 +320,8 @@ public function testGetQuotaInfoUnlimited() {
}

public function testGetQuotaInfoSpecific() {
self::createUser('user', 'password');
self::loginAsUser('user');
$mountPoint = $this->createMock(IMountPoint::class);
$storage = $this->getMockBuilder(Quota::class)
->disableOriginalConstructor()
Expand All @@ -325,6 +336,10 @@ public function testGetQuotaInfoSpecific() {
['\OC\Files\Storage\Wrapper\Quota', true],
]);

$storage->expects($this->once())
->method('getOwner')
->willReturn('user');

$storage->expects($this->once())
->method('getQuota')
->willReturn(1000);
Expand Down
6 changes: 3 additions & 3 deletions lib/private/legacy/OC_Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,10 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin

$ownerId = $storage->getOwner($path);
$ownerDisplayName = '';
$owner = \OC::$server->getUserManager()->get($ownerId);
if ($owner) {
$ownerDisplayName = $owner->getDisplayName();
if ($ownerId) {
$ownerDisplayName = \OC::$server->getUserManager()->getDisplayName($ownerId) ?? '';
}

if (substr_count($mount->getMountPoint(), '/') < 3) {
$mountPoint = '';
} else {
Expand Down