diff options
Diffstat (limited to 'apps/files/tests/Controller/ApiControllerTest.php')
-rw-r--r-- | apps/files/tests/Controller/ApiControllerTest.php | 31 |
1 files changed, 19 insertions, 12 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); } |