diff options
author | Nick Bakkegaard <nickbakkegaard@gmail.com> | 2017-06-30 00:42:04 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2017-08-04 14:24:16 +0300 |
commit | d1ed5c7b99e10dc2d7d09f53fa3b384e2a81edeb (patch) | |
tree | cc25a396db0695c18d1be37819431f29e127cc20 | |
parent | 554733fd2263e01bdafdfdc7640181e663dbbeb0 (diff) |
fix testcases
-rw-r--r-- | tests/unit/controller/SettingsControllerTest.php | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/tests/unit/controller/SettingsControllerTest.php b/tests/unit/controller/SettingsControllerTest.php index 387f9bf..a4964c3 100644 --- a/tests/unit/controller/SettingsControllerTest.php +++ b/tests/unit/controller/SettingsControllerTest.php @@ -90,10 +90,15 @@ class SettingsControllerTest extends \PHPUnit_Framework_TestCase { $nav_final = [ '/app/calendar/' => $nav_oc[1], '/app/tasks/' => $nav_oc[2], '/app/files/' => $nav_oc[0] ]; - $this->service->expects($this->once()) + $hidden = ["/app/calendar/"]; + $this->service->expects($this->at(0)) ->method('getAppValue') ->with('order') ->will($this->returnValue(json_encode($nav_custom))); + $this->service->expects($this->at(1)) + ->method('getAppValue') + ->with('hidden') + ->will($this->returnValue(json_encode($hidden))); $this->navigationManager->expects($this->once()) ->method('getAll') ->will($this->returnValue($nav_oc)); @@ -102,7 +107,7 @@ class SettingsControllerTest extends \PHPUnit_Framework_TestCase { $expected = new \OCP\AppFramework\Http\TemplateResponse( $this->appName, 'admin', - ["nav" => $nav_final, 'type' => 'admin'], + ["nav" => $nav_final, 'type' => 'admin', 'hidden' => $hidden], 'blank' ); $this->assertEquals($expected, $result); @@ -118,10 +123,13 @@ class SettingsControllerTest extends \PHPUnit_Framework_TestCase { $nav_final = [ '/app/calendar/' => $nav_oc[1], '/app/tasks/' => $nav_oc[2], '/app/files/' => $nav_oc[0] ]; - $this->service->expects($this->once()) - ->method('getUserValue') + $hidden = ["/app/calendar/"]; + $this->service->expects($this->at(0))->method('getUserValue') ->with('order', 'admin') ->will($this->returnValue(json_encode($nav_custom))); + $this->service->expects($this->at(1))->method('getUserValue') + ->with('hidden', 'admin') + ->will($this->returnValue(json_encode($hidden))); $this->navigationManager->expects($this->once()) ->method('getAll') ->will($this->returnValue($nav_oc)); @@ -130,7 +138,7 @@ class SettingsControllerTest extends \PHPUnit_Framework_TestCase { $expected = new \OCP\AppFramework\Http\TemplateResponse( $this->appName, 'admin', - ["nav" => $nav_final, 'type' => 'personal'], + ["nav" => $nav_final, 'type' => 'personal', "hidden" => $hidden], 'blank' ); $this->assertEquals($expected, $result); @@ -140,17 +148,37 @@ class SettingsControllerTest extends \PHPUnit_Framework_TestCase { public function testGetOrder() { $nav_system = ['/app/calendar/', '/app/tasks/']; $nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/']; - $this->service->expects($this->once()) + + $hidden_admin = ['/app/calender/']; + $hidden_user = ['/app/files/']; + + $this->service->expects($this->at(0)) + ->method('getUserValue') + ->with('order', $this->userId) + ->will($this->returnValue(json_encode($nav_user))); + + $this->service->expects($this->at(1)) ->method('getAppValue') ->with('order') ->will($this->returnValue(json_encode($nav_system))); - $this->service->expects($this->once()) + + $this->service->expects($this->at(2)) ->method('getUserValue') - ->with('order', $this->userId) - ->will($this->returnValue(json_encode($nav_user))); + ->with('hidden', $this->userId) + ->will($this->returnValue(json_encode($hidden_user))); + + $this->service->expects($this->at(3)) + ->method('getAppValue') + ->with('hidden') + ->will($this->returnValue(json_encode($hidden_admin))); + $order = ['/app/files/', '/app/calendar/', '/app/tasks/']; + $hidden = ['/app/files/']; + $result = $this->controller->getOrder(); - $expected = array('status' => 'success', 'order' => json_encode($order)); + + $expected = array('status' => 'success', 'order' => json_encode($order), 'hidden' => json_encode($hidden)); + $this->assertEquals($expected, $result); } |