|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Nextcloud - Tasks |
|
4
|
|
|
* |
|
5
|
|
|
* @author Raimund Schlüßler |
|
6
|
|
|
* @copyright 2019 Raimund Schlüßler <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This library is free software; you can redistribute it and/or |
|
9
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
10
|
|
|
* License as published by the Free Software Foundation; either |
|
11
|
|
|
* version 3 of the License, or any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This library is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public |
|
19
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace OCA\Tasks\Tests\Unit\Controller; |
|
24
|
|
|
|
|
25
|
|
|
use OCA\Tasks\Controller\SettingsController; |
|
26
|
|
|
use OCA\Tasks\Service\SettingsService; |
|
27
|
|
|
use OCP\IRequest; |
|
28
|
|
|
|
|
29
|
|
|
use PHPUnit\Framework\TestCase; |
|
30
|
|
|
|
|
31
|
|
|
class SettingsControllerTest extends TestCase { |
|
32
|
|
|
private $appName; |
|
33
|
|
|
private $settingsService; |
|
34
|
|
|
private $request; |
|
35
|
|
|
private $controller; |
|
36
|
|
|
|
|
37
|
|
|
use \OCA\Tasks\Controller\Response; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Gets run before each test |
|
41
|
|
|
*/ |
|
42
|
|
|
public function setUp(): void { |
|
43
|
|
|
$this->appName = 'tasks'; |
|
44
|
|
|
$this->settingsService = $this->getMockBuilder(SettingsService::class) |
|
45
|
|
|
->disableOriginalConstructor() |
|
46
|
|
|
->getMock(); |
|
47
|
|
|
$this->request = $this->getMockBuilder(IRequest::class) |
|
48
|
|
|
->disableOriginalConstructor() |
|
49
|
|
|
->getMock(); |
|
50
|
|
|
$this->controller = new SettingsController( |
|
51
|
|
|
$this->appName, |
|
52
|
|
|
$this->request, |
|
53
|
|
|
$this->settingsService |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function testSet() { |
|
58
|
|
|
$this->settingsService->expects($this->once()) |
|
59
|
|
|
->method('set') |
|
60
|
|
|
->with( |
|
61
|
|
|
'sortOrder', |
|
62
|
|
|
$this->equalTo(0) |
|
63
|
|
|
) |
|
64
|
|
|
->will($this->returnValue(true)); |
|
65
|
|
|
|
|
66
|
|
|
$expected = $this->generateResponse(function () { |
|
67
|
|
|
return true; |
|
68
|
|
|
}); |
|
69
|
|
|
$response = $this->controller->set('sortOrder', 0); |
|
70
|
|
|
$this->assertEquals($expected, $response); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|