@@ -32,118 +32,118 @@ |
||
| 32 | 32 | |
| 33 | 33 | class SettingsControllerTest extends \PHPUnit_Framework_TestCase { |
| 34 | 34 | |
| 35 | - /** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 36 | - private $request; |
|
| 37 | - /** @var ConfigService|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 38 | - private $service; |
|
| 39 | - /** @var INavigationManager|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 40 | - private $navigationManager; |
|
| 41 | - /** @var string */ |
|
| 42 | - private $userId; |
|
| 43 | - /** @var string */ |
|
| 44 | - private $appName; |
|
| 45 | - /** @var SettingsController */ |
|
| 46 | - private $controller; |
|
| 47 | - /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 48 | - private $config; |
|
| 49 | - /** @var Util */ |
|
| 50 | - private $util; |
|
| 35 | + /** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 36 | + private $request; |
|
| 37 | + /** @var ConfigService|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 38 | + private $service; |
|
| 39 | + /** @var INavigationManager|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 40 | + private $navigationManager; |
|
| 41 | + /** @var string */ |
|
| 42 | + private $userId; |
|
| 43 | + /** @var string */ |
|
| 44 | + private $appName; |
|
| 45 | + /** @var SettingsController */ |
|
| 46 | + private $controller; |
|
| 47 | + /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 48 | + private $config; |
|
| 49 | + /** @var Util */ |
|
| 50 | + private $util; |
|
| 51 | 51 | |
| 52 | - public function setUp() { |
|
| 52 | + public function setUp() { |
|
| 53 | 53 | |
| 54 | - parent::setUp(); |
|
| 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->navigationManager = $this->getMockBuilder('\OCP\INavigationManager') |
|
| 65 | - ->setMethods(['getAll', 'add', 'setActiveEntry']) |
|
| 66 | - ->disableOriginalConstructor() |
|
| 67 | - ->getMock(); |
|
| 54 | + parent::setUp(); |
|
| 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->navigationManager = $this->getMockBuilder('\OCP\INavigationManager') |
|
| 65 | + ->setMethods(['getAll', 'add', 'setActiveEntry']) |
|
| 66 | + ->disableOriginalConstructor() |
|
| 67 | + ->getMock(); |
|
| 68 | 68 | |
| 69 | - $this->userId = 'admin'; |
|
| 70 | - $this->appName = 'apporder'; |
|
| 71 | - $this->util = new Util($this->service, $this->userId); |
|
| 72 | - $this->controller = new SettingsController( |
|
| 73 | - $this->appName, |
|
| 74 | - $this->request, |
|
| 75 | - $this->service, |
|
| 76 | - $this->navigationManager, |
|
| 77 | - $this->util, |
|
| 78 | - $this->userId |
|
| 79 | - ); |
|
| 69 | + $this->userId = 'admin'; |
|
| 70 | + $this->appName = 'apporder'; |
|
| 71 | + $this->util = new Util($this->service, $this->userId); |
|
| 72 | + $this->controller = new SettingsController( |
|
| 73 | + $this->appName, |
|
| 74 | + $this->request, |
|
| 75 | + $this->service, |
|
| 76 | + $this->navigationManager, |
|
| 77 | + $this->util, |
|
| 78 | + $this->userId |
|
| 79 | + ); |
|
| 80 | 80 | |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - public function testAdminIndex() { |
|
| 84 | - $nav_custom = ['/app/calendar/', '/app/tasks/']; |
|
| 85 | - $nav_oc = [ |
|
| 86 | - ['href' => '/app/files/', 'name' => 'Files'], |
|
| 87 | - ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 88 | - ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 89 | - ]; |
|
| 90 | - $nav_final = [ |
|
| 91 | - '/app/calendar/' => $nav_oc[1], '/app/tasks/' => $nav_oc[2], '/app/files/' => $nav_oc[0] |
|
| 92 | - ]; |
|
| 93 | - $this->service->expects($this->once()) |
|
| 94 | - ->method('getAppValue') |
|
| 95 | - ->with('order') |
|
| 96 | - ->will($this->returnValue(json_encode($nav_custom))); |
|
| 97 | - $this->navigationManager->expects($this->once()) |
|
| 98 | - ->method('getAll') |
|
| 99 | - ->will($this->returnValue($nav_oc)); |
|
| 83 | + public function testAdminIndex() { |
|
| 84 | + $nav_custom = ['/app/calendar/', '/app/tasks/']; |
|
| 85 | + $nav_oc = [ |
|
| 86 | + ['href' => '/app/files/', 'name' => 'Files'], |
|
| 87 | + ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 88 | + ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 89 | + ]; |
|
| 90 | + $nav_final = [ |
|
| 91 | + '/app/calendar/' => $nav_oc[1], '/app/tasks/' => $nav_oc[2], '/app/files/' => $nav_oc[0] |
|
| 92 | + ]; |
|
| 93 | + $this->service->expects($this->once()) |
|
| 94 | + ->method('getAppValue') |
|
| 95 | + ->with('order') |
|
| 96 | + ->will($this->returnValue(json_encode($nav_custom))); |
|
| 97 | + $this->navigationManager->expects($this->once()) |
|
| 98 | + ->method('getAll') |
|
| 99 | + ->will($this->returnValue($nav_oc)); |
|
| 100 | 100 | |
| 101 | - $result = $this->controller->adminIndex(); |
|
| 102 | - $expected = new \OCP\AppFramework\Http\TemplateResponse( |
|
| 103 | - $this->appName, |
|
| 104 | - 'admin', |
|
| 105 | - ["nav" => $nav_final], |
|
| 106 | - 'blank' |
|
| 107 | - ); |
|
| 108 | - $this->assertEquals($expected, $result); |
|
| 109 | - } |
|
| 101 | + $result = $this->controller->adminIndex(); |
|
| 102 | + $expected = new \OCP\AppFramework\Http\TemplateResponse( |
|
| 103 | + $this->appName, |
|
| 104 | + 'admin', |
|
| 105 | + ["nav" => $nav_final], |
|
| 106 | + 'blank' |
|
| 107 | + ); |
|
| 108 | + $this->assertEquals($expected, $result); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | - public function testGetOrder() { |
|
| 113 | - $nav_system = ['/app/calendar/', '/app/tasks/']; |
|
| 114 | - $nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/']; |
|
| 115 | - $this->service->expects($this->once()) |
|
| 116 | - ->method('getAppValue') |
|
| 117 | - ->with('order') |
|
| 118 | - ->will($this->returnValue(json_encode($nav_system))); |
|
| 119 | - $this->service->expects($this->once()) |
|
| 120 | - ->method('getUserValue') |
|
| 121 | - ->with('order', $this->userId) |
|
| 122 | - ->will($this->returnValue(json_encode($nav_user))); |
|
| 123 | - $order = ['/app/files/', '/app/calendar/', '/app/tasks/']; |
|
| 124 | - $result = $this->controller->getOrder(); |
|
| 125 | - $expected = array('status' => 'success', 'order' => json_encode($order)); |
|
| 126 | - $this->assertEquals($expected, $result); |
|
| 127 | - } |
|
| 112 | + public function testGetOrder() { |
|
| 113 | + $nav_system = ['/app/calendar/', '/app/tasks/']; |
|
| 114 | + $nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/']; |
|
| 115 | + $this->service->expects($this->once()) |
|
| 116 | + ->method('getAppValue') |
|
| 117 | + ->with('order') |
|
| 118 | + ->will($this->returnValue(json_encode($nav_system))); |
|
| 119 | + $this->service->expects($this->once()) |
|
| 120 | + ->method('getUserValue') |
|
| 121 | + ->with('order', $this->userId) |
|
| 122 | + ->will($this->returnValue(json_encode($nav_user))); |
|
| 123 | + $order = ['/app/files/', '/app/calendar/', '/app/tasks/']; |
|
| 124 | + $result = $this->controller->getOrder(); |
|
| 125 | + $expected = array('status' => 'success', 'order' => json_encode($order)); |
|
| 126 | + $this->assertEquals($expected, $result); |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - public function testSavePersonal() { |
|
| 130 | - $order = "RANDOMORDER"; |
|
| 131 | - $expected = array( |
|
| 132 | - 'status' => 'success', |
|
| 133 | - 'data' => array('message' => 'User order saved successfully.'), |
|
| 134 | - 'order' => $order |
|
| 135 | - ); |
|
| 136 | - $result = $this->controller->savePersonal($order); |
|
| 137 | - $this->assertEquals($expected, $result); |
|
| 138 | - } |
|
| 129 | + public function testSavePersonal() { |
|
| 130 | + $order = "RANDOMORDER"; |
|
| 131 | + $expected = array( |
|
| 132 | + 'status' => 'success', |
|
| 133 | + 'data' => array('message' => 'User order saved successfully.'), |
|
| 134 | + 'order' => $order |
|
| 135 | + ); |
|
| 136 | + $result = $this->controller->savePersonal($order); |
|
| 137 | + $this->assertEquals($expected, $result); |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - public function testSaveDefaultOrder() { |
|
| 141 | - $order = "RANDOMORDER"; |
|
| 142 | - $expected = array( |
|
| 143 | - 'status' => 'success', |
|
| 144 | - 'order' => $order |
|
| 145 | - ); |
|
| 146 | - $result = $this->controller->saveDefaultOrder($order); |
|
| 147 | - $this->assertEquals($expected, $result); |
|
| 148 | - } |
|
| 140 | + public function testSaveDefaultOrder() { |
|
| 141 | + $order = "RANDOMORDER"; |
|
| 142 | + $expected = array( |
|
| 143 | + 'status' => 'success', |
|
| 144 | + 'order' => $order |
|
| 145 | + ); |
|
| 146 | + $result = $this->controller->saveDefaultOrder($order); |
|
| 147 | + $this->assertEquals($expected, $result); |
|
| 148 | + } |
|
| 149 | 149 | } |
@@ -32,60 +32,60 @@ |
||
| 32 | 32 | |
| 33 | 33 | class AppControllerTest extends \PHPUnit_Framework_TestCase { |
| 34 | 34 | |
| 35 | - /** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 36 | - private $request; |
|
| 37 | - /** @var IURLGenerator */ |
|
| 38 | - private $urlGenerator; |
|
| 39 | - /** @var string */ |
|
| 40 | - private $userId; |
|
| 41 | - /** @var string */ |
|
| 42 | - private $appName; |
|
| 43 | - /** @var AppController */ |
|
| 44 | - private $controller; |
|
| 45 | - /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 46 | - private $config; |
|
| 47 | - /** @var Util|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 48 | - private $util; |
|
| 35 | + /** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 36 | + private $request; |
|
| 37 | + /** @var IURLGenerator */ |
|
| 38 | + private $urlGenerator; |
|
| 39 | + /** @var string */ |
|
| 40 | + private $userId; |
|
| 41 | + /** @var string */ |
|
| 42 | + private $appName; |
|
| 43 | + /** @var AppController */ |
|
| 44 | + private $controller; |
|
| 45 | + /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 46 | + private $config; |
|
| 47 | + /** @var Util|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 48 | + private $util; |
|
| 49 | 49 | |
| 50 | - public function setUp() { |
|
| 51 | - parent::setUp(); |
|
| 52 | - $this->request = $this->getMockBuilder('OCP\IRequest') |
|
| 53 | - ->disableOriginalConstructor() |
|
| 54 | - ->getMock(); |
|
| 55 | - $this->config = $this->getMockBuilder('OCP\IConfig') |
|
| 56 | - ->disableOriginalConstructor() |
|
| 57 | - ->getMock(); |
|
| 58 | - $this->util = $this->getMockBuilder('\OCA\AppOrder\Util') |
|
| 59 | - ->disableOriginalConstructor() |
|
| 60 | - ->getMock(); |
|
| 61 | - $this->urlGenerator = \OC::$server->getURLGenerator(); |
|
| 62 | - $this->userId = 'admin'; |
|
| 63 | - $this->appName = 'apporder'; |
|
| 64 | - $this->controller = new AppController( |
|
| 65 | - $this->appName, |
|
| 66 | - $this->request, |
|
| 67 | - $this->urlGenerator, |
|
| 68 | - $this->util, |
|
| 69 | - $this->userId |
|
| 70 | - ); |
|
| 71 | - } |
|
| 50 | + public function setUp() { |
|
| 51 | + parent::setUp(); |
|
| 52 | + $this->request = $this->getMockBuilder('OCP\IRequest') |
|
| 53 | + ->disableOriginalConstructor() |
|
| 54 | + ->getMock(); |
|
| 55 | + $this->config = $this->getMockBuilder('OCP\IConfig') |
|
| 56 | + ->disableOriginalConstructor() |
|
| 57 | + ->getMock(); |
|
| 58 | + $this->util = $this->getMockBuilder('\OCA\AppOrder\Util') |
|
| 59 | + ->disableOriginalConstructor() |
|
| 60 | + ->getMock(); |
|
| 61 | + $this->urlGenerator = \OC::$server->getURLGenerator(); |
|
| 62 | + $this->userId = 'admin'; |
|
| 63 | + $this->appName = 'apporder'; |
|
| 64 | + $this->controller = new AppController( |
|
| 65 | + $this->appName, |
|
| 66 | + $this->request, |
|
| 67 | + $this->urlGenerator, |
|
| 68 | + $this->util, |
|
| 69 | + $this->userId |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - public function testIndex() { |
|
| 74 | - $this->util->expects($this->once()) |
|
| 75 | - ->method('getAppOrder') |
|
| 76 | - ->willReturn(json_encode(['/index.php/foo/bar', '/index.php/bar/foo'])); |
|
| 77 | - $expected = new Http\RedirectResponse('/index.php/foo/bar'); |
|
| 78 | - $result = $this->controller->index(); |
|
| 79 | - $this->assertEquals($expected, $result); |
|
| 80 | - } |
|
| 73 | + public function testIndex() { |
|
| 74 | + $this->util->expects($this->once()) |
|
| 75 | + ->method('getAppOrder') |
|
| 76 | + ->willReturn(json_encode(['/index.php/foo/bar', '/index.php/bar/foo'])); |
|
| 77 | + $expected = new Http\RedirectResponse('/index.php/foo/bar'); |
|
| 78 | + $result = $this->controller->index(); |
|
| 79 | + $this->assertEquals($expected, $result); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - public function testIndexEmpty() { |
|
| 83 | - $this->util->expects($this->once()) |
|
| 84 | - ->method('getAppOrder') |
|
| 85 | - ->willReturn(""); |
|
| 86 | - $result = $this->controller->index(); |
|
| 87 | - $expected = new Http\RedirectResponse('http://localhost/index.php/apps/files/'); |
|
| 88 | - $this->assertEquals($expected, $result); |
|
| 89 | - } |
|
| 82 | + public function testIndexEmpty() { |
|
| 83 | + $this->util->expects($this->once()) |
|
| 84 | + ->method('getAppOrder') |
|
| 85 | + ->willReturn(""); |
|
| 86 | + $result = $this->controller->index(); |
|
| 87 | + $expected = new Http\RedirectResponse('http://localhost/index.php/apps/files/'); |
|
| 88 | + $this->assertEquals($expected, $result); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | 91 | } |
@@ -28,34 +28,34 @@ |
||
| 28 | 28 | |
| 29 | 29 | class ConfigServiceTest extends \PHPUnit_Framework_TestCase { |
| 30 | 30 | |
| 31 | - /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 32 | - private $config; |
|
| 33 | - /** @var ConfigService */ |
|
| 34 | - private $service; |
|
| 35 | - |
|
| 36 | - public function setUp() { |
|
| 37 | - $this->config = $this->getMockBuilder('\OCP\IConfig') |
|
| 38 | - ->disableOriginalConstructor()->getMock(); |
|
| 39 | - $this->service = new ConfigService($this->config, 'apporder'); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - public function testAppValue() { |
|
| 43 | - $this->config->expects($this->any()) |
|
| 44 | - ->method('getAppValue') |
|
| 45 | - ->with('apporder', 'foo') |
|
| 46 | - ->willReturn('bar'); |
|
| 47 | - $result = $this->service->getAppValue("foo"); |
|
| 48 | - $this->assertEquals('bar', $result); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function testUserValue() { |
|
| 52 | - $this->config->expects($this->any()) |
|
| 53 | - ->method('getUserValue') |
|
| 54 | - ->with('user', 'apporder', 'foo') |
|
| 55 | - ->willReturn('bar'); |
|
| 56 | - $this->service->setUserValue("foo", "user", "bar"); |
|
| 57 | - $result = $this->service->getUserValue("foo", "user"); |
|
| 58 | - $this->assertEquals('bar', $result); |
|
| 59 | - } |
|
| 31 | + /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 32 | + private $config; |
|
| 33 | + /** @var ConfigService */ |
|
| 34 | + private $service; |
|
| 35 | + |
|
| 36 | + public function setUp() { |
|
| 37 | + $this->config = $this->getMockBuilder('\OCP\IConfig') |
|
| 38 | + ->disableOriginalConstructor()->getMock(); |
|
| 39 | + $this->service = new ConfigService($this->config, 'apporder'); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + public function testAppValue() { |
|
| 43 | + $this->config->expects($this->any()) |
|
| 44 | + ->method('getAppValue') |
|
| 45 | + ->with('apporder', 'foo') |
|
| 46 | + ->willReturn('bar'); |
|
| 47 | + $result = $this->service->getAppValue("foo"); |
|
| 48 | + $this->assertEquals('bar', $result); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public function testUserValue() { |
|
| 52 | + $this->config->expects($this->any()) |
|
| 53 | + ->method('getUserValue') |
|
| 54 | + ->with('user', 'apporder', 'foo') |
|
| 55 | + ->willReturn('bar'); |
|
| 56 | + $this->service->setUserValue("foo", "user", "bar"); |
|
| 57 | + $result = $this->service->getUserValue("foo", "user"); |
|
| 58 | + $this->assertEquals('bar', $result); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | 61 | } |
@@ -28,74 +28,74 @@ |
||
| 28 | 28 | |
| 29 | 29 | class UtilTest extends \PHPUnit_Framework_TestCase { |
| 30 | 30 | |
| 31 | - /** @var ConfigService|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 32 | - private $service; |
|
| 33 | - /** @var string */ |
|
| 34 | - private $userId; |
|
| 35 | - /** @var Util */ |
|
| 36 | - private $util; |
|
| 37 | - /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 38 | - private $config; |
|
| 31 | + /** @var ConfigService|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 32 | + private $service; |
|
| 33 | + /** @var string */ |
|
| 34 | + private $userId; |
|
| 35 | + /** @var Util */ |
|
| 36 | + private $util; |
|
| 37 | + /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ |
|
| 38 | + private $config; |
|
| 39 | 39 | |
| 40 | - public function setUp() { |
|
| 40 | + public function setUp() { |
|
| 41 | 41 | |
| 42 | - parent::setUp(); |
|
| 42 | + parent::setUp(); |
|
| 43 | 43 | |
| 44 | - $this->config = $this->getMockBuilder('OCP\IConfig') |
|
| 45 | - ->disableOriginalConstructor() |
|
| 46 | - ->getMock(); |
|
| 47 | - $this->service = $this->getMockBuilder('\OCA\AppOrder\Service\ConfigService') |
|
| 48 | - ->disableOriginalConstructor() |
|
| 49 | - ->getMock(); |
|
| 50 | - $this->userId = 'admin'; |
|
| 51 | - $this->util = new Util($this->service, $this->userId); |
|
| 44 | + $this->config = $this->getMockBuilder('OCP\IConfig') |
|
| 45 | + ->disableOriginalConstructor() |
|
| 46 | + ->getMock(); |
|
| 47 | + $this->service = $this->getMockBuilder('\OCA\AppOrder\Service\ConfigService') |
|
| 48 | + ->disableOriginalConstructor() |
|
| 49 | + ->getMock(); |
|
| 50 | + $this->userId = 'admin'; |
|
| 51 | + $this->util = new Util($this->service, $this->userId); |
|
| 52 | 52 | |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function testMatchOrder() { |
|
| 56 | - $nav = [ |
|
| 57 | - ['href' => '/app/files/', 'name' => 'Files'], |
|
| 58 | - ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 59 | - ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 60 | - ]; |
|
| 61 | - $order = ['/app/calendar/', '/app/tasks/']; |
|
| 62 | - $result = $this->util->matchOrder($nav, $order); |
|
| 63 | - $expected = [ |
|
| 64 | - '/app/calendar/' => ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 65 | - '/app/tasks/' => ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 66 | - '/app/files/' => ['href' => '/app/files/', 'name' => 'Files'], |
|
| 67 | - ]; |
|
| 68 | - $this->assertEquals($expected, $result); |
|
| 69 | - } |
|
| 55 | + public function testMatchOrder() { |
|
| 56 | + $nav = [ |
|
| 57 | + ['href' => '/app/files/', 'name' => 'Files'], |
|
| 58 | + ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 59 | + ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 60 | + ]; |
|
| 61 | + $order = ['/app/calendar/', '/app/tasks/']; |
|
| 62 | + $result = $this->util->matchOrder($nav, $order); |
|
| 63 | + $expected = [ |
|
| 64 | + '/app/calendar/' => ['href' => '/app/calendar/', 'name' => 'Calendar'], |
|
| 65 | + '/app/tasks/' => ['href' => '/app/tasks/', 'name' => 'Tasks'], |
|
| 66 | + '/app/files/' => ['href' => '/app/files/', 'name' => 'Files'], |
|
| 67 | + ]; |
|
| 68 | + $this->assertEquals($expected, $result); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - public function testGetAppOrder() { |
|
| 72 | - $nav_system = ['/app/calendar/', '/app/tasks/']; |
|
| 73 | - $nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/']; |
|
| 74 | - $this->service->expects($this->once()) |
|
| 75 | - ->method('getAppValue') |
|
| 76 | - ->with('order') |
|
| 77 | - ->will($this->returnValue(json_encode($nav_system))); |
|
| 78 | - $this->service->expects($this->once()) |
|
| 79 | - ->method('getUserValue') |
|
| 80 | - ->with('order', $this->userId) |
|
| 81 | - ->will($this->returnValue(json_encode($nav_user))); |
|
| 82 | - $result = $this->util->getAppOrder(); |
|
| 83 | - $this->assertEquals(json_encode($nav_user), $result); |
|
| 84 | - } |
|
| 71 | + public function testGetAppOrder() { |
|
| 72 | + $nav_system = ['/app/calendar/', '/app/tasks/']; |
|
| 73 | + $nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/']; |
|
| 74 | + $this->service->expects($this->once()) |
|
| 75 | + ->method('getAppValue') |
|
| 76 | + ->with('order') |
|
| 77 | + ->will($this->returnValue(json_encode($nav_system))); |
|
| 78 | + $this->service->expects($this->once()) |
|
| 79 | + ->method('getUserValue') |
|
| 80 | + ->with('order', $this->userId) |
|
| 81 | + ->will($this->returnValue(json_encode($nav_user))); |
|
| 82 | + $result = $this->util->getAppOrder(); |
|
| 83 | + $this->assertEquals(json_encode($nav_user), $result); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public function testGetAppOrderNoUser() { |
|
| 87 | - $nav_system = ['/app/calendar/', '/app/tasks/']; |
|
| 88 | - $nav_user = ''; |
|
| 89 | - $this->service->expects($this->once()) |
|
| 90 | - ->method('getAppValue') |
|
| 91 | - ->with('order') |
|
| 92 | - ->will($this->returnValue(json_encode($nav_system))); |
|
| 93 | - $this->service->expects($this->once()) |
|
| 94 | - ->method('getUserValue') |
|
| 95 | - ->with('order', $this->userId) |
|
| 96 | - ->will($this->returnValue($nav_user)); |
|
| 97 | - $result = $this->util->getAppOrder(); |
|
| 98 | - $this->assertEquals(json_encode($nav_system), $result); |
|
| 99 | - } |
|
| 86 | + public function testGetAppOrderNoUser() { |
|
| 87 | + $nav_system = ['/app/calendar/', '/app/tasks/']; |
|
| 88 | + $nav_user = ''; |
|
| 89 | + $this->service->expects($this->once()) |
|
| 90 | + ->method('getAppValue') |
|
| 91 | + ->with('order') |
|
| 92 | + ->will($this->returnValue(json_encode($nav_system))); |
|
| 93 | + $this->service->expects($this->once()) |
|
| 94 | + ->method('getUserValue') |
|
| 95 | + ->with('order', $this->userId) |
|
| 96 | + ->will($this->returnValue($nav_user)); |
|
| 97 | + $result = $this->util->getAppOrder(); |
|
| 98 | + $this->assertEquals(json_encode($nav_system), $result); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | } |