diff options
Diffstat (limited to 'apps/files/tests/HelperTest.php')
-rw-r--r-- | apps/files/tests/HelperTest.php | 48 |
1 files changed, 8 insertions, 40 deletions
diff --git a/apps/files/tests/HelperTest.php b/apps/files/tests/HelperTest.php index 0cf2812f816..cb1fc5ed66d 100644 --- a/apps/files/tests/HelperTest.php +++ b/apps/files/tests/HelperTest.php @@ -1,17 +1,17 @@ <?php -use OC\Files\FileInfo; -use OCA\Files\Helper; -use OCP\ITagManager; -use OCP\ITags; - +declare(strict_types=1); /** * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. * SPDX-License-Identifier: AGPL-3.0-only */ + +use OC\Files\FileInfo; +use OCA\Files\Helper; + class HelperTest extends \Test\TestCase { - private function makeFileInfo($name, $size, $mtime, $isDir = false) { + private static function makeFileInfo($name, $size, $mtime, $isDir = false): FileInfo { return new FileInfo( '/' . $name, null, @@ -30,7 +30,7 @@ class HelperTest extends \Test\TestCase { /** * Returns a file list for testing */ - private function getTestFileList() { + private static function getTestFileList(): array { return [ self::makeFileInfo('a.txt', 4, 2.3 * pow(10, 9)), self::makeFileInfo('q.txt', 5, 150), @@ -41,7 +41,7 @@ class HelperTest extends \Test\TestCase { ]; } - public function sortDataProvider() { + public static function sortDataProvider(): array { return [ [ 'name', @@ -94,36 +94,4 @@ class HelperTest extends \Test\TestCase { $fileNames ); } - - public function testPopulateTags(): void { - $tagManager = $this->createMock(ITagManager::class); - $tagger = $this->createMock(ITags::class); - - $tagManager->method('load') - ->with('files') - ->willReturn($tagger); - - $data = [ - ['file_source' => 10], - ['file_source' => 22, 'foo' => 'bar'], - ['file_source' => 42, 'x' => 'y'], - ]; - - $tags = [ - 10 => ['tag3'], - 42 => ['tag1', 'tag2'], - ]; - - $tagger->method('getTagsForObjects') - ->with([10, 22, 42]) - ->willReturn($tags); - - $result = Helper::populateTags($data, $tagManager); - - $this->assertSame([ - ['file_source' => 10, 'tags' => ['tag3']], - ['file_source' => 22, 'foo' => 'bar', 'tags' => []], - ['file_source' => 42, 'x' => 'y', 'tags' => ['tag1', 'tag2']], - ], $result); - } } |