diff options
Diffstat (limited to 'tests/Unit/Controller')
-rw-r--r-- | tests/Unit/Controller/ItemControllerTest.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php index db3b5234b..a35df1552 100644 --- a/tests/Unit/Controller/ItemControllerTest.php +++ b/tests/Unit/Controller/ItemControllerTest.php @@ -128,6 +128,43 @@ class ItemControllerTest extends TestCase } + public function testShare() + { + $this->itemService->expects($this->once()) + ->method('checkSharing') + ->with(4, 'bob', 'jackob') + ->will($this->returnValue(0)); + + $this->itemService->expects($this->once()) + ->method('shareItem') + ->with(4, 'bob', 'jackob'); + + $this->controller->share(4, 'bob'); + } + + + public function testShareDoesNotExist() + { + $msg = 'hi'; + + $this->itemService->expects($this->once()) + ->method('checkSharing') + ->with(4, 'bob', 'jackob') + ->will($this->returnValue(0)); + + $this->itemService->expects($this->once()) + ->method('shareItem') + ->with(4, 'bob', 'jackob') + ->will($this->throwException(new ServiceNotFoundException($msg))); + + $response = $this->controller->share(4, 'bob'); + $params = json_decode($response->render(), true); + + $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); + $this->assertEquals($msg, $params['message']); + } + + public function testReadMultiple() { $this->itemService->expects($this->exactly(2)) |