@@ -11,121 +11,121 @@ |
||
| 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 | } |