use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\Files\File;
use OCP\Files\Folder;
+use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage;
use OCP\IConfig;
use OCP\IL10N;
$ocs = $this->mockFormatShare();
$node = $this->getMockBuilder(Folder::class)->getMock();
+ $node->method('getId')
+ ->willReturn(42);
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
$this->shareManager->method('getSharedWith')
->willReturn([]);
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$node]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $node->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$expected = new DataResponse([]);
$result = $ocs->updateShare(42, null, '', null, 'false', '', '', '', 'false');
$ocs = $this->mockFormatShare();
$folder = $this->getMockBuilder(Folder::class)->getMock();
+ $folder->method('getId')
+ ->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
$this->shareManager->method('getSharedWith')
->willReturn([]);
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$folder]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $folder->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$expected = new DataResponse([]);
$result = $ocs->updateShare(42, null, 'password', null, 'true', '2000-01-01', 'note', 'label', 'true');
$ocs = $this->mockFormatShare();
$folder = $this->getMockBuilder(Folder::class)->getMock();
+ $folder->method('getId')
+ ->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
})
)->will($this->returnArgument(0));
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$folder]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $folder->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$expected = new DataResponse([]);
$result = $ocs->updateShare(42, $permissions, $password, null, $publicUpload, $expireDate);
$date->setTime(0,0,0);
$node = $this->getMockBuilder(File::class)->getMock();
+ $node->method('getId')
+ ->willReturn(42);
+
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
})
)->will($this->returnArgument(0));
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$node]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $node->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $node->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$expected = new DataResponse([]);
$result = $ocs->updateShare(42, null, null, 'false', null, null, null, null, null);
$ocs = $this->mockFormatShare();
$node = $this->getMockBuilder(File::class)->getMock();
+ $node->method('getId')
+ ->willReturn(42);
+
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
})
)->will($this->returnArgument(0));
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$node]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $node->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$expected = new DataResponse([]);
$result = $ocs->updateShare(42, null, null, null, null, '2010-12-23', null, null, null);
$date = new \DateTime('2000-01-01');
$folder = $this->getMockBuilder(Folder::class)->getMock();
+ $folder->method('getId')
+ ->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
$this->shareManager->method('getSharedWith')
->willReturn([]);
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$folder]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $folder->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$expected = new DataResponse([]);
$result = $ocs->updateShare(42, null, null, null, 'true', null, null, null, null);
$date = new \DateTime('2000-01-01');
$folder = $this->getMockBuilder(Folder::class)->getMock();
+ $folder->method('getId')
+ ->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
$this->shareManager->method('getSharedWith')->willReturn([]);
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$folder]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $folder->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$expected = new DataResponse([]);
$result = $ocs->updateShare(42, 7, null, null, null, null, null, null, null);
$date = new \DateTime('2000-01-01');
$folder = $this->getMockBuilder(Folder::class)->getMock();
+ $folder->method('getId')
+ ->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
})
)->will($this->returnArgument(0));
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$folder]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $folder->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$this->shareManager->method('getSharedWith')->willReturn([]);
$expected = new DataResponse([]);
$ocs = $this->mockFormatShare();
$file = $this->getMockBuilder(File::class)->getMock();
+ $file->method('getId')
+ ->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
$this->shareManager->method('getSharedWith')->willReturn([]);
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$file]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $file->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$expected = new DataResponse([]);
$result = $ocs->updateShare(42, 31, null, null, null, null);
$ocs = $this->mockFormatShare();
$folder = $this->createMock(Folder::class);
+ $folder->method('getId')
+ ->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
$share
['currentUser', \OCP\Share::SHARE_TYPE_ROOM, $share->getNode(), -1, 0, []]
]));
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$folder]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $folder->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$this->shareManager->expects($this->never())->method('updateShare');
try {
$ocs = $this->mockFormatShare();
$folder = $this->createMock(Folder::class);
+ $folder->method('getId')
+ ->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
$share
['currentUser', \OCP\Share::SHARE_TYPE_ROOM, $share->getNode(), -1, 0, []]
]));
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$folder]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $folder->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$this->shareManager->expects($this->never())->method('updateShare');
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
$ocs = $this->mockFormatShare();
$folder = $this->createMock(Folder::class);
+ $folder->method('getId')
+ ->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
$share
}
));
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$folder]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $folder->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$this->shareManager->expects($this->any())
->method('getSharedWith')
->will($this->returnValueMap([
$ocs = $this->mockFormatShare();
$folder = $this->createMock(Folder::class);
+ $folder->method('getId')
+ ->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
$share
->with($share)
->willReturn($share);
+ $userFolder = $this->createMock(Folder::class);
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser)
+ ->willReturn($userFolder);
+
+ $userFolder->method('getById')
+ ->with(42)
+ ->willReturn([$folder]);
+
+ $mountPoint = $this->createMock(IMountPoint::class);
+ $folder->method('getMountPoint')
+ ->willReturn($mountPoint);
+ $mountPoint->method('getStorageRootId')
+ ->willReturn(42);
+
$result = $ocs->updateShare(42, 31);
$this->assertInstanceOf(DataResponse::class, $result);
}