mirror of https://github.com/nextcloud/bookmarks
test(FolderController): Test moving and editing read-only shares
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
be0af16d1e
commit
b337f38bab
|
@ -236,7 +236,7 @@ class TreeMapper extends QBMapper {
|
|||
* @psalm-return array<array-key, Entity>
|
||||
*/
|
||||
public function findChildren(string $type, int $folderId): array {
|
||||
$qb = $this->getChildrenQuery[$type];
|
||||
$qb = $this->selectFromType($type, [], $this->getChildrenQuery[$type]);
|
||||
$qb->setParameter('parent_folder', $folderId);
|
||||
return $this->findEntitiesWithType($qb, $type);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ use OCA\Bookmarks\Events\MoveEvent;
|
|||
use OCA\Bookmarks\Exception\UnsupportedOperation;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use OCP\AppFramework\IAppContainer;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\ICache;
|
||||
use OCP\ICacheFactory;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class TreeCacheManager implements IEventListener {
|
||||
|
@ -61,10 +61,7 @@ class TreeCacheManager implements IEventListener {
|
|||
* @var ICache[]
|
||||
*/
|
||||
private $caches = [];
|
||||
/**
|
||||
* @var IAppContainer
|
||||
*/
|
||||
private $appContainer;
|
||||
private ContainerInterface $appContainer;
|
||||
/**
|
||||
* @var \OCA\Bookmarks\Db\TagMapper
|
||||
*/
|
||||
|
@ -78,10 +75,10 @@ class TreeCacheManager implements IEventListener {
|
|||
* @param ShareMapper $shareMapper
|
||||
* @param SharedFolderMapper $sharedFolderMapper
|
||||
* @param ICacheFactory $cacheFactory
|
||||
* @param IAppContainer $appContainer
|
||||
* @param ContainerInterface $appContainer
|
||||
* @param \OCA\Bookmarks\Db\TagMapper $tagMapper
|
||||
*/
|
||||
public function __construct(FolderMapper $folderMapper, BookmarkMapper $bookmarkMapper, ShareMapper $shareMapper, SharedFolderMapper $sharedFolderMapper, ICacheFactory $cacheFactory, IAppContainer $appContainer, \OCA\Bookmarks\Db\TagMapper $tagMapper) {
|
||||
public function __construct(FolderMapper $folderMapper, BookmarkMapper $bookmarkMapper, ShareMapper $shareMapper, SharedFolderMapper $sharedFolderMapper, ICacheFactory $cacheFactory, ContainerInterface $appContainer, \OCA\Bookmarks\Db\TagMapper $tagMapper) {
|
||||
$this->folderMapper = $folderMapper;
|
||||
$this->bookmarkMapper = $bookmarkMapper;
|
||||
$this->shareMapper = $shareMapper;
|
||||
|
|
|
@ -27,9 +27,13 @@ use OCA\Bookmarks\Service\FolderService;
|
|||
use OCA\Bookmarks\Service\TreeCacheManager;
|
||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\ICache;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
@ -41,129 +45,43 @@ class FolderControllerTest extends TestCase {
|
|||
private $userId;
|
||||
|
||||
private $otherUser;
|
||||
/**
|
||||
* @var \OCP\IRequest
|
||||
*/
|
||||
private $request;
|
||||
/**
|
||||
* @var \OC\User\Manager
|
||||
*/
|
||||
private $userManager;
|
||||
/**
|
||||
* @var BookmarkController
|
||||
*/
|
||||
private $controller;
|
||||
/**
|
||||
* @var BookmarkController
|
||||
*/
|
||||
private $publicController;
|
||||
|
||||
/**
|
||||
* @var BookmarkMapper
|
||||
*/
|
||||
private $bookmarkMapper;
|
||||
|
||||
/**
|
||||
* @var FolderMapper
|
||||
*/
|
||||
private $folderMapper;
|
||||
|
||||
/**
|
||||
* @var TagMapper
|
||||
*/
|
||||
private $tagMapper;
|
||||
|
||||
/**
|
||||
* @var PublicFolderMapper
|
||||
*/
|
||||
private $publicFolderMapper;
|
||||
|
||||
/**
|
||||
* @var IGroupManager
|
||||
*/
|
||||
private $groupManager;
|
||||
private \OCP\IRequest $request;
|
||||
private \OC\User\Manager $userManager;
|
||||
private FoldersController $controller;
|
||||
private FoldersController $publicController;
|
||||
private BookmarkMapper $bookmarkMapper;
|
||||
private FolderMapper $folderMapper;
|
||||
private TagMapper $tagMapper;
|
||||
private PublicFolderMapper $publicFolderMapper;
|
||||
private IGroupManager $groupManager;
|
||||
|
||||
private $bookmark1Id;
|
||||
private $bookmark2Id;
|
||||
|
||||
/**
|
||||
* @var PublicFolder
|
||||
*/
|
||||
private $publicFolder;
|
||||
private PublicFolder $publicFolder;
|
||||
|
||||
/**
|
||||
* @var Folder
|
||||
*/
|
||||
private $folder1;
|
||||
private Folder $folder1;
|
||||
|
||||
/**
|
||||
* @var Folder
|
||||
*/
|
||||
private $folder2;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $otherUserId;
|
||||
/**
|
||||
* @var \stdClass
|
||||
*/
|
||||
private $shareMapper;
|
||||
/**
|
||||
* @var SharedFolderMapper
|
||||
*/
|
||||
private $sharedFolderMapper;
|
||||
/**
|
||||
* @var \OCP\IGroup
|
||||
*/
|
||||
private $group;
|
||||
/**
|
||||
* @var \stdClass
|
||||
*/
|
||||
private $treeMapper;
|
||||
/**
|
||||
* @var FoldersController
|
||||
*/
|
||||
private $otherController;
|
||||
/**
|
||||
* @var FoldersController
|
||||
*/
|
||||
private $public;
|
||||
/**
|
||||
* @var FoldersController
|
||||
*/
|
||||
private $noauth;
|
||||
/**
|
||||
* @var \PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
private $publicRequest;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $user;
|
||||
/**
|
||||
* @var Share
|
||||
*/
|
||||
private $share;
|
||||
/**
|
||||
* @var SharedFolder
|
||||
*/
|
||||
private $sharedFolder;
|
||||
/**
|
||||
* @var TreeCacheManager
|
||||
*/
|
||||
private $hashManager;
|
||||
/**
|
||||
* @var Authorizer
|
||||
*/
|
||||
private $authorizer;
|
||||
/**
|
||||
* @var FolderService
|
||||
*/
|
||||
private $folders;
|
||||
/**
|
||||
* @var BookmarkService
|
||||
*/
|
||||
private $bookmarks;
|
||||
private Folder $folder2;
|
||||
|
||||
private string $otherUserId;
|
||||
|
||||
private ShareMapper $shareMapper;
|
||||
private SharedFolderMapper $sharedFolderMapper;
|
||||
|
||||
private \OCP\IGroup $group;
|
||||
private TreeMapper $treeMapper;
|
||||
private FoldersController $otherController;
|
||||
private FoldersController $public;
|
||||
private FoldersController $noauth;
|
||||
private IRequest $publicRequest;
|
||||
private string $user;
|
||||
private Share $share;
|
||||
private SharedFolder $sharedFolder;
|
||||
private TreeCacheManager $hashManager;
|
||||
private Authorizer $authorizer;
|
||||
private FolderService $folders;
|
||||
private BookmarkService $bookmarks;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -171,6 +89,7 @@ class FolderControllerTest extends TestCase {
|
|||
*/
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->cleanUp();
|
||||
|
||||
$this->user = 'test';
|
||||
$this->otherUser = 'otheruser';
|
||||
|
@ -195,7 +114,23 @@ class FolderControllerTest extends TestCase {
|
|||
$this->publicFolderMapper = OC::$server->get(PublicFolderMapper::class);
|
||||
$this->shareMapper = OC::$server->get(ShareMapper::class);
|
||||
$this->sharedFolderMapper = OC::$server->get(SharedFolderMapper::class);
|
||||
$this->hashManager = OC::$server->get(TreeCacheManager::class);
|
||||
$this->emptyCache = $emptyCache = $this->createMock(ICache::class);
|
||||
$emptyCache->method('get')->willReturn(null);
|
||||
$emptyCache->method('set')->willReturn(true);
|
||||
$emptyCache->method('hasKey')->willReturn(false);
|
||||
$emptyCache->method('remove')->willReturn(true);
|
||||
$emptyCache->method('clear')->willReturn(true);
|
||||
$this->cacheFactory = $this->createMock(ICacheFactory::class);
|
||||
$this->cacheFactory->method('createLocal')->willReturn($this->emptyCache);
|
||||
$this->hashManager = new TreeCacheManager(
|
||||
$this->folderMapper,
|
||||
$this->bookmarkMapper,
|
||||
$this->shareMapper,
|
||||
$this->sharedFolderMapper,
|
||||
$this->cacheFactory,
|
||||
OC::$server->get(ContainerInterface::class),
|
||||
$this->tagMapper,
|
||||
);
|
||||
$this->folders = OC::$server->get(FolderService::class);
|
||||
$this->bookmarks = OC::$server->get(BookmarkService::class);
|
||||
$this->groupManager = OC::$server->get(IGroupManager::class);
|
||||
|
@ -204,7 +139,17 @@ class FolderControllerTest extends TestCase {
|
|||
$this->group = $this->groupManager->createGroup('foobar');
|
||||
$this->group->addUser($this->userManager->get($this->otherUser));
|
||||
|
||||
$this->authorizer = OC::$server->get(Authorizer::class);
|
||||
$userSession = $this->createMock(IUserSession::class);
|
||||
$userSession->method('isLoggedIn')->willReturn(false);
|
||||
$userSession->method('getUser')->willReturn(null);
|
||||
$this->authorizer = new Authorizer(
|
||||
$this->folderMapper,
|
||||
$this->bookmarkMapper,
|
||||
$this->publicFolderMapper,
|
||||
$this->shareMapper,
|
||||
$this->treeMapper,
|
||||
$userSession,
|
||||
);
|
||||
|
||||
$this->controller = new FoldersController('bookmarks', $this->request, $this->folderMapper, $this->publicFolderMapper, $this->shareMapper, $this->treeMapper, $this->authorizer, $this->hashManager, $this->folders, $this->bookmarks, $loggerInterface, $this->userManager);
|
||||
$this->otherController = new FoldersController('bookmarks', $this->request, $this->folderMapper, $this->publicFolderMapper, $this->shareMapper, $this->treeMapper, $this->authorizer, $this->hashManager, $this->folders, $this->bookmarks, $loggerInterface, $this->userManager);
|
||||
|
@ -290,7 +235,7 @@ class FolderControllerTest extends TestCase {
|
|||
*/
|
||||
public function setupSharedFolder() {
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
$this->folders->createShare($this->folder1->getId(), $this->otherUser, \OCP\Share\IShare::TYPE_USER, true, false);
|
||||
$this->share = $this->folders->createShare($this->folder1->getId(), $this->otherUser, \OCP\Share\IShare::TYPE_USER, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -301,7 +246,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testRead(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
$output = $this->controller->getFolder($this->folder1->getId());
|
||||
|
@ -316,9 +261,18 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws UserLimitExceededError
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
* @dataProvider hashCacheDataProvider
|
||||
*/
|
||||
public function testHash(): void {
|
||||
$this->cleanUp();
|
||||
public function testHash(bool $useCache): void {
|
||||
if ($useCache) {
|
||||
$this->cacheFactory = $this->createMock(ICacheFactory::class);
|
||||
$this->cacheFactory->method('createLocal')
|
||||
->willReturnCallback(fn ()
|
||||
=> OC::$server->get(ICacheFactory::class)
|
||||
->createLocal(time() . '' . random_int(0, 1000000))
|
||||
);
|
||||
}
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
|
||||
|
@ -367,7 +321,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testCreate(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
$output = $this->controller->addFolder('foo', $this->folder1->getId());
|
||||
|
@ -387,7 +341,6 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testEdit(): void {
|
||||
$this->cleanUp();
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
// Edit title
|
||||
|
@ -424,11 +377,14 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws UserLimitExceededError
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
* @dataProvider shareCanWriteProvider
|
||||
*/
|
||||
public function testSharedEdit(): void {
|
||||
$this->cleanUp();
|
||||
public function testSharedEdit(bool $canWrite): void {
|
||||
$this->setupBookmarks();
|
||||
$this->setupSharedFolder();
|
||||
$this->share->setCanWrite($canWrite);
|
||||
$this->shareMapper->update($this->share);
|
||||
|
||||
$this->authorizer->setUserId($this->otherUserId);
|
||||
// Edit title
|
||||
$output = $this->otherController->editFolder($this->folder1->getId(), 'blabla');
|
||||
|
@ -467,7 +423,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testDelete(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
$output = $this->controller->deleteFolder($this->folder1->getId());
|
||||
|
@ -485,7 +441,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testGetFullHierarchy(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
// Using -1 here because this is the controller
|
||||
|
@ -509,7 +465,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testSetFullHierarchy(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
$output = $this->controller->setFolderChildrenOrder($this->folder1->getId(), [
|
||||
|
@ -537,7 +493,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testGetFolderHierarchy(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
$output = $this->controller->getFolders(-1, -1);
|
||||
|
@ -560,7 +516,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testReadNoauthFail(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupPublicFolder();
|
||||
$this->authorizer->setUserId(null);
|
||||
|
@ -576,7 +532,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testCreateNoauthFail(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupPublicFolder();
|
||||
$this->authorizer->setUserId(null);
|
||||
|
@ -593,7 +549,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testEditNoauthFail(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupPublicFolder();
|
||||
$this->authorizer->setUserId(null);
|
||||
|
@ -610,7 +566,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testDeleteNoauthFail(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupPublicFolder();
|
||||
$this->authorizer->setUserId(null);
|
||||
|
@ -626,7 +582,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testGetFullHierarchyNoauthFail(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId(null);
|
||||
$this->authorizer->setToken(null);
|
||||
|
@ -641,7 +597,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testSetFullHierarchyNoauthFail(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId(null);
|
||||
$this->authorizer->setToken(null);
|
||||
|
@ -659,7 +615,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testGetFolderHierarchyNoauth(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId(null);
|
||||
$this->authorizer->setToken(null);
|
||||
|
@ -675,7 +631,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testReadPublic(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupPublicFolder();
|
||||
$this->authorizer->setUserId(null);
|
||||
|
@ -693,9 +649,9 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testReadPublicFail(): void {
|
||||
$this->cleanUp();
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId(null);
|
||||
$this->authorizer->setToken('foobar');
|
||||
$output = $this->public->getFolder($this->folder1->getId());
|
||||
$data = $output->getData();
|
||||
$this->assertEquals('error', $data['status'], var_export($data, true));
|
||||
|
@ -708,7 +664,6 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testCreatePublicFail(): void {
|
||||
$this->cleanUp();
|
||||
$this->setupBookmarks();
|
||||
$this->setupPublicFolder();
|
||||
$this->authorizer->setUserId(null);
|
||||
|
@ -725,7 +680,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testEditPublicFail(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupPublicFolder();
|
||||
$this->authorizer->setUserId(null);
|
||||
|
@ -746,7 +701,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testDeletePublicFail(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupPublicFolder();
|
||||
$this->authorizer->setUserId(null);
|
||||
|
@ -765,7 +720,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testGetFullHierarchyPublic(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupPublicFolder();
|
||||
$this->authorizer->setUserId(null);
|
||||
|
@ -786,8 +741,8 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testSetFullHierarchyPublicFail(): void {
|
||||
$this->cleanUp();
|
||||
$this->setupBookmarks();
|
||||
$this->setupPublicFolder();
|
||||
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
$originalOutput = $this->controller->getFolderChildrenOrder(-1, -1)->getData();
|
||||
|
@ -814,7 +769,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testGetFolderHierarchyPublic(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupPublicFolder();
|
||||
$this->authorizer->setUserId(null);
|
||||
|
@ -833,7 +788,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testReadShared(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupSharedFolder();
|
||||
$this->authorizer->setUserId($this->otherUserId);
|
||||
|
@ -851,7 +806,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testReadSharedFail(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->otherUserId);
|
||||
$output = $this->otherController->getFolder($this->folder1->getId());
|
||||
|
@ -867,7 +822,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testCreateShared(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupSharedFolder();
|
||||
$this->authorizer->setUserId($this->otherUserId);
|
||||
|
@ -887,7 +842,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testEditShared(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupSharedFolder();
|
||||
$this->authorizer->setUserId($this->otherUserId);
|
||||
|
@ -908,7 +863,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testDeleteShared(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupSharedFolder();
|
||||
$this->authorizer->setUserId($this->otherUserId);
|
||||
|
@ -927,7 +882,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testGetFullHierarchyShared(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupSharedFolder();
|
||||
$this->authorizer->setUserId($this->otherUserId);
|
||||
|
@ -948,7 +903,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testSetFullHierarchyShared(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupSharedFolder();
|
||||
|
||||
|
@ -980,7 +935,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function testGetFolderHierarchyShared(): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->setupSharedFolder();
|
||||
$this->authorizer->setUserId($this->otherUserId);
|
||||
|
@ -1004,7 +959,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @dataProvider shareDataProvider
|
||||
*/
|
||||
public function testCreateShare($participant, $type, $canWrite, $canShare): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserid($this->userId);
|
||||
$res = $this->controller->createShare($this->folder1->getId(), $participant, $type, $canWrite, $canShare);
|
||||
|
@ -1025,7 +980,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @depends testCreateShare
|
||||
*/
|
||||
public function testGetShare($participant, $type, $canWrite, $canShare): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
$res = $this->controller->createShare($this->folder1->getId(), $participant, $type, $canWrite, $canShare);
|
||||
|
@ -1053,7 +1008,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @depends testCreateShare
|
||||
*/
|
||||
public function testEditShare($participant, $type, $canWrite, $canShare): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
$res = $this->controller->createShare($this->folder1->getId(), $participant, $type, $canWrite, $canShare);
|
||||
|
@ -1089,7 +1044,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @depends testCreateShare
|
||||
*/
|
||||
public function testDeleteShareOwner($participant, $type, $canWrite, $canShare): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
$res = $this->controller->createShare($this->folder1->getId(), $participant, $type, $canWrite, $canShare);
|
||||
|
@ -1116,7 +1071,7 @@ class FolderControllerTest extends TestCase {
|
|||
* @depends testCreateShare
|
||||
*/
|
||||
public function testDeleteShareSharee($participant, $type, $canWrite, $canShare): void {
|
||||
$this->cleanUp();
|
||||
|
||||
$this->setupBookmarks();
|
||||
$this->authorizer->setUserId($this->userId);
|
||||
$res = $this->controller->createShare($this->folder1->getId(), $participant, $type, $canWrite, $canShare);
|
||||
|
@ -1145,4 +1100,18 @@ class FolderControllerTest extends TestCase {
|
|||
['foobar', \OCP\Share\IShare::TYPE_GROUP, true, true],
|
||||
];
|
||||
}
|
||||
|
||||
public function hashCacheDataProvider(): array {
|
||||
return [
|
||||
[false],
|
||||
[true],
|
||||
];
|
||||
}
|
||||
|
||||
public function shareCanWriteProvider(): array {
|
||||
return [
|
||||
[false],
|
||||
[true],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ use PHPUnit\Framework;
|
|||
|
||||
class TestCase extends Framework\TestCase {
|
||||
protected function cleanUp(): void {
|
||||
parent::setUp();
|
||||
$query = \OC::$server->get(IDBConnection::class)->prepare('DELETE FROM *PREFIX*bookmarks');
|
||||
$query->execute();
|
||||
$query = \OC::$server->get(IDBConnection::class)->prepare('DELETE FROM *PREFIX*bookmarks_tags');
|
||||
|
|
Loading…
Reference in New Issue