public function testCreateGroupShare() { $share = new \OC\Share20\Share(); $shareOwner = $this->getMock('\\OCP\\IUser'); $shareOwner->method('getUID')->willReturn('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_GROUP); $share->setSharedWith('sharedWith'); $share->setSharedBy('sharedBy'); $share->setShareOwner('shareOwner'); $share->setNode($path); $share->setPermissions(1); $share->setTarget('/target'); $share2 = $this->provider->create($share); $this->assertNotNull($share2->getId()); $this->assertSame('ocinternal:' . $share2->getId(), $share2->getFullId()); $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share2->getShareType()); $this->assertSame('sharedWith', $share2->getSharedWith()); $this->assertSame('sharedBy', $share2->getSharedBy()); $this->assertSame('shareOwner', $share2->getShareOwner()); $this->assertSame(1, $share2->getPermissions()); $this->assertSame('/target', $share2->getTarget()); $this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime()); $this->assertSame($path, $share2->getNode()); }
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]); }