@@ -7,33 +7,33 @@ |
||
| 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 | + } |
|
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | 'routes' => [ |
| 5 | - ['name' => 'app#index', 'url' => '/', 'verb' => 'GET'], |
|
| 5 | + ['name' => 'app#index', 'url' => '/', 'verb' => 'GET'], |
|
| 6 | 6 | ['name' => 'settings#getOrder', 'url' => 'ajax/order.php', 'verb' => 'GET'], |
| 7 | 7 | ['name' => 'settings#savePersonal', 'url' => 'ajax/personal.php', 'verb' => 'GET'], |
| 8 | 8 | ['name' => 'settings#saveDefaultOrder', 'url' => 'ajax/admin.php', 'verb' => 'GET'], |
@@ -14,23 +14,23 @@ discard block |
||
| 14 | 14 | private $userId; |
| 15 | 15 | private $appConfig; |
| 16 | 16 | private $navigationManager; |
| 17 | - private $util; |
|
| 17 | + private $util; |
|
| 18 | 18 | |
| 19 | 19 | public function __construct($appName, IRequest $request, ConfigService $appConfig, INavigationManager $navigationManager, Util $util, $userId) { |
| 20 | 20 | parent::__construct($appName, $request); |
| 21 | 21 | $this->userId = $userId; |
| 22 | 22 | $this->appConfig = $appConfig; |
| 23 | 23 | $this->navigationManager = $navigationManager; |
| 24 | - $this->util = $util; |
|
| 24 | + $this->util = $util; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Admin: render admin page |
|
| 29 | - * FIXME: Move to dedicated class |
|
| 30 | - * @return TemplateResponse |
|
| 31 | - */ |
|
| 27 | + /** |
|
| 28 | + * Admin: render admin page |
|
| 29 | + * FIXME: Move to dedicated class |
|
| 30 | + * @return TemplateResponse |
|
| 31 | + */ |
|
| 32 | 32 | public function adminIndex() { |
| 33 | - // Private API call |
|
| 33 | + // Private API call |
|
| 34 | 34 | $navigation = $this->navigationManager->getAll(); |
| 35 | 35 | $order = json_decode($this->appConfig->getAppValue('order')); |
| 36 | 36 | $nav = $this->util->matchOrder($navigation, $order); |
@@ -42,17 +42,17 @@ discard block |
||
| 42 | 42 | ); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Admin: save default order |
|
| 47 | - * @param $order |
|
| 48 | - * @return array |
|
| 49 | - */ |
|
| 50 | - public function saveDefaultOrder($order) { |
|
| 51 | - if (!is_null($order)) { |
|
| 52 | - $this->appConfig->setAppValue('order', $order); |
|
| 53 | - } |
|
| 54 | - return array('status' => 'success', 'order' => $order); |
|
| 55 | - } |
|
| 45 | + /** |
|
| 46 | + * Admin: save default order |
|
| 47 | + * @param $order |
|
| 48 | + * @return array |
|
| 49 | + */ |
|
| 50 | + public function saveDefaultOrder($order) { |
|
| 51 | + if (!is_null($order)) { |
|
| 52 | + $this->appConfig->setAppValue('order', $order); |
|
| 53 | + } |
|
| 54 | + return array('status' => 'success', 'order' => $order); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * @NoAdminRequired |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | return array('status' => 'success', 'order' => $order); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @NoAdminRequired |
|
| 67 | - * @param $order string |
|
| 68 | - * @return array response |
|
| 69 | - */ |
|
| 65 | + /** |
|
| 66 | + * @NoAdminRequired |
|
| 67 | + * @param $order string |
|
| 68 | + * @return array response |
|
| 69 | + */ |
|
| 70 | 70 | public function savePersonal($order) { |
| 71 | 71 | $this->appConfig->setUserValue('order', $this->userId, $order); |
| 72 | 72 | $response = array( |
@@ -24,35 +24,35 @@ |
||
| 24 | 24 | namespace OCA\AppOrder; |
| 25 | 25 | |
| 26 | 26 | class Util { |
| 27 | - private $userId; |
|
| 28 | - private $appConfig; |
|
| 27 | + private $userId; |
|
| 28 | + private $appConfig; |
|
| 29 | 29 | |
| 30 | - public function __construct(ConfigService $appConfig, $userId) { |
|
| 31 | - $this->userId = $userId; |
|
| 32 | - $this->appConfig = $appConfig; |
|
| 33 | - } |
|
| 34 | - public function getAppOrder() { |
|
| 35 | - $order_user = $this->appConfig->getUserValue('order', $this->userId); |
|
| 36 | - $order_default = $this->appConfig->getAppValue('order'); |
|
| 37 | - if ($order_user !== null && $order_user !== "") |
|
| 38 | - $order = $order_user; |
|
| 39 | - else |
|
| 40 | - $order = $order_default; |
|
| 41 | - return $order; |
|
| 42 | - } |
|
| 30 | + public function __construct(ConfigService $appConfig, $userId) { |
|
| 31 | + $this->userId = $userId; |
|
| 32 | + $this->appConfig = $appConfig; |
|
| 33 | + } |
|
| 34 | + public function getAppOrder() { |
|
| 35 | + $order_user = $this->appConfig->getUserValue('order', $this->userId); |
|
| 36 | + $order_default = $this->appConfig->getAppValue('order'); |
|
| 37 | + if ($order_user !== null && $order_user !== "") |
|
| 38 | + $order = $order_user; |
|
| 39 | + else |
|
| 40 | + $order = $order_default; |
|
| 41 | + return $order; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - public function matchOrder($nav, $order) { |
|
| 45 | - $nav_tmp = array(); |
|
| 46 | - $result = array(); |
|
| 47 | - foreach ($nav as $app) |
|
| 48 | - $nav_tmp[$app['href']] = $app; |
|
| 49 | - foreach ($order as $app) |
|
| 50 | - if(array_key_exists($app, $nav_tmp)) |
|
| 51 | - $result[$app] = $nav_tmp[$app]; |
|
| 52 | - foreach ($nav as $app) |
|
| 53 | - if (!array_key_exists($app['href'], $result)) |
|
| 54 | - $result[$app['href']] = $app; |
|
| 55 | - return $result; |
|
| 56 | - } |
|
| 44 | + public function matchOrder($nav, $order) { |
|
| 45 | + $nav_tmp = array(); |
|
| 46 | + $result = array(); |
|
| 47 | + foreach ($nav as $app) |
|
| 48 | + $nav_tmp[$app['href']] = $app; |
|
| 49 | + foreach ($order as $app) |
|
| 50 | + if(array_key_exists($app, $nav_tmp)) |
|
| 51 | + $result[$app] = $nav_tmp[$app]; |
|
| 52 | + foreach ($nav as $app) |
|
| 53 | + if (!array_key_exists($app['href'], $result)) |
|
| 54 | + $result[$app['href']] = $app; |
|
| 55 | + return $result; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | } |
| 59 | 59 | \ No newline at end of file |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | foreach ($nav as $app) |
| 48 | 48 | $nav_tmp[$app['href']] = $app; |
| 49 | 49 | foreach ($order as $app) |
| 50 | - if(array_key_exists($app, $nav_tmp)) |
|
| 50 | + if (array_key_exists($app, $nav_tmp)) |
|
| 51 | 51 | $result[$app] = $nav_tmp[$app]; |
| 52 | 52 | foreach ($nav as $app) |
| 53 | 53 | if (!array_key_exists($app['href'], $result)) |
@@ -34,24 +34,28 @@ |
||
| 34 | 34 | public function getAppOrder() { |
| 35 | 35 | $order_user = $this->appConfig->getUserValue('order', $this->userId); |
| 36 | 36 | $order_default = $this->appConfig->getAppValue('order'); |
| 37 | - if ($order_user !== null && $order_user !== "") |
|
| 38 | - $order = $order_user; |
|
| 39 | - else |
|
| 40 | - $order = $order_default; |
|
| 37 | + if ($order_user !== null && $order_user !== "") { |
|
| 38 | + $order = $order_user; |
|
| 39 | + } else { |
|
| 40 | + $order = $order_default; |
|
| 41 | + } |
|
| 41 | 42 | return $order; |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | public function matchOrder($nav, $order) { |
| 45 | 46 | $nav_tmp = array(); |
| 46 | 47 | $result = array(); |
| 47 | - foreach ($nav as $app) |
|
| 48 | - $nav_tmp[$app['href']] = $app; |
|
| 49 | - foreach ($order as $app) |
|
| 50 | - if(array_key_exists($app, $nav_tmp)) |
|
| 48 | + foreach ($nav as $app) { |
|
| 49 | + $nav_tmp[$app['href']] = $app; |
|
| 50 | + } |
|
| 51 | + foreach ($order as $app) { |
|
| 52 | + if(array_key_exists($app, $nav_tmp)) |
|
| 51 | 53 | $result[$app] = $nav_tmp[$app]; |
| 52 | - foreach ($nav as $app) |
|
| 53 | - if (!array_key_exists($app['href'], $result)) |
|
| 54 | + } |
|
| 55 | + foreach ($nav as $app) { |
|
| 56 | + if (!array_key_exists($app['href'], $result)) |
|
| 54 | 57 | $result[$app['href']] = $app; |
| 58 | + } |
|
| 55 | 59 | return $result; |
| 56 | 60 | } |
| 57 | 61 | |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | ); |
| 18 | 18 | }); |
| 19 | 19 | |
| 20 | - \OCP\Util::addStyle('apporder', 'apporder'); |
|
| 21 | - \OCP\Util::addScript('apporder', 'apporder'); |
|
| 22 | - \OCP\App::registerAdmin('apporder', 'admin'); |
|
| 20 | + \OCP\Util::addStyle('apporder', 'apporder'); |
|
| 21 | + \OCP\Util::addScript('apporder', 'apporder'); |
|
| 22 | + \OCP\App::registerAdmin('apporder', 'admin'); |
|
| 23 | 23 | } |
| 24 | 24 | } |
@@ -28,72 +28,72 @@ |
||
| 28 | 28 | |
| 29 | 29 | class UtilTest extends \PHPUnit_Framework_TestCase { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var ConfigService |
|
| 33 | - */ |
|
| 34 | - private $service; |
|
| 35 | - private $userId; |
|
| 36 | - private $util; |
|
| 37 | - private $config; |
|
| 38 | - public function setUp() { |
|
| 31 | + /** |
|
| 32 | + * @var ConfigService |
|
| 33 | + */ |
|
| 34 | + private $service; |
|
| 35 | + private $userId; |
|
| 36 | + private $util; |
|
| 37 | + private $config; |
|
| 38 | + public function setUp() { |
|
| 39 | 39 | |
| 40 | 40 | parent::setUp(); |
| 41 | 41 | |
| 42 | 42 | $this->config = $this->getMockBuilder('OCP\IConfig') |
| 43 | - ->disableOriginalConstructor() |
|
| 44 | - ->getMock(); |
|
| 43 | + ->disableOriginalConstructor() |
|
| 44 | + ->getMock(); |
|
| 45 | 45 | $this->service = $this->getMockBuilder('\OCA\AppOrder\Service\ConfigService') |
| 46 | - ->disableOriginalConstructor() |
|
| 47 | - ->getMock(); |
|
| 46 | + ->disableOriginalConstructor() |
|
| 47 | + ->getMock(); |
|
| 48 | 48 | $this->userId = 'admin'; |
| 49 | 49 | $this->util = new Util($this->service, $this->userId); |
| 50 | 50 | |
| 51 | - } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function testMatchOrder() { |
|
| 53 | + public function testMatchOrder() { |
|
| 54 | 54 | $nav = [ |
| 55 | - ['href' => '/app/files/', 'name' => 'Files'], |
|
| 56 | - ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 57 | - ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 55 | + ['href' => '/app/files/', 'name' => 'Files'], |
|
| 56 | + ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 57 | + ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 58 | 58 | ]; |
| 59 | 59 | $order = ['/app/calendar/', '/app/tasks/']; |
| 60 | 60 | $result = $this->util->matchOrder($nav, $order); |
| 61 | 61 | $expected = [ |
| 62 | - '/app/calendar/' => ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 63 | - '/app/tasks/' => ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 64 | - '/app/files/' => ['href' => '/app/files/', 'name' => 'Files'], |
|
| 62 | + '/app/calendar/' => ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 63 | + '/app/tasks/' => ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 64 | + '/app/files/' => ['href' => '/app/files/', 'name' => 'Files'], |
|
| 65 | 65 | ]; |
| 66 | 66 | $this->assertEquals($expected, $result); |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - public function testGetAppOrder() { |
|
| 69 | + public function testGetAppOrder() { |
|
| 70 | 70 | $nav_system = ['/app/calendar/', '/app/tasks/']; |
| 71 | 71 | $nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/']; |
| 72 | 72 | $this->service->expects($this->once()) |
| 73 | - ->method('getAppValue') |
|
| 74 | - ->with('order') |
|
| 75 | - ->will($this->returnValue(json_encode($nav_system))); |
|
| 73 | + ->method('getAppValue') |
|
| 74 | + ->with('order') |
|
| 75 | + ->will($this->returnValue(json_encode($nav_system))); |
|
| 76 | 76 | $this->service->expects($this->once()) |
| 77 | - ->method('getUserValue') |
|
| 78 | - ->with('order', $this->userId) |
|
| 79 | - ->will($this->returnValue(json_encode($nav_user))); |
|
| 77 | + ->method('getUserValue') |
|
| 78 | + ->with('order', $this->userId) |
|
| 79 | + ->will($this->returnValue(json_encode($nav_user))); |
|
| 80 | 80 | $result = $this->util->getAppOrder(); |
| 81 | 81 | $this->assertEquals(json_encode($nav_user), $result); |
| 82 | - } |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - public function testGetAppOrderNoUser() { |
|
| 84 | + public function testGetAppOrderNoUser() { |
|
| 85 | 85 | $nav_system = ['/app/calendar/', '/app/tasks/']; |
| 86 | 86 | $nav_user = ''; |
| 87 | 87 | $this->service->expects($this->once()) |
| 88 | - ->method('getAppValue') |
|
| 89 | - ->with('order') |
|
| 90 | - ->will($this->returnValue(json_encode($nav_system))); |
|
| 88 | + ->method('getAppValue') |
|
| 89 | + ->with('order') |
|
| 90 | + ->will($this->returnValue(json_encode($nav_system))); |
|
| 91 | 91 | $this->service->expects($this->once()) |
| 92 | - ->method('getUserValue') |
|
| 93 | - ->with('order', $this->userId) |
|
| 94 | - ->will($this->returnValue($nav_user)); |
|
| 92 | + ->method('getUserValue') |
|
| 93 | + ->with('order', $this->userId) |
|
| 94 | + ->will($this->returnValue($nav_user)); |
|
| 95 | 95 | $result = $this->util->getAppOrder(); |
| 96 | 96 | $this->assertEquals(json_encode($nav_system), $result); |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | } |
@@ -11,107 +11,107 @@ |
||
| 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 \OCA\AppOrder\AppInfo\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 | |
| 41 | 41 | $this->userId = 'admin'; |
| 42 | 42 | $this->appName = 'apporder'; |
| 43 | - $this->util = new \OCA\AppOrder\Util($this->service, $this->userId); |
|
| 43 | + $this->util = new \OCA\AppOrder\Util($this->service, $this->userId); |
|
| 44 | 44 | $this->controller = new \OCA\AppOrder\Controller\SettingsController( |
| 45 | - $this->appName, $this->request, $this->service, $this->navigationManager, $this->util, |
|
| 46 | - $this->userId |
|
| 45 | + $this->appName, $this->request, $this->service, $this->navigationManager, $this->util, |
|
| 46 | + $this->userId |
|
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public function testAdminIndex() { |
|
| 51 | + public function testAdminIndex() { |
|
| 52 | 52 | $nav_custom = ['/app/calendar/', '/app/tasks/']; |
| 53 | 53 | $nav_oc = [ |
| 54 | - ['href' => '/app/files/', 'name' => 'Files'], |
|
| 55 | - ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 56 | - ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 54 | + ['href' => '/app/files/', 'name' => 'Files'], |
|
| 55 | + ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 56 | + ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 57 | 57 | ]; |
| 58 | 58 | $nav_final = [ |
| 59 | - '/app/calendar/' => $nav_oc[1], '/app/tasks/' => $nav_oc[2], '/app/files/' => $nav_oc[0] |
|
| 60 | - ]; |
|
| 59 | + '/app/calendar/' => $nav_oc[1], '/app/tasks/' => $nav_oc[2], '/app/files/' => $nav_oc[0] |
|
| 60 | + ]; |
|
| 61 | 61 | $this->service->expects($this->once()) |
| 62 | - ->method('getAppValue') |
|
| 63 | - ->with('order') |
|
| 64 | - ->will($this->returnValue(json_encode($nav_custom))); |
|
| 62 | + ->method('getAppValue') |
|
| 63 | + ->with('order') |
|
| 64 | + ->will($this->returnValue(json_encode($nav_custom))); |
|
| 65 | 65 | $this->navigationManager->expects($this->once()) |
| 66 | - ->method('getAll') |
|
| 67 | - ->will($this->returnValue($nav_oc)); |
|
| 66 | + ->method('getAll') |
|
| 67 | + ->will($this->returnValue($nav_oc)); |
|
| 68 | 68 | |
| 69 | 69 | $result = $this->controller->adminIndex(); |
| 70 | 70 | $expected = new \OCP\AppFramework\Http\TemplateResponse( |
| 71 | - $this->appName, |
|
| 72 | - 'admin', |
|
| 73 | - ["nav" => $nav_final], |
|
| 74 | - 'blank' |
|
| 71 | + $this->appName, |
|
| 72 | + 'admin', |
|
| 73 | + ["nav" => $nav_final], |
|
| 74 | + 'blank' |
|
| 75 | 75 | ); |
| 76 | 76 | $this->assertEquals($expected, $result); |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | |
| 80 | - public function testGetOrder() { |
|
| 80 | + public function testGetOrder() { |
|
| 81 | 81 | $nav_system = ['/app/calendar/', '/app/tasks/']; |
| 82 | 82 | $nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/']; |
| 83 | 83 | $this->service->expects($this->once()) |
| 84 | - ->method('getAppValue') |
|
| 85 | - ->with('order') |
|
| 86 | - ->will($this->returnValue(json_encode($nav_system))); |
|
| 84 | + ->method('getAppValue') |
|
| 85 | + ->with('order') |
|
| 86 | + ->will($this->returnValue(json_encode($nav_system))); |
|
| 87 | 87 | $this->service->expects($this->once()) |
| 88 | - ->method('getUserValue') |
|
| 89 | - ->with('order', $this->userId) |
|
| 90 | - ->will($this->returnValue(json_encode($nav_user))); |
|
| 88 | + ->method('getUserValue') |
|
| 89 | + ->with('order', $this->userId) |
|
| 90 | + ->will($this->returnValue(json_encode($nav_user))); |
|
| 91 | 91 | $order = ['/app/files/', '/app/calendar/', '/app/tasks/']; |
| 92 | 92 | $result = $this->controller->getOrder(); |
| 93 | 93 | $expected = array('status' => 'success', 'order' => json_encode($order)); |
| 94 | 94 | $this->assertEquals($expected, $result); |
| 95 | - } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - public function testSavePersonal() { |
|
| 97 | + public function testSavePersonal() { |
|
| 98 | 98 | $order = "RANDOMORDER"; |
| 99 | 99 | $expected = array( |
| 100 | - 'status' => 'success', |
|
| 101 | - 'data' => array('message'=> 'User order saved successfully.'), |
|
| 102 | - 'order' => $order |
|
| 100 | + 'status' => 'success', |
|
| 101 | + 'data' => array('message'=> 'User order saved successfully.'), |
|
| 102 | + 'order' => $order |
|
| 103 | 103 | ); |
| 104 | 104 | $result = $this->controller->savePersonal($order); |
| 105 | 105 | $this->assertEquals($expected, $result); |
| 106 | - } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - public function testSaveDefaultOrder() { |
|
| 108 | + public function testSaveDefaultOrder() { |
|
| 109 | 109 | $order = "RANDOMORDER"; |
| 110 | 110 | $expected = array( |
| 111 | - 'status' => 'success', |
|
| 112 | - 'order' => $order |
|
| 111 | + 'status' => 'success', |
|
| 112 | + 'order' => $order |
|
| 113 | 113 | ); |
| 114 | 114 | $result = $this->controller->saveDefaultOrder($order); |
| 115 | 115 | $this->assertEquals($expected, $result); |
| 116 | - } |
|
| 116 | + } |
|
| 117 | 117 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | |
| 28 | 28 | require_once __DIR__.'/../../../lib/base.php'; |
| 29 | 29 | if(!class_exists('PHPUnit_Framework_TestCase')) { |
| 30 | - require_once('PHPUnit/Autoload.php'); |
|
| 30 | + require_once('PHPUnit/Autoload.php'); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | \OC_App::loadApp('apporder'); |
@@ -21,12 +21,12 @@ |
||
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -require_once __DIR__ . '/../../../tests/bootstrap.php'; |
|
| 25 | -require_once __DIR__ . '/../appinfo/autoload.php'; |
|
| 24 | +require_once __DIR__.'/../../../tests/bootstrap.php'; |
|
| 25 | +require_once __DIR__.'/../appinfo/autoload.php'; |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | require_once __DIR__.'/../../../lib/base.php'; |
| 29 | -if(!class_exists('PHPUnit_Framework_TestCase')) { |
|
| 29 | +if (!class_exists('PHPUnit_Framework_TestCase')) { |
|
| 30 | 30 | require_once('PHPUnit/Autoload.php'); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -33,66 +33,66 @@ |
||
| 33 | 33 | |
| 34 | 34 | class AppControllerTest extends \Test\TestCase { |
| 35 | 35 | |
| 36 | - private $container; |
|
| 37 | - private $request; |
|
| 38 | - private $service; |
|
| 39 | - private $urlGenerator; |
|
| 40 | - private $userId; |
|
| 41 | - private $appName; |
|
| 42 | - /** |
|
| 43 | - * @var AppController |
|
| 44 | - */ |
|
| 45 | - private $controller; |
|
| 46 | - private $config; |
|
| 47 | - private $util; |
|
| 36 | + private $container; |
|
| 37 | + private $request; |
|
| 38 | + private $service; |
|
| 39 | + private $urlGenerator; |
|
| 40 | + private $userId; |
|
| 41 | + private $appName; |
|
| 42 | + /** |
|
| 43 | + * @var AppController |
|
| 44 | + */ |
|
| 45 | + private $controller; |
|
| 46 | + private $config; |
|
| 47 | + private $util; |
|
| 48 | 48 | |
| 49 | - public function setUp() { |
|
| 49 | + public function setUp() { |
|
| 50 | 50 | |
| 51 | - parent::setUp(); |
|
| 51 | + parent::setUp(); |
|
| 52 | 52 | |
| 53 | - $app = new \OCA\AppOrder\AppInfo\Application(); |
|
| 54 | - $this->container = $app->getContainer(); |
|
| 55 | - $this->request = $this->getMockBuilder('OCP\IRequest') |
|
| 56 | - ->disableOriginalConstructor() |
|
| 57 | - ->getMock(); |
|
| 58 | - $this->config = $this->getMockBuilder('OCP\IConfig') |
|
| 59 | - ->disableOriginalConstructor() |
|
| 60 | - ->getMock(); |
|
| 61 | - $this->service = $this->getMockBuilder('\OCA\AppOrder\Service\ConfigService') |
|
| 62 | - ->disableOriginalConstructor() |
|
| 63 | - ->getMock(); |
|
| 64 | - $this->urlGenerator = \OC::$server->getURLGenerator(); |
|
| 65 | - $this->util = $this->getMockBuilder('\OCA\AppOrder\Util')->disableOriginalConstructor()->getMock(); |
|
| 53 | + $app = new \OCA\AppOrder\AppInfo\Application(); |
|
| 54 | + $this->container = $app->getContainer(); |
|
| 55 | + $this->request = $this->getMockBuilder('OCP\IRequest') |
|
| 56 | + ->disableOriginalConstructor() |
|
| 57 | + ->getMock(); |
|
| 58 | + $this->config = $this->getMockBuilder('OCP\IConfig') |
|
| 59 | + ->disableOriginalConstructor() |
|
| 60 | + ->getMock(); |
|
| 61 | + $this->service = $this->getMockBuilder('\OCA\AppOrder\Service\ConfigService') |
|
| 62 | + ->disableOriginalConstructor() |
|
| 63 | + ->getMock(); |
|
| 64 | + $this->urlGenerator = \OC::$server->getURLGenerator(); |
|
| 65 | + $this->util = $this->getMockBuilder('\OCA\AppOrder\Util')->disableOriginalConstructor()->getMock(); |
|
| 66 | 66 | |
| 67 | - $this->userId = 'admin'; |
|
| 68 | - $this->appName = 'apporder'; |
|
| 69 | - $this->controller = new AppController( |
|
| 70 | - $this->appName, $this->request, $this->service, $this->urlGenerator, $this->util, |
|
| 71 | - $this->userId |
|
| 72 | - ); |
|
| 67 | + $this->userId = 'admin'; |
|
| 68 | + $this->appName = 'apporder'; |
|
| 69 | + $this->controller = new AppController( |
|
| 70 | + $this->appName, $this->request, $this->service, $this->urlGenerator, $this->util, |
|
| 71 | + $this->userId |
|
| 72 | + ); |
|
| 73 | 73 | |
| 74 | - } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - public function testIndex() { |
|
| 77 | - $this->util->expects($this->once()) |
|
| 78 | - ->method('getAppOrder') |
|
| 79 | - ->willReturn( |
|
| 80 | - json_encode(['/index.php/foo/bar', '/index.php/bar/foo']) |
|
| 81 | - ); |
|
| 82 | - $expected = new Http\RedirectResponse('/index.php/foo/bar'); |
|
| 83 | - $result = $this->controller->index(); |
|
| 84 | - $this->assertEquals($expected, $result); |
|
| 85 | - } |
|
| 76 | + public function testIndex() { |
|
| 77 | + $this->util->expects($this->once()) |
|
| 78 | + ->method('getAppOrder') |
|
| 79 | + ->willReturn( |
|
| 80 | + json_encode(['/index.php/foo/bar', '/index.php/bar/foo']) |
|
| 81 | + ); |
|
| 82 | + $expected = new Http\RedirectResponse('/index.php/foo/bar'); |
|
| 83 | + $result = $this->controller->index(); |
|
| 84 | + $this->assertEquals($expected, $result); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - public function testIndexEmpty() { |
|
| 88 | - $this->util->expects($this->once()) |
|
| 89 | - ->method('getAppOrder') |
|
| 90 | - ->willReturn(""); |
|
| 91 | - $result = $this->controller->index(); |
|
| 87 | + public function testIndexEmpty() { |
|
| 88 | + $this->util->expects($this->once()) |
|
| 89 | + ->method('getAppOrder') |
|
| 90 | + ->willReturn(""); |
|
| 91 | + $result = $this->controller->index(); |
|
| 92 | 92 | |
| 93 | - $expected = new Http\RedirectResponse('http://localhost/index.php/apps/files/'); |
|
| 94 | - $this->assertEquals($expected, $result); |
|
| 95 | - } |
|
| 93 | + $expected = new Http\RedirectResponse('http://localhost/index.php/apps/files/'); |
|
| 94 | + $this->assertEquals($expected, $result); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | } |