summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-06-21 18:01:49 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2023-07-07 17:55:50 +0200
commit1ffae9d110343d9dbf48e0fb96ce83e6b51cd763 (patch)
tree476ec1a156097f9a82aca48eb85f48d2e43a15f7
parentd21b251a8581a5035692e3e75ee1d9c89b9d0558 (diff)
downloadnextcloud-server-1ffae9d110343d9dbf48e0fb96ce83e6b51cd763.tar.gz
nextcloud-server-1ffae9d110343d9dbf48e0fb96ce83e6b51cd763.zip
fix: cominbation of small fixes
- possible null return - parameter name mismatch in implementation - incomplete unit test Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesReportPlugin.php6
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php23
-rw-r--r--lib/private/Files/Node/Folder.php4
3 files changed, 25 insertions, 8 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
index 4fabe9fdd1c..450fe134772 100644
--- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
@@ -284,9 +284,9 @@ class FilesReportPlugin extends ServerPlugin {
* @param array $filterRules
* @return array array of unique file id results
*/
- protected function processFilterRulesForFileIDs($filterRules) {
+ protected function processFilterRulesForFileIDs(array $filterRules): array {
$ns = '{' . $this::NS_OWNCLOUD . '}';
- $resultFileIds = null;
+ $resultFileIds = [];
$circlesIds = [];
$favoriteFilter = null;
foreach ($filterRules as $filterRule) {
@@ -407,7 +407,7 @@ class FilesReportPlugin extends ServerPlugin {
* @param array $fileIds file ids
* @return Node[] array of Sabre nodes
*/
- public function findNodesByFileIds($rootNode, $fileIds): array {
+ public function findNodesByFileIds(Node $rootNode, array $fileIds): array {
if (empty($fileIds)) {
return [];
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
index 7cb2d85fe1f..f1f1cc8b27f 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
@@ -890,12 +890,25 @@ class FilesReportPluginTest extends \Test\TestCase {
$filesNode1 = $this->createMock(File::class);
$filesNode1->expects($this->any())
+ ->method('getId')
+ ->willReturn(111);
+ $filesNode1->expects($this->any())
->method('getSize')
->willReturn(12);
$filesNode2 = $this->createMock(Folder::class);
$filesNode2->expects($this->any())
+ ->method('getId')
+ ->willReturn(222);
+ $filesNode2->expects($this->any())
->method('getSize')
->willReturn(10);
+ $filesNode3 = $this->createMock(Folder::class);
+ $filesNode3->expects($this->any())
+ ->method('getId')
+ ->willReturn(333);
+ $filesNode3->expects($this->any())
+ ->method('getSize')
+ ->willReturn(33);
$this->tagManager->expects($this->once())
->method('getTagsByIds')
@@ -903,16 +916,20 @@ class FilesReportPluginTest extends \Test\TestCase {
->willReturn([$tag1, $tag2]);
// main assertion: only user visible tags are being passed through.
- $this->userFolder->expects($this->exactly(1))
+ $this->userFolder->expects($this->exactly(2))
->method('searchBySystemTag')
- ->with('FourFiveSix', $this->anything(), $this->anything(), $this->anything());
+ ->withConsecutive(['OneTwoThree'], ['FourFiveSix'])
+ ->willReturnOnConsecutiveCalls(
+ [$filesNode1, $filesNode2],
+ [$filesNode2, $filesNode3],
+ );
$rules = [
['name' => '{http://owncloud.org/ns}systemtag', 'value' => '123'],
['name' => '{http://owncloud.org/ns}systemtag', 'value' => '456'],
];
- $this->invokePrivate($this->plugin, 'processFilterRulesForFileNodes', [$rules, null, null]);
+ $this->assertEquals([$filesNode2], array_values($this->invokePrivate($this->plugin, 'processFilterRulesForFileNodes', [$rules, null, null])));
}
public function testProcessFavoriteFilter(): void {
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php
index f409f5e63f4..9f84993000f 100644
--- a/lib/private/Files/Node/Folder.php
+++ b/lib/private/Files/Node/Folder.php
@@ -301,8 +301,8 @@ class Folder extends Node implements \OCP\Files\Folder {
return $this->search($query);
}
- public function searchBySystemTag(string $tag, string $userId, int $limit = 0, int $offset = 0): array {
- $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'systemtag', $tag), $userId, $limit, $offset);
+ public function searchBySystemTag(string $tagName, string $userId, int $limit = 0, int $offset = 0): array {
+ $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'systemtag', $tagName), $userId, $limit, $offset);
return $this->search($query);
}