public function testGroupCreateChecksPathAlreadySharedWithDifferentGroup() { $share = new \OC\Share20\Share(); $sharedWith = $this->getMock('\\OCP\\IGroup'); $share->setSharedWith($sharedWith); $path = $this->getMock('\\OCP\\Files\\Node'); $share->setPath($path); $share2 = new \OC\Share20\Share(); $sharedWith2 = $this->getMock('\\OCP\\IGroup'); $share2->setSharedWith($sharedWith2); $this->defaultProvider->method('getSharesByPath')->with($path)->willReturn([$share2]); $this->invokePrivate($this->manager, 'groupCreateChecks', [$share]); }
public function testCreateLinkShare() { $share = new \OC\Share20\Share(); $sharedBy = $this->getMock('OCP\\IUser'); $sharedBy->method('getUID')->willReturn('sharedBy'); $shareOwner = $this->getMock('OCP\\IUser'); $shareOwner->method('getUID')->WillReturn('shareOwner'); $this->userManager->method('get')->will($this->returnValueMap([['sharedBy', $sharedBy], ['shareOwner', $shareOwner]])); $path = $this->getMock('\\OCP\\Files\\Folder'); $path->method('getId')->willReturn(100); $path->method('getOwner')->willReturn($shareOwner); $ownerFolder = $this->getMock('OCP\\Files\\Folder'); $userFolder = $this->getMock('OCP\\Files\\Folder'); $this->rootFolder->method('getUserFolder')->will($this->returnValueMap([['sharedBy', $userFolder], ['shareOwner', $ownerFolder]])); $userFolder->method('getById')->with(100)->willReturn([$path]); $ownerFolder->method('getById')->with(100)->willReturn([$path]); $share->setShareType(\OCP\Share::SHARE_TYPE_LINK); $share->setSharedBy($sharedBy); $share->setShareOwner($shareOwner); $share->setPath($path); $share->setPermissions(1); $share->setPassword('password'); $share->setToken('token'); $expireDate = new \DateTime(); $share->setExpirationDate($expireDate); $share->setTarget('/target'); $share2 = $this->provider->create($share); $this->assertNotNull($share2->getId()); $this->assertSame(\OCP\Share::SHARE_TYPE_LINK, $share2->getShareType()); $this->assertSame($sharedBy, $share2->getSharedBy()); $this->assertSame($shareOwner, $share2->getShareOwner()); $this->assertSame(1, $share2->getPermissions()); $this->assertSame('/target', $share2->getTarget()); $this->assertLessThanOrEqual(time(), $share2->getSharetime()); $this->assertSame($path, $share2->getPath()); $this->assertSame('password', $share2->getPassword()); $this->assertSame('token', $share2->getToken()); $this->assertEquals($expireDate, $share2->getExpirationDate()); }