Skip to content
Merged
Show file tree
Hide file tree
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
fixing tests + avoid duplicate in getFormattedShares()
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl authored and rullzer committed Dec 3, 2019
commit f2c7ca45840d20a8b6c40937958f4e5a8953d0dd
11 changes: 7 additions & 4 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -759,15 +759,18 @@ private function getFormattedShares(

$shares = $this->getSharesFromNode($viewer, $node, $reShares);

$formatted = $miniFormatted = [];
$known = $formatted = $miniFormatted = [];
$resharingRight = false;
foreach ($shares as $share) {
if (in_array($share->getId(), $known) || $share->getSharedWith() === $this->currentUser) {
continue;
}

$known[] = $share->getId();
try {
/** @var IShare $share */
$format = $this->formatShare($share, $node);
if ($share->getSharedWith() !== $this->currentUser) {
$formatted[] = $format;
}
$formatted[] = $format;

// let's also build a list of shares created
// by the current user only, in case
Expand Down
11 changes: 6 additions & 5 deletions apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ protected function setUp(): void {
->expects($this->any())
->method('shareApiEnabled')
->willReturn(true);
$this->shareManager
->expects($this->any())
->method('shareProviderExists')->willReturn(true);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->request = $this->createMock(IRequest::class);
Expand Down Expand Up @@ -170,10 +173,10 @@ public function testDeleteShareShareNotFound() {
$this->expectExceptionMessage('Wrong share ID, share doesn\'t exist');

$this->shareManager
->expects($this->exactly(3))
->expects($this->exactly(5))
->method('getShareById')
->will($this->returnCallback(function($id) {
if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42') {
if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42') {
throw new \OCP\Share\Exceptions\ShareNotFound();
} else {
throw new \Exception();
Expand Down Expand Up @@ -1008,9 +1011,7 @@ public function dataGetShares() {
[
],
[
$file1UserShareOwnerExpected,
$file1UserShareOwnerExpected,
$file1UserShareOwnerExpected,
$file1UserShareOwnerExpected
]
],
[
Expand Down