summaryrefslogtreecommitdiffstats
path: root/apps/files/tests
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2023-03-24 09:41:40 +0100
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-04-06 14:49:31 +0200
commit3c3050c76f86c7a8cc2f217f9305cb1051e0eca0 (patch)
treed9656a549b1db4c7f3d37549713a6c96da616464 /apps/files/tests
parent0b4da6117fff4d999cb492503a8b6fc04eb75f9d (diff)
downloadnextcloud-server-3c3050c76f86c7a8cc2f217f9305cb1051e0eca0.tar.gz
nextcloud-server-3c3050c76f86c7a8cc2f217f9305cb1051e0eca0.zip
feat(files): implement sorting per view
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/tests')
-rw-r--r--apps/files/tests/Controller/ApiControllerTest.php31
-rw-r--r--apps/files/tests/Controller/ViewControllerTest.php19
2 files changed, 20 insertions, 30 deletions
diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php
index 6df3f46c5a9..2f4daa98901 100644
--- a/apps/files/tests/Controller/ApiControllerTest.php
+++ b/apps/files/tests/Controller/ApiControllerTest.php
@@ -206,37 +206,44 @@ class ApiControllerTest extends TestCase {
$mode = 'mtime';
$direction = 'desc';
- $this->config->expects($this->exactly(2))
+ $sortingConfig = [];
+ $sortingConfig['files'] = [
+ 'mode' => $mode,
+ 'direction' => $direction,
+ ];
+
+ $this->config->expects($this->once())
->method('setUserValue')
- ->withConsecutive(
- [$this->user->getUID(), 'files', 'file_sorting', $mode],
- [$this->user->getUID(), 'files', 'file_sorting_direction', $direction],
- );
+ ->with($this->user->getUID(), 'files', 'files_sorting_configs', json_encode($sortingConfig));
- $expected = new HTTP\Response();
+ $expected = new HTTP\JSONResponse([
+ 'message' => 'ok',
+ 'data' => $sortingConfig
+ ]);
$actual = $this->apiController->updateFileSorting($mode, $direction);
$this->assertEquals($expected, $actual);
}
public function invalidSortingModeData() {
return [
- ['color', 'asc'],
- ['name', 'size'],
- ['foo', 'bar']
+ ['size'],
+ ['bar']
];
}
/**
* @dataProvider invalidSortingModeData
*/
- public function testUpdateInvalidFileSorting($mode, $direction) {
+ public function testUpdateInvalidFileSorting($direction) {
$this->config->expects($this->never())
->method('setUserValue');
- $expected = new Http\Response(null);
+ $expected = new Http\JSONResponse([
+ 'message' => 'Invalid direction parameter'
+ ]);
$expected->setStatus(Http::STATUS_UNPROCESSABLE_ENTITY);
- $result = $this->apiController->updateFileSorting($mode, $direction);
+ $result = $this->apiController->updateFileSorting('basename', $direction);
$this->assertEquals($expected, $result);
}
diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php
index 08ec7d17a1d..58b70f8b0fa 100644
--- a/apps/files/tests/Controller/ViewControllerTest.php
+++ b/apps/files/tests/Controller/ViewControllerTest.php
@@ -266,19 +266,6 @@ class ViewControllerTest extends TestCase {
'expanded' => false,
'unread' => 0,
],
- 'trashbin' => [
- 'id' => 'trashbin',
- 'appname' => 'files_trashbin',
- 'script' => 'list.php',
- 'order' => 50,
- 'name' => \OC::$server->getL10N('files_trashbin')->t('Deleted files'),
- 'active' => false,
- 'icon' => '',
- 'type' => 'link',
- 'classes' => 'pinned',
- 'expanded' => false,
- 'unread' => 0,
- ],
'shareoverview' => [
'id' => 'shareoverview',
'appname' => 'files_sharing',
@@ -339,7 +326,7 @@ class ViewControllerTest extends TestCase {
'owner' => 'MyName',
'ownerDisplayName' => 'MyDisplayName',
'isPublic' => false,
- 'defaultFileSorting' => 'name',
+ 'defaultFileSorting' => 'basename',
'defaultFileSortingDirection' => 'asc',
'showHiddenFiles' => 0,
'cropImagePreviews' => 1,
@@ -363,10 +350,6 @@ class ViewControllerTest extends TestCase {
'id' => 'systemtagsfilter',
'content' => null,
],
- 'trashbin' => [
- 'id' => 'trashbin',
- 'content' => null,
- ],
'sharingout' => [
'id' => 'sharingout',
'content' => null,