Completed
Push — master ( 6a7f6a...2d18f0 )
by Julius
04:59 queued 02:43
created
controller/settingscontroller.php 1 patch
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,23 +37,27 @@
 block discarded – undo
37 37
     public function getAppOrder() {
38 38
         $order_user = $this->appConfig->getUserValue('order', $this->userId);
39 39
         $order_default = $this->appConfig->getAppValue('order');
40
-        if ($order_user !== null && $order_user !== "")
41
-            $order = $order_user;
42
-        else
43
-            $order = $order_default;
40
+        if ($order_user !== null && $order_user !== "") {
41
+                    $order = $order_user;
42
+        } else {
43
+                    $order = $order_default;
44
+        }
44 45
         return $order;
45 46
     }
46 47
 
47 48
     public function matchOrder($nav, $order) {
48 49
         $nav_tmp = array();
49 50
         $result = array();
50
-        foreach ($nav as $app)
51
-            $nav_tmp[$app['href']] = $app;
52
-        foreach ($order as $app)
53
-            $result[$app] = $nav_tmp[$app];
54
-        foreach ($nav as $app)
55
-            if (!array_key_exists($app['href'], $result))
51
+        foreach ($nav as $app) {
52
+                    $nav_tmp[$app['href']] = $app;
53
+        }
54
+        foreach ($order as $app) {
55
+                    $result[$app] = $nav_tmp[$app];
56
+        }
57
+        foreach ($nav as $app) {
58
+                    if (!array_key_exists($app['href'], $result))
56 59
                 $result[$app['href']] = $app;
60
+        }
57 61
         return $result;
58 62
     }
59 63
 
Please login to merge, or discard this patch.
tests/unit/controller/SettingsControllerTest.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -11,149 +11,149 @@
 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
 
122
-  public function testGetOrder() {
122
+    public function testGetOrder() {
123 123
     $nav_system = ['/app/calendar/', '/app/tasks/'];
124 124
     $nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/'];
125 125
     $this->service->expects($this->once())
126
-      ->method('getAppValue')
127
-      ->with('order')
128
-      ->will($this->returnValue(json_encode($nav_system)));
126
+        ->method('getAppValue')
127
+        ->with('order')
128
+        ->will($this->returnValue(json_encode($nav_system)));
129 129
     $this->service->expects($this->once())
130
-      ->method('getUserValue')
131
-      ->with('order', $this->userId)
132
-      ->will($this->returnValue(json_encode($nav_user)));
130
+        ->method('getUserValue')
131
+        ->with('order', $this->userId)
132
+        ->will($this->returnValue(json_encode($nav_user)));
133 133
     $order = ['/app/files/', '/app/calendar/', '/app/tasks/'];
134 134
     $result = $this->controller->getOrder();
135 135
     $expected = array('status' => 'success', 'order' => json_encode($order));
136 136
     $this->assertEquals($expected, $result);
137
-  }
137
+    }
138 138
 
139
-  public function testSavePersonal() {
139
+    public function testSavePersonal() {
140 140
     $order = "RANDOMORDER";
141 141
     $expected = array(
142
-      'status' => 'success',
143
-      'data' => array('message'=> 'User order saved successfully.'),
144
-      'order' => $order
142
+        'status' => 'success',
143
+        'data' => array('message'=> 'User order saved successfully.'),
144
+        'order' => $order
145 145
     );
146 146
     $result = $this->controller->savePersonal($order);
147 147
     $this->assertEquals($expected, $result);
148
-  }
148
+    }
149 149
 
150
-  public function testSaveDefaultOrder() {
150
+    public function testSaveDefaultOrder() {
151 151
     $order = "RANDOMORDER";
152 152
     $expected = array(
153
-      'status' => 'success',
154
-      'order' => $order
153
+        'status' => 'success',
154
+        'order' => $order
155 155
     );
156 156
     $result = $this->controller->saveDefaultOrder($order);
157 157
     $this->assertEquals($expected, $result);
158
-  }
158
+    }
159 159
 }
Please login to merge, or discard this patch.
tests/unit/service/ConfigServiceTest.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,33 +7,33 @@
 block discarded – undo
7 7
 
8 8
 class ConfigServiceTest extends \Test\TestCase {
9 9
 
10
-  private $config;
11
-  private $service;
10
+    private $config;
11
+    private $service;
12 12
 
13
-  public function setUp() {
13
+    public function setUp() {
14 14
     $this->config = $this->getMockBuilder('\OCP\IConfig')
15
-      ->disableOriginalConstructor()->getMock();
15
+        ->disableOriginalConstructor()->getMock();
16 16
     $this->service = new ConfigService($this->config, 'apporder');
17
-  }
17
+    }
18 18
 
19
-  public function testAppValue() {
19
+    public function testAppValue() {
20 20
     $this->config->expects($this->any())
21
-      ->method('getAppValue')
22
-      ->with('apporder', 'foo')
23
-      ->willReturn('bar');
21
+        ->method('getAppValue')
22
+        ->with('apporder', 'foo')
23
+        ->willReturn('bar');
24 24
 //    $this->service->setAppValue("foo","bar");
25 25
     $result = $this->service->getAppValue("foo");
26 26
     $this->assertEquals('bar', $result);
27
-  }
27
+    }
28 28
 
29
-  public function testUserValue() {
29
+    public function testUserValue() {
30 30
     $this->config->expects($this->any())
31
-      ->method('getUserValue')
32
-      ->with('user', 'apporder', 'foo')
33
-      ->willReturn('bar');
31
+        ->method('getUserValue')
32
+        ->with('user', 'apporder', 'foo')
33
+        ->willReturn('bar');
34 34
     $this->service->setUserValue("foo", "user", "bar");
35 35
     $result = $this->service->getUserValue("foo", "user");
36 36
     $this->assertEquals('bar', $result);
37
-  }
37
+    }
38 38
 
39
-  }
39
+    }
Please login to merge, or discard this patch.