use OCP\Files\Folder;
use OCP\IURLGenerator;
use OCP\IUser;
+use OCP\Files\IRootFolder;
class Share20OCS {
/** @var IRequest */
private $request;
- /** @var Folder */
- private $userFolder;
+ /** @var IRootFolder */
+ private $rootFolder;
/** @var IUrlGenerator */
private $urlGenerator;
IGroupManager $groupManager,
IUserManager $userManager,
IRequest $request,
- Folder $userFolder,
+ IRootFolder $rootFolder,
IURLGenerator $urlGenerator,
IUser $currentUser
) {
$this->userManager = $userManager;
$this->groupManager = $groupManager;
$this->request = $request;
- $this->userFolder = $userFolder;
+ $this->rootFolder = $rootFolder;
$this->urlGenerator = $urlGenerator;
$this->currentUser = $currentUser;
}
];
$path = $share->getPath();
- $result['path'] = $this->userFolder->getRelativePath($path->getPath());
+ $result['path'] = $this->rootFolder->getUserFolder($share->getShareOwner()->getUID())->getRelativePath($path->getPath());
if ($path instanceOf \OCP\Files\Folder) {
$result['item_type'] = 'folder';
} else {
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IRequest;
-use OCP\Files\Folder;
use OCP\IURLGenerator;
use OCP\IUser;
+use OCP\Files\IRootFolder;
class Share20OCSTest extends \Test\TestCase {
/** @var IRequest */
private $request;
- /** @var Folder */
- private $userFolder;
+ /** @var IRootFolder */
+ private $rootFolder;
/** @var IURLGenerator */
private $urlGenerator;
$this->groupManager = $this->getMock('OCP\IGroupManager');
$this->userManager = $this->getMock('OCP\IUserManager');
$this->request = $this->getMock('OCP\IRequest');
- $this->userFolder = $this->getMock('OCP\Files\Folder');
+ $this->rootFolder = $this->getMock('OCP\Files\IRootFolder');
$this->urlGenerator = $this->getMock('OCP\IURLGenerator');
$this->currentUser = $this->getMock('OCP\IUser');
$this->groupManager,
$this->userManager,
$this->request,
- $this->userFolder,
+ $this->rootFolder,
$this->urlGenerator,
$this->currentUser
);
$this->assertEquals($expected, $this->ocs->getShare(42));
}
- public function createShare($id, $shareType, $sharedWith, $sharedBy, $path, $permissions,
+ public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions,
$shareTime, $expiration, $parent, $target, $mail_send, $token=null,
$password=null) {
$share = $this->getMock('OC\Share20\IShare');
$share->method('getShareType')->willReturn($shareType);
$share->method('getSharedWith')->willReturn($sharedWith);
$share->method('getSharedBy')->willReturn($sharedBy);
+ $share->method('getShareOwner')->willReturn($shareOwner);
$share->method('getPath')->willReturn($path);
$share->method('getPermissions')->willReturn($permissions);
$share->method('getShareTime')->willReturn($shareTime);
$folder->method('getParent')->willReturn($parentFolder);
// File shared with user
- $share = $this->createShare(100,
- \OCP\Share::SHARE_TYPE_USER,
- $user,
- $owner,
- $file,
- 4,
- 5,
- null,
- 6,
- 'target',
- 0);
+ $share = $this->createShare(
+ 100,
+ \OCP\Share::SHARE_TYPE_USER,
+ $user,
+ $owner,
+ $owner,
+ $file,
+ 4,
+ 5,
+ null,
+ 6,
+ 'target',
+ 0
+ );
$expected = [
'id' => 100,
'share_type' => \OCP\Share::SHARE_TYPE_USER,
$data[] = [$share, $expected];
// Folder shared with group
- $share = $this->createShare(101,
- \OCP\Share::SHARE_TYPE_GROUP,
- $group,
- $owner,
- $folder,
- 4,
- 5,
- null,
- 6,
- 'target',
- 0);
+ $share = $this->createShare(
+ 101,
+ \OCP\Share::SHARE_TYPE_GROUP,
+ $group,
+ $owner,
+ $owner,
+ $folder,
+ 4,
+ 5,
+ null,
+ 6,
+ 'target',
+ 0
+ );
$expected = [
'id' => 101,
'share_type' => \OCP\Share::SHARE_TYPE_GROUP,
// File shared by link with Expire
$expire = \DateTime::createFromFormat('Y-m-d h:i:s', '2000-01-02 01:02:03');
- $share = $this->createShare(101,
- \OCP\Share::SHARE_TYPE_LINK,
- null,
- $owner,
- $folder,
- 4,
- 5,
- $expire,
- 6,
- 'target',
- 0,
- 'token',
- 'password');
+ $share = $this->createShare(
+ 101,
+ \OCP\Share::SHARE_TYPE_LINK,
+ null,
+ $owner,
+ $owner,
+ $folder,
+ 4,
+ 5,
+ $expire,
+ 6,
+ 'target',
+ 0,
+ 'token',
+ 'password'
+ );
$expected = [
'id' => 101,
'share_type' => \OCP\Share::SHARE_TYPE_LINK,
$this->groupManager,
$this->userManager,
$this->request,
- $this->userFolder,
+ $this->rootFolder,
$this->urlGenerator,
$this->currentUser
])->setMethods(['canAccessShare'])
->with($share->getId())
->willReturn($share);
- $this->userFolder
+ $userFolder = $this->getMock('OCP\Files\Folder');
+ $userFolder
->method('getRelativePath')
->will($this->returnArgument(0));
+ $this->rootFolder->method('getUserFolder')
+ ->with($share->getShareOwner()->getUID())
+ ->willReturn($userFolder);
+
$this->urlGenerator
->method('linkToRouteAbsolute')
->willReturn('url');