Completed
Branch test-environment (ae587d)
by Julius
02:23
created
templates/admin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
     <h2><?php p($l->t('App Order')) ?></h2>
3 3
     <p><?php p($l->t('Set default order for all users')) ?></p>
4 4
     <ul id="appsorter">
5
-    <?php foreach($_['nav'] as $entry) { ?>
5
+    <?php foreach ($_['nav'] as $entry) { ?>
6 6
         <li>
7 7
             <img class="app-icon svg" alt="" src="<?php print_unescaped($entry['icon']); ?>">
8 8
             <a href="<?php print_unescaped($entry['href']); ?>">
Please login to merge, or discard this patch.
controller/settingscontroller.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,21 +8,21 @@  discard block
 block discarded – undo
8 8
 use \OCP\INavigationManager;
9 9
 use \OCA\AppOrder\Service\ConfigService;
10 10
 
11
-class SettingsController extends Controller{
11
+class SettingsController extends Controller {
12 12
 
13 13
     private $userId;
14 14
     private $l10n;
15 15
     private $appConfig;
16 16
     private $navigationManager;
17 17
 
18
-    public function __construct($appName, IRequest $request, ConfigService $appConfig, INavigationManager $navigationManager, $userId){
18
+    public function __construct($appName, IRequest $request, ConfigService $appConfig, INavigationManager $navigationManager, $userId) {
19 19
         parent::__construct($appName, $request);
20 20
         $this->userId = $userId;
21 21
         $this->appConfig = $appConfig;
22 22
         $this->navigationManager = $navigationManager;
23 23
     }
24 24
 
25
-    public function adminIndex(){
25
+    public function adminIndex() {
26 26
         $navigation = $this->navigationManager->getAll();
27 27
         $order = json_decode($this->appConfig->getAppValue('order'));
28 28
         $nav = $this->matchOrder($navigation, $order);
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
     private function matchOrder($nav, $order) {
48 48
         $nav_tmp = array();
49 49
         $result = array();
50
-        foreach($nav as $app)
50
+        foreach ($nav as $app)
51 51
             $nav_tmp[$app['href']] = $app;
52
-        foreach($order as $app)
52
+        foreach ($order as $app)
53 53
             $result[$app] = $nav_tmp[$app];
54
-        foreach($nav as $app)
55
-            if(!array_key_exists($app['href'], $result))
54
+        foreach ($nav as $app)
55
+            if (!array_key_exists($app['href'], $result))
56 56
                 $result[$app['href']] = $app;
57 57
         return $result;
58 58
     }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     /**
61 61
      * @NoAdminRequired
62 62
      */
63
-    public function getOrder(){
63
+    public function getOrder() {
64 64
         $order = $this->getAppOrder();
65 65
         return array('status' => 'success', 'order' => $order);
66 66
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     /**
69 69
      * @NoAdminRequired
70 70
      */
71
-    public function savePersonal($order){
71
+    public function savePersonal($order) {
72 72
         $this->appConfig->setUserValue('order', $this->userId, $order);
73 73
         $response = array(
74 74
             'status' => 'success',
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
         return $response;
79 79
     }
80 80
 
81
-    public function saveDefaultOrder($order){
82
-        if (!is_null($order)){
83
-            $this->appConfig->setAppValue('order',$order);
81
+    public function saveDefaultOrder($order) {
82
+        if (!is_null($order)) {
83
+            $this->appConfig->setAppValue('order', $order);
84 84
         }
85 85
         return array('status' => 'success', 'order' => $order);
86 86
     }
Please login to merge, or discard this patch.
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,23 +37,27 @@
 block discarded – undo
37 37
     private 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
     private 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.
appinfo/application.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 
8 8
 class Application extends App {
9 9
 
10
-    public function __construct(array $urlParams=array()){
10
+    public function __construct(array $urlParams = array()) {
11 11
         parent::__construct('apporder', $urlParams);
12 12
         $container = $this->getContainer();
13 13
         $container->registerService('ConfigService', function($c) {
Please login to merge, or discard this patch.
service/configservice.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
     private $config;
10 10
     private $appName;
11 11
 
12
-    public function __construct(IConfig $config, $appName){
12
+    public function __construct(IConfig $config, $appName) {
13 13
         $this->config = $config;
14 14
         $this->appName = $appName;
15 15
     }
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@
 block discarded – undo
9 9
  * @copyright jus 2016
10 10
  */
11 11
 
12
-require_once __DIR__ . '/../../../tests/bootstrap.php';
13
-require_once __DIR__ . '/../appinfo/autoload.php';
12
+require_once __DIR__.'/../../../tests/bootstrap.php';
13
+require_once __DIR__.'/../appinfo/autoload.php';
14 14
 
15
-\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
15
+\OC::$loader->addValidRoot(OC::$SERVERROOT.'/tests');
16 16
 \OC_App::loadApp('apporder');
Please login to merge, or discard this patch.
tests/unit/controller/SettingsControllerTest.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -11,121 +11,121 @@
 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 test() {
50
-  /*  $expected = ['hi'];
49
+    public function test() {
50
+    /*  $expected = ['hi'];
51 51
     $this->service->expects($this->once())
52 52
       ->method('getAll')
53 53
       ->will($this->returnValue($expected));
54 54
     $response = $this->controller->index();
55 55
     $this->assertEquals($expected, $response->getData());
56 56
   $this->assertTrue($response instanceof DataResponse);*/
57
-  }
57
+    }
58 58
 
59
-  public function testAdminIndex() {
59
+    public function testAdminIndex() {
60 60
     $nav_custom = ['/app/calendar/', '/app/tasks/'];
61 61
     $nav_oc = [
62
-      ['href' => '/app/files/', 'name' => 'Files'],
63
-      ['href' => '/app/calendar/', 'name' => 'Calendar'],
64
-      ['href' => '/app/tasks/', 'name' => 'Tasks'],
62
+        ['href' => '/app/files/', 'name' => 'Files'],
63
+        ['href' => '/app/calendar/', 'name' => 'Calendar'],
64
+        ['href' => '/app/tasks/', 'name' => 'Tasks'],
65 65
     ];
66 66
     $nav_final = [
67
-      '/app/calendar/' => $nav_oc[1], '/app/tasks/' => $nav_oc[2], '/app/files/' => $nav_oc[0]
68
-      ];
67
+        '/app/calendar/' => $nav_oc[1], '/app/tasks/' => $nav_oc[2], '/app/files/' => $nav_oc[0]
68
+        ];
69 69
     $this->service->expects($this->once())
70
-      ->method('getAppValue')
71
-      ->with('order')
72
-      ->will($this->returnValue(json_encode($nav_custom)));
70
+        ->method('getAppValue')
71
+        ->with('order')
72
+        ->will($this->returnValue(json_encode($nav_custom)));
73 73
     $this->navigationManager->expects($this->once())
74
-      ->method('getAll')
75
-      ->will($this->returnValue($nav_oc));
74
+        ->method('getAll')
75
+        ->will($this->returnValue($nav_oc));
76 76
 
77 77
     $result = $this->controller->adminIndex(); 
78 78
     $expected = new \OCP\AppFramework\Http\TemplateResponse(
79
-      $this->appName, 
80
-      'admin',
81
-      ["nav" => $nav_final],
82
-      'blank'
79
+        $this->appName, 
80
+        'admin',
81
+        ["nav" => $nav_final],
82
+        'blank'
83 83
     );
84 84
     $this->assertEquals($expected, $result);
85
-  }
85
+    }
86 86
 
87
-  public function testMatchOrder() {
87
+    public function testMatchOrder() {
88 88
     $nav = [
89
-      ['href' => '/app/files/', 'name' => 'Files'],
90
-      ['href' => '/app/calendar/', 'name' => 'Calendar'],
91
-      ['href' => '/app/tasks/', 'name' => 'Tasks'],
89
+        ['href' => '/app/files/', 'name' => 'Files'],
90
+        ['href' => '/app/calendar/', 'name' => 'Calendar'],
91
+        ['href' => '/app/tasks/', 'name' => 'Tasks'],
92 92
     ];
93 93
     $order = ['/app/calendar/', '/app/tasks/'];
94 94
     $result = $this->controller->matchOrder($nav, $order);
95 95
     $expected = [
96
-      '/app/calendar/' => ['href' => '/app/calendar/', 'name' => 'Calendar'],
97
-      '/app/tasks/' => ['href' => '/app/tasks/', 'name' => 'Tasks'],
98
-      '/app/files/' => ['href' => '/app/files/', 'name' => 'Files'],
96
+        '/app/calendar/' => ['href' => '/app/calendar/', 'name' => 'Calendar'],
97
+        '/app/tasks/' => ['href' => '/app/tasks/', 'name' => 'Tasks'],
98
+        '/app/files/' => ['href' => '/app/files/', 'name' => 'Files'],
99 99
     ];
100 100
     $this->assertEquals($expected, $result);
101
-  }
101
+    }
102 102
 
103
-  public function testGetAppOrder() {
103
+    public function testGetAppOrder() {
104 104
     $nav_system= ['/app/calendar/', '/app/tasks/'];
105 105
     $nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/'];
106 106
     $this->service->expects($this->once())
107
-      ->method('getAppValue')
108
-      ->with('order')
109
-      ->will($this->returnValue(json_encode($nav_system)));
107
+        ->method('getAppValue')
108
+        ->with('order')
109
+        ->will($this->returnValue(json_encode($nav_system)));
110 110
     $this->service->expects($this->once())
111
-      ->method('getUserValue')
112
-      ->with('order', $this->userId)
113
-      ->will($this->returnValue(json_encode($nav_user)));
111
+        ->method('getUserValue')
112
+        ->with('order', $this->userId)
113
+        ->will($this->returnValue(json_encode($nav_user)));
114 114
     $result = $this->controller->getAppOrder();
115 115
     $this->assertEquals(json_encode($nav_user), $result);
116
-  }
117
-  public function testGetAppOrderNoUser() {
116
+    }
117
+    public function testGetAppOrderNoUser() {
118 118
     $nav_system= ['/app/calendar/', '/app/tasks/'];
119 119
     $nav_user = '';
120 120
     $this->service->expects($this->once())
121
-      ->method('getAppValue')
122
-      ->with('order')
123
-      ->will($this->returnValue(json_encode($nav_system)));
121
+        ->method('getAppValue')
122
+        ->with('order')
123
+        ->will($this->returnValue(json_encode($nav_system)));
124 124
     $this->service->expects($this->once())
125
-      ->method('getUserValue')
126
-      ->with('order', $this->userId)
127
-      ->will($this->returnValue($nav_user));
125
+        ->method('getUserValue')
126
+        ->with('order', $this->userId)
127
+        ->will($this->returnValue($nav_user));
128 128
     $result = $this->controller->getAppOrder();
129 129
     $this->assertEquals(json_encode($nav_system), $result);
130
-  }
130
+    }
131 131
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
   private $appName;
20 20
   private $controller;
21 21
   private $config;
22
-  public function setUp (){
22
+  public function setUp() {
23 23
 
24 24
     parent::setUp();
25 25
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     $this->service = $this->getMockBuilder('\OCA\AppOrder\Service\ConfigService')
35 35
       ->disableOriginalConstructor()
36 36
       ->getMock();
37
-    $this->navigationManager = $this->getMockBuilder('\OCP\INavigationManager')->setMethods(['getAll','add','setActiveEntry'])
37
+    $this->navigationManager = $this->getMockBuilder('\OCP\INavigationManager')->setMethods(['getAll', 'add', 'setActiveEntry'])
38 38
       ->disableOriginalConstructor()
39 39
       ->getMock();
40 40
     $this->userId = 'admin';
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
   }
102 102
 
103 103
   public function testGetAppOrder() {
104
-    $nav_system= ['/app/calendar/', '/app/tasks/'];
104
+    $nav_system = ['/app/calendar/', '/app/tasks/'];
105 105
     $nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/'];
106 106
     $this->service->expects($this->once())
107 107
       ->method('getAppValue')
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     $this->assertEquals(json_encode($nav_user), $result);
116 116
   }
117 117
   public function testGetAppOrderNoUser() {
118
-    $nav_system= ['/app/calendar/', '/app/tasks/'];
118
+    $nav_system = ['/app/calendar/', '/app/tasks/'];
119 119
     $nav_user = '';
120 120
     $this->service->expects($this->once())
121 121
       ->method('getAppValue')
Please login to merge, or discard this patch.