Skip to content

Commit

Permalink
refactor tests
Browse files Browse the repository at this point in the history
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
  • Loading branch information
SwikritiT committed Jan 11, 2024
1 parent 5f219b6 commit 0168438
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/Controller/FilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ private function compileFileInfo($fileId) {

$userFolder = $this->rootFolder->getUserFolder($this->user->getUID());
$files = $userFolder->getById($fileId);
$file = $files[0];
if (is_array($files) && count($files) > 0) {
$file = $files[0];
}
$mounts = $this->mountCollection->getMountCache()->getMountsForFileId($fileId);

if ($file !== null && is_array($mounts) && count($mounts) > 0) {
Expand Down
5 changes: 1 addition & 4 deletions tests/lib/Controller/FilesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ public function testGetFilesInfoFourIdsRequestedOneExistsOneInTrashOneNotExisiti
->willReturnOnConsecutiveCalls(
'files/logo.png',
'files_trashbin/files/welcome.txt.d1648724302',
[],
[]
'/anotherUser/files/logo.png'
);

$ownerMock = $this->getMockBuilder('\OCP\IUser')->getMock();
Expand Down Expand Up @@ -876,7 +875,6 @@ private function createFilesController(
* @param array<string> $onlyMethods
* @param MockObject $folderMock
* @param MockObject|null $mountCacheMock mock for Files that exist but cannot be accessed by this user
* @param bool $isAppEnabled
* @param MockObject|null $davUtilsMock
* @return FilesController|MockObject
*/
Expand Down Expand Up @@ -916,7 +914,6 @@ public function getFilesControllerMock(
$userSessionMock,
$mountProviderCollectionMock,
$this->createMock(IManager::class),
$appManagerMock,
$this->createMock(IDBConnection::class),
$this->createMock(ILogger::class),
$this->createMock(IUserManager::class),
Expand Down

0 comments on commit 0168438

Please sign in to comment.