Completed
Push — test-environment ( 1806a4...345bd9 )
by Julius
05:55
created
tests/unit/controller/SettingsControllerTest.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -11,111 +11,111 @@
 block discarded – undo
11 11
 
12 12
 class SettingsControllerTest extends \Test\TestCase {
13 13
 
14
-  private $container;
15
-  private $request;
16
-  private $service;
17
-  private $navigationManager;
18
-  private $userId;
19
-  private $appName;
20
-  private $controller;
21
-  private $config;
22
-  public function setUp (){
14
+    private $container;
15
+    private $request;
16
+    private $service;
17
+    private $navigationManager;
18
+    private $userId;
19
+    private $appName;
20
+    private $controller;
21
+    private $config;
22
+    public function setUp (){
23 23
 
24 24
     parent::setUp();
25 25
 
26 26
     $app = new Application();
27 27
     $this->container = $app->getContainer();
28 28
     $this->request = $this->getMockBuilder('OCP\IRequest')
29
-      ->disableOriginalConstructor()
30
-      ->getMock();
29
+        ->disableOriginalConstructor()
30
+        ->getMock();
31 31
     $this->config = $this->getMockBuilder('OCP\IConfig')
32
-      ->disableOriginalConstructor()
33
-      ->getMock();
32
+        ->disableOriginalConstructor()
33
+        ->getMock();
34 34
     $this->service = $this->getMockBuilder('\OCA\AppOrder\Service\ConfigService')
35
-      ->disableOriginalConstructor()
36
-      ->getMock();
35
+        ->disableOriginalConstructor()
36
+        ->getMock();
37 37
     $this->navigationManager = $this->getMockBuilder('\OCP\INavigationManager')->setMethods(['getAll','add','setActiveEntry'])
38
-      ->disableOriginalConstructor()
39
-      ->getMock();
38
+        ->disableOriginalConstructor()
39
+        ->getMock();
40 40
     $this->userId = 'admin';
41 41
     $this->appName = 'apporder';
42 42
     $this->controller = new \OCA\AppOrder\Controller\SettingsController(
43
-      $this->appName, $this->request, $this->service, $this->navigationManager,
44
-      $this->userId
43
+        $this->appName, $this->request, $this->service, $this->navigationManager,
44
+        $this->userId
45 45
     );
46 46
 
47
-  }
47
+    }
48 48
 
49
-  public function testAdminIndex() {
49
+    public function testAdminIndex() {
50 50
     $nav_custom = ['/app/calendar/', '/app/tasks/'];
51 51
     $nav_oc = [
52
-      ['href' => '/app/files/', 'name' => 'Files'],
53
-      ['href' => '/app/calendar/', 'name' => 'Calendar'],
54
-      ['href' => '/app/tasks/', 'name' => 'Tasks'],
52
+        ['href' => '/app/files/', 'name' => 'Files'],
53
+        ['href' => '/app/calendar/', 'name' => 'Calendar'],
54
+        ['href' => '/app/tasks/', 'name' => 'Tasks'],
55 55
     ];
56 56
     $nav_final = [
57
-      '/app/calendar/' => $nav_oc[1], '/app/tasks/' => $nav_oc[2], '/app/files/' => $nav_oc[0]
58
-      ];
57
+        '/app/calendar/' => $nav_oc[1], '/app/tasks/' => $nav_oc[2], '/app/files/' => $nav_oc[0]
58
+        ];
59 59
     $this->service->expects($this->once())
60
-      ->method('getAppValue')
61
-      ->with('order')
62
-      ->will($this->returnValue(json_encode($nav_custom)));
60
+        ->method('getAppValue')
61
+        ->with('order')
62
+        ->will($this->returnValue(json_encode($nav_custom)));
63 63
     $this->navigationManager->expects($this->once())
64
-      ->method('getAll')
65
-      ->will($this->returnValue($nav_oc));
64
+        ->method('getAll')
65
+        ->will($this->returnValue($nav_oc));
66 66
 
67 67
     $result = $this->controller->adminIndex(); 
68 68
     $expected = new \OCP\AppFramework\Http\TemplateResponse(
69
-      $this->appName, 
70
-      'admin',
71
-      ["nav" => $nav_final],
72
-      'blank'
69
+        $this->appName, 
70
+        'admin',
71
+        ["nav" => $nav_final],
72
+        'blank'
73 73
     );
74 74
     $this->assertEquals($expected, $result);
75
-  }
75
+    }
76 76
 
