diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2023-04-14 12:40:08 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2023-04-18 09:02:01 +0200 |
commit | d7ab8da1ef7decb512d68b038fc7e92758fbb518 (patch) | |
tree | 302b14a5a8a5c3b07cabc3595caba53500eca238 /apps/files/tests | |
parent | ff58cd52279cccfbda0cc4683f1194d6c7ee283b (diff) | |
download | nextcloud-server-d7ab8da1ef7decb512d68b038fc7e92758fbb518.tar.gz nextcloud-server-d7ab8da1ef7decb512d68b038fc7e92758fbb518.zip |
feat(files): add view config service to store user-config per view
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/tests')
-rw-r--r-- | apps/files/tests/Controller/ApiControllerTest.php | 53 | ||||
-rw-r--r-- | apps/files/tests/Controller/ViewControllerTest.php | 5 |
2 files changed, 11 insertions, 47 deletions
diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php index 2f4daa98901..269977350f7 100644 --- a/apps/files/tests/Controller/ApiControllerTest.php +++ b/apps/files/tests/Controller/ApiControllerTest.php @@ -29,6 +29,7 @@ namespace OCA\Files\Controller; use OCA\Files\Service\TagService; use OCA\Files\Service\UserConfig; +use OCA\Files\Service\ViewConfig; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\Files\File; @@ -70,6 +71,8 @@ class ApiControllerTest extends TestCase { private $userFolder; /** @var UserConfig|\PHPUnit\Framework\MockObject\MockObject */ private $userConfig; + /** @var ViewConfig|\PHPUnit\Framework\MockObject\MockObject */ + private $viewConfig; protected function setUp(): void { parent::setUp(); @@ -99,6 +102,7 @@ class ApiControllerTest extends TestCase { ->disableOriginalConstructor() ->getMock(); $this->userConfig = $this->createMock(UserConfig::class); + $this->viewConfig = $this->createMock(ViewConfig::class); $this->apiController = new ApiController( $this->appName, @@ -109,7 +113,8 @@ class ApiControllerTest extends TestCase { $this->shareManager, $this->config, $this->userFolder, - $this->userConfig + $this->userConfig, + $this->viewConfig ); } @@ -202,52 +207,6 @@ class ApiControllerTest extends TestCase { $this->assertInstanceOf(Http\FileDisplayResponse::class, $ret); } - public function testUpdateFileSorting() { - $mode = 'mtime'; - $direction = 'desc'; - - $sortingConfig = []; - $sortingConfig['files'] = [ - 'mode' => $mode, - 'direction' => $direction, - ]; - - $this->config->expects($this->once()) - ->method('setUserValue') - ->with($this->user->getUID(), 'files', 'files_sorting_configs', json_encode($sortingConfig)); - - $expected = new HTTP\JSONResponse([ - 'message' => 'ok', - 'data' => $sortingConfig - ]); - $actual = $this->apiController->updateFileSorting($mode, $direction); - $this->assertEquals($expected, $actual); - } - - public function invalidSortingModeData() { - return [ - ['size'], - ['bar'] - ]; - } - - /** - * @dataProvider invalidSortingModeData - */ - public function testUpdateInvalidFileSorting($direction) { - $this->config->expects($this->never()) - ->method('setUserValue'); - - $expected = new Http\JSONResponse([ - 'message' => 'Invalid direction parameter' - ]); - $expected->setStatus(Http::STATUS_UNPROCESSABLE_ENTITY); - - $result = $this->apiController->updateFileSorting('basename', $direction); - - $this->assertEquals($expected, $result); - } - public function testShowHiddenFiles() { $show = false; diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index 58b70f8b0fa..64f0f10671c 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -35,6 +35,7 @@ namespace OCA\Files\Tests\Controller; use OCA\Files\Activity\Helper; use OCA\Files\Controller\ViewController; use OCA\Files\Service\UserConfig; +use OCA\Files\Service\ViewConfig; use OCP\App\IAppManager; use OCP\AppFramework\Http; use OCP\AppFramework\Services\IInitialState; @@ -90,6 +91,8 @@ class ViewControllerTest extends TestCase { private $shareManager; /** @var UserConfig|\PHPUnit\Framework\MockObject\MockObject */ private $userConfig; + /** @var ViewConfig|\PHPUnit\Framework\MockObject\MockObject */ + private $viewConfig; protected function setUp(): void { parent::setUp(); @@ -113,6 +116,7 @@ class ViewControllerTest extends TestCase { $this->templateManager = $this->createMock(ITemplateManager::class); $this->shareManager = $this->createMock(IManager::class); $this->userConfig = $this->createMock(UserConfig::class); + $this->viewConfig = $this->createMock(ViewConfig::class); $this->viewController = $this->getMockBuilder('\OCA\Files\Controller\ViewController') ->setConstructorArgs([ 'files', @@ -129,6 +133,7 @@ class ViewControllerTest extends TestCase { $this->templateManager, $this->shareManager, $this->userConfig, + $this->viewConfig, ]) ->setMethods([ 'getStorageInfo', |