Skip to content

Commit

Permalink
test: sharing
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Jun 11, 2024
1 parent 6ed0495 commit 0ef52d0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/ClassifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use OCA\Recognize\Service\QueueService;
use OCP\AppFramework\Services\IAppConfig;
use OCP\BackgroundJob\IJobList;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\SystemTag\ISystemTagObjectMapper;
Expand Down Expand Up @@ -391,6 +392,37 @@ public function testLandmarksPipeline() : void {
);
}

public function testSharing() : void {
$testFile = $this->userFolder->newFile('/jumpingjack.gif', file_get_contents(__DIR__.'/res/jumpingjack.gif'));

$userMountCache = \OCP\Server::get(IUserMountCache::class);
$userMountCache->clear();
$mountInfos = $userMountCache->getMountsForFileId($testFile->getId());
$users = array_map(static function (\OCP\Files\Config\ICachedMountInfo $mountInfo) {
return $mountInfo->getUser()->getUID();
}, $mountInfos);
self::assertEquals([self::TEST_USER1], $users);

$sharedFolder = $this->userFolder->newFolder('/shared/');
$share = $this->shareManager->newShare();
$share->setSharedBy(self::TEST_USER1);
$share->setSharedWith(self::TEST_USER2);
$share->setShareType(\OCP\Share\IShare::TYPE_USER);
$share->setNode($sharedFolder);
$share->setPermissions(\OCP\Constants::PERMISSION_ALL);
$this->shareManager->createShare($share);
$this->shareManager->acceptShare($share, self::TEST_USER2);

$testFile->move($sharedFolder->getPath().'/'.$testFile->getName());

$userMountCache->clear();
$mountInfos = $userMountCache->getMountsForFileId($testFile->getId());
$users = array_map(static function (\OCP\Files\Config\ICachedMountInfo $mountInfo) {
return $mountInfo->getUser()->getUID();
}, $mountInfos);
self::assertEquals([self::TEST_USER1, self::TEST_USER2], $users);
}

public function testFacesPipeline() : void {
// Upload FaceID files
$testFiles = [];
Expand Down

0 comments on commit 0ef52d0

Please sign in to comment.