77
-  public function testMatchOrder() {
77
+    public function testMatchOrder() {
78 78
     $nav = [
79
-      ['href' => '/app/files/', 'name' => 'Files'],
80
-      ['href' => '/app/calendar/', 'name' => 'Calendar'],
81
-      ['href' => '/app/tasks/', 'name' => 'Tasks'],
79
+        ['href' => '/app/files/', 'name' => 'Files'],
80
+        ['href' => '/app/calendar/', 'name' => 'Calendar'],
81
+        ['href' => '/app/tasks/', 'name' => 'Tasks'],
82 82
     ];
83 83
     $order = ['/app/calendar/', '/app/tasks/'];
84 84
     $result = $this->controller->matchOrder($nav, $order);
85 85
     $expected = [
86
-      '/app/calendar/' => ['href' => '/app/calendar/', 'name' => 'Calendar'],
87
-      '/app/tasks/' => ['href' => '/app/tasks/', 'name' => 'Tasks'],
88
-      '/app/files/' => ['href' => '/app/files/', 'name' => 'Files'],
86
+        '/app/calendar/' => ['href' => '/app/calendar/', 'name' => 'Calendar'],
87
+        '/app/tasks/' => ['href' => '/app/tasks/', 'name' => 'Tasks'],
88
+        '/app/files/' => ['href' => '/app/files/', 'name' => 'Files'],
89 89
     ];
90 90
     $this->assertEquals($expected, $result);
91
-  }
91
+    }
92 92
 
93
-  public function testGetAppOrder() {
93
+    public function testGetAppOrder() {
94 94
     $nav_system= ['/app/calendar/', '/app/tasks/'];
95 95
     $nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/'];
96 96
     $this->service->expects($this->once())
97
-      ->method('getAppValue')
98
-      ->with('order')
99
-      ->will($this->returnValue(json_encode($nav_system)));
97
+        ->method('getAppValue')
98
+        ->with('order')
99
+        ->will($this->returnValue(json_encode($nav_system)));
100 100
     $this->service->expects($this->once())
101
-      ->method('getUserValue')
102
-      ->with('order', $this->userId)
103
-      ->will($this->returnValue(json_encode($nav_user)));
101
+        ->method('getUserValue')
102
+        ->with('order', $this->userId)
103
+        ->will($this->returnValue(json_encode($nav_user)));
104 104
     $result = $this->controller->getAppOrder();
105 105
     $this->assertEquals(json_encode($nav_user), $result);
106
-  }
107
-  public function testGetAppOrderNoUser() {
106
+    }
107
+    public function testGetAppOrderNoUser() {
108 108
     $nav_system= ['/app/calendar/', '/app/tasks/'];
109 109
     $nav_user = '';
110 110
     $this->service->expects($this->once())
111
-      ->method('getAppValue')
112
-      ->with('order')
113
-      ->will($this->returnValue(json_encode($nav_system)));
111
+        ->method('getAppValue')
112
+        ->with('order')
113
+        ->will($this->returnValue(json_encode($nav_system)));
114 114
     $this->service->expects($this->once())
115
-      ->method('getUserValue')
116
-      ->with('order', $this->userId)
117
-      ->will($this->returnValue($nav_user));
115
+        ->method('getUserValue')
116
+        ->with('order', $this->userId)
117
+        ->will($this->returnValue($nav_user));
118 118
     $result = $this->controller->getAppOrder();
119 119
     $this->assertEquals(json_encode($nav_system), $result);
120
-  }
120
+    }
121 121
 }
Please login to merge, or discard this patch.