@@ -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 | } |