Skip to content

Commit bfed23e

Browse files
test(files_sharing): cover duplicate file_source entries in populateTags
Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent ac1f53f commit bfed23e

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

apps/files_sharing/tests/Controller/ShareAPIControllerTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5257,6 +5257,31 @@ public function testPopulateTags(): void {
52575257
], $result);
52585258
}
52595259

5260+
public function testPopulateTagsWithDuplicateFileSource(): void {
5261+
$tagger = $this->createMock(ITags::class);
5262+
$this->tagManager->method('load')
5263+
->with('files')
5264+
->willReturn($tagger);
5265+
$data = [
5266+
['file_source' => 42, 'foo' => 'bar'],
5267+
['file_source' => 10],
5268+
['file_source' => 42, 'x' => 'y'],
5269+
];
5270+
$tags = [
5271+
42 => ['tag1', 'tag2'],
5272+
];
5273+
$tagger->method('getTagsForObjects')
5274+
->with([42, 10, 42])
5275+
->willReturn($tags);
5276+
5277+
$result = self::invokePrivate($this->ocs, 'populateTags', [$data]);
5278+
$this->assertSame([
5279+
['file_source' => 42, 'foo' => 'bar', 'tags' => ['tag1', 'tag2']],
5280+
['file_source' => 10, 'tags' => []],
5281+
['file_source' => 42, 'x' => 'y', 'tags' => ['tag1', 'tag2']],
5282+
], $result);
5283+
}
5284+
52605285
public static function trustedServerProvider(): array {
52615286
return [
52625287
'Trusted server' => [true, true],

0 commit comments

Comments
 (0)