Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: add test for leave share activity
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Aug 14, 2025
commit cccf42bf9eb1e7e00534197ca1eb6c8bdfe022ae
44 changes: 44 additions & 0 deletions tests/FilesHooksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1007,4 +1007,48 @@ public function testAddNotificationsForUser(string $user, string $subject, array

self::invokePrivate($this->filesHooks, 'addNotificationsForUser', [$user, $subject, $parameter, $fileId, $path, $isFile, $email, $notification, $type]);
}

public function testLeaveShare(): void {
$filesHooks = $this->getFilesHooks([
'addNotificationsForUser',
'shareNotificationForOriginalOwners',
], 'with');

$node = $this->getNodeMock(42, '/user/files/path');
$share = $this->createMock(IShare::class);
$share->method('getNode')
->willReturn($node);
$share->method('getTarget')
->willReturn('/target');
$share->method('getNodeType')
->willReturn('file');
$share->method('getSharedWith')
->willReturn('with');

$this->settings->expects($this->exactly(3))
->method('getUserSetting')
->willReturnMap([
['with', 'notification', Files_Sharing::TYPE_SHARED, true],
['with', 'email', Files_Sharing::TYPE_SHARED, true],
['with', 'setting', 'batchtime', 21],
]);

$filesHooks->expects($this->once())
->method('addNotificationsForUser')
->with(
'with',
'self_unshared',
[[42 => '/target'], 'with'],
42,
'/target',
true,
true,
21
);
$filesHooks->expects($this->once())
->method('shareNotificationForOriginalOwners')
->with('with', 'self_unshared_by', 'with', $node);

self::invokePrivate($filesHooks, 'unShareSelf', [$share]);
}
}
Loading