diff options
-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()) |