|
27 | 27 | */ |
28 | 28 | namespace OCA\Files\Controller; |
29 | 29 |
|
| 30 | +use OCA\Files\Capabilities; |
30 | 31 | use OCA\Files\Service\TagService; |
31 | 32 | use OCP\AppFramework\Http; |
32 | 33 | use OCP\AppFramework\Http\DataResponse; |
@@ -211,6 +212,42 @@ public function testUpdateFileSorting() { |
211 | 212 | $this->assertEquals($expected, $actual); |
212 | 213 | } |
213 | 214 |
|
| 215 | + public function testUpdateFileSortingWithBadParams() { |
| 216 | + $mode = 'abcdef'; |
| 217 | + $direction = '123456'; |
| 218 | + |
| 219 | + $this->config->expects($this->never()) |
| 220 | + ->method('setUserValue') |
| 221 | + ->with($this->user->getUID(), 'files', 'file_sorting', $mode); |
| 222 | + $this->config->expects($this->never()) |
| 223 | + ->method('setUserValue') |
| 224 | + ->with($this->user->getUID(), 'files', 'file_sorting_direction', $direction); |
| 225 | + |
| 226 | + $actual = $this->apiController->updateFileSorting($mode, $direction); |
| 227 | + $this->assertEquals($actual->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY); |
| 228 | + } |
| 229 | + |
| 230 | + public function testGetFileSorting() { |
| 231 | + $file_sorting = Capabilities::SORTING_MODES[0]; |
| 232 | + $file_sorting_direction = Capabilities::SORTING_DIRECTIONS[0]; |
| 233 | + |
| 234 | + $this->config->expects($this->at(0)) |
| 235 | + ->method('getUserValue') |
| 236 | + ->with($this->user->getUID(), 'files', 'file_sorting', $file_sorting) |
| 237 | + ->willReturn($file_sorting); |
| 238 | + $this->config->expects($this->at(1)) |
| 239 | + ->method('getUserValue') |
| 240 | + ->with($this->user->getUID(), 'files', 'file_sorting_direction', $file_sorting_direction) |
| 241 | + ->willReturn($file_sorting_direction); |
| 242 | + |
| 243 | + $expected = new HTTP\JSONResponse([ |
| 244 | + 'file_sorting' => 'name', |
| 245 | + 'file_sorting_direction' => 'asc' |
| 246 | + ]); |
| 247 | + $actual = $this->apiController->getFileSorting(); |
| 248 | + $this->assertEquals($expected, $actual); |
| 249 | + } |
| 250 | + |
214 | 251 | public function invalidSortingModeData() { |
215 | 252 | return [ |
216 | 253 | ['color', 'asc'], |
|
0 commit comments