diff options
author | provokateurin <kate@provokateurin.de> | 2024-10-22 13:19:18 +0200 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2024-11-25 10:27:31 +0100 |
commit | c378e7401703146dcbfaa2be78b2d68675fd6742 (patch) | |
tree | 87061a0da55b1dea92708a8c4763a52cd29f2bc5 /tests | |
parent | a978e0a806901588a008ac2b71d825aae7541322 (diff) | |
download | nextcloud-server-c378e7401703146dcbfaa2be78b2d68675fd6742.tar.gz nextcloud-server-c378e7401703146dcbfaa2be78b2d68675fd6742.zip |
feat(Share20\Manager): Return all shares on IShareOwnerlessMount
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Share20/ManagerTest.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index a4c1dd3803d..5a0ca230186 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -23,6 +23,7 @@ use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; use OCP\Files\Mount\IMountPoint; +use OCP\Files\Mount\IShareOwnerlessMount; use OCP\Files\Node; use OCP\Files\Storage\IStorage; use OCP\HintException; @@ -2895,6 +2896,31 @@ class ManagerTest extends \Test\TestCase { $this->assertSame($share, $shares[0]); } + public function testGetSharesByOwnerless(): void { + $mount = $this->createMock(IShareOwnerlessMount::class); + + $node = $this->createMock(Folder::class); + $node + ->expects($this->once()) + ->method('getMountPoint') + ->willReturn($mount); + + $share = $this->manager->newShare(); + $share->setNode($node); + $share->setShareType(IShare::TYPE_USER); + + $this->defaultProvider + ->expects($this->once()) + ->method('getSharesByPath') + ->with($this->equalTo($node)) + ->willReturn([$share]); + + $shares = $this->manager->getSharesBy('user', IShare::TYPE_USER, $node, true, 1, 1); + + $this->assertCount(1, $shares); + $this->assertSame($share, $shares[0]); + } + /** * Test to ensure we correctly remove expired link shares * @@ -4493,6 +4519,49 @@ class ManagerTest extends \Test\TestCase { $this->assertSame($expects, $result); } + public function testGetSharesInFolderOwnerless(): void { + $factory = new DummyFactory2($this->createMock(IServerContainer::class)); + + $manager = $this->createManager($factory); + + $factory->setProvider($this->defaultProvider); + $extraProvider = $this->createMock(IShareProvider::class); + $factory->setSecondProvider($extraProvider); + + $share1 = $this->createMock(IShare::class); + $share2 = $this->createMock(IShare::class); + + $mount = $this->createMock(IShareOwnerlessMount::class); + + $file = $this->createMock(File::class); + $file + ->method('getId') + ->willReturn(1); + + $folder = $this->createMock(Folder::class); + $folder + ->method('getMountPoint') + ->willReturn($mount); + $folder + ->method('getDirectoryListing') + ->willReturn([$file]); + + $this->defaultProvider + ->method('getSharesByPath') + ->with($file) + ->willReturn([$share1]); + + $extraProvider + ->method('getSharesByPath') + ->with($file) + ->willReturn([$share2]); + + $this->assertSame([ + 1 => [$share1, $share2], + ], $manager->getSharesInFolder('user', $folder)); + } + + public function testGetAccessList(): void { $factory = new DummyFactory2($this->createMock(IServerContainer::class)); |