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 | |
parent | f9f25ddbd2214abf5b290e881b1f1dbe57342888 (diff) |
✅ Add tests: testFindAllShared, testShare + ...
+ testShareDoesNotExist
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Unit/Controller/ItemControllerTest.php | 37 | ||||
-rw-r--r-- | tests/Unit/Service/ItemServiceTest.php | 26 |
2 files changed, 62 insertions, 1 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)) diff --git a/tests/Unit/Service/ItemServiceTest.php b/tests/Unit/Service/ItemServiceTest.php index ce4e927e2..04c89ae28 100644 --- a/tests/Unit/Service/ItemServiceTest.php +++ b/tests/Unit/Service/ItemServiceTest.php @@ -174,7 +174,31 @@ class ItemServiceTest extends TestCase $this->assertEquals(['val'], $result); } - public function testFindAllItems() + + public function testFindAllShared() + { + $type = FeedType::SHARED; + $this->mapper->expects($this->once()) + ->method('findAllShared') + ->with( + $this->equalTo(20), + $this->equalTo(5), + $this->equalTo(true), + $this->equalTo(true), + $this->equalTo('jack'), + $this->equalTo([]) + ) + ->will($this->returnValue(['val'])); + + $result = $this->itemService->findAllItems( + 3, $type, 20, 5, + true, true, 'jack' + ); + $this->assertEquals(['val'], $result); + } + + + public function testFindAll() { $type = ListType::STARRED; $this->mapper->expects($this->once()) |