From dbee0fbaa4dcd1c3f8980fe6ae0e5d39d7f8188d Mon Sep 17 00:00:00 2001 From: provokateurin Date: Tue, 12 Nov 2024 14:59:35 +0100 Subject: [PATCH] wip --- tests/lib/Repair/RepairInvalidSharesTest.php | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php index dfcdce3801a9b..d28fcdd79c88b 100644 --- a/tests/lib/Repair/RepairInvalidSharesTest.php +++ b/tests/lib/Repair/RepairInvalidSharesTest.php @@ -7,11 +7,15 @@ namespace Test\Repair; +use OC\Files\Node\File; +use OC\Files\Node\Folder; use OC\Repair\RepairInvalidShares; +use OCP\Files\IRootFolder; use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Share\IShare; +use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; /** @@ -63,6 +67,7 @@ public function testSharesNonExistingParent(): void { 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('recipientuser1'), 'uid_owner' => $qb->expr()->literal('user1'), + 'uid_initiator' => $qb->expr()->literal('user1'), 'item_type' => $qb->expr()->literal('folder'), 'item_source' => $qb->expr()->literal(123), 'item_target' => $qb->expr()->literal('/123'), @@ -70,7 +75,6 @@ public function testSharesNonExistingParent(): void { 'file_target' => $qb->expr()->literal('/test'), 'permissions' => $qb->expr()->literal(1), 'stime' => $qb->expr()->literal(time()), - 'expiration' => $qb->expr()->literal('2015-09-25 00:00:00') ]; // valid share @@ -151,11 +155,27 @@ public function fileSharePermissionsProvider() { * @dataProvider fileSharePermissionsProvider */ public function testFileSharePermissions($itemType, $testPerms, $expectedPerms): void { + $file = $this->createMock(File::class); + + $folder = $this->createMock(Folder::class); + $folder + ->method('getFirstNodeById') + ->with(123) + ->willReturn($file); + + $this->rootFolder = $this->createMock(IRootFolder::class); + $this->rootFolder + ->method('getUserFolder') + ->with('user1') + ->willReturn($folder); + $this->overwriteService(IRootFolder::class, $this->rootFolder); + $qb = $this->connection->getQueryBuilder(); $qb->insert('share') ->values([ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK), 'uid_owner' => $qb->expr()->literal('user1'), + 'uid_initiator' => $qb->expr()->literal('user1'), 'item_type' => $qb->expr()->literal($itemType), 'item_source' => $qb->expr()->literal(123), 'item_target' => $qb->expr()->literal('/123'), @@ -185,5 +205,7 @@ public function testFileSharePermissions($itemType, $testPerms, $expectedPerms): $updatedShare = $results[0]; $this->assertEquals($expectedPerms, $updatedShare['permissions']); + + $this->restoreAllServices(); } }