diff options
author | Marco Nassabain <marco.nassabain@hotmail.com> | 2021-02-16 16:31:43 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-04-08 22:31:21 +0200 |
commit | 89d7293e845ee7bcc9b55910c1a0bb30b3c6e5ad (patch) | |
tree | f78b3094697430cb22eb4d328e4ac5dc56fba8b9 /tests/Unit/Controller | |
parent | f9f25ddbd2214abf5b290e881b1f1dbe57342888 (diff) |
✅ Add tests: testFindAllShared, testShare + ...
+ testShareDoesNotExist
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
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)) |