diff options
author | Marco Nassabain <marco.nassabain@hotmail.com> | 2021-02-27 15:26:11 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-04-08 22:31:21 +0200 |
commit | 46cc0698637f34136365de017efd7ba5e8d7b441 (patch) | |
tree | 714662a847c3701734d29eb5f43e18d07bd9fc1f /tests | |
parent | ceefee0d3e070023e6d7d3aac6427d994b77bd9b (diff) |
✅ ItemControllerTest: added share tests (WIP)
- testIndexForShared
- testNewItemShared
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Unit/Controller/ItemControllerTest.php | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php index b2f833868..a9f43e95c 100644 --- a/tests/Unit/Controller/ItemControllerTest.php +++ b/tests/Unit/Controller/ItemControllerTest.php @@ -339,6 +339,50 @@ class ItemControllerTest extends TestCase } + public function testIndexForShared() + { + $feeds = [new Feed()]; + $result = [ + 'items' => [new Item()], + 'feeds' => $feeds, + 'newestItemId' => $this->newestItemId, + 'starred' => 3, + // 'shared' => 99 // TODO: uncomment when implemented + ]; + + $this->itemsApiExpects(2, ListType::SHARED, '0'); + + $this->feedService->expects($this->once()) + ->method('findAllForUser') + ->with('user') + ->will($this->returnValue($feeds)); + + $this->itemService->expects($this->once()) + ->method('newest') + ->with('user') + ->will($this->returnValue(Item::fromParams(['id' => $this->newestItemId]))); + + $this->itemService->expects($this->once()) + ->method('starred') + ->with('user') + ->will($this->returnValue([1, 2, 3])); + + // TODO: uncomment when implemented + // $this->itemService->expects($this->once()) + // ->method('shared') + // ->with($this->equalTo($this->user)) + // ->will($this->returnValue($result['shared'])); + + $this->itemService->expects($this->once()) + ->method('findAllSharedWithUserWithFilters') + ->with('user', 3, 0, false, false, []) + ->will($this->returnValue($result['items'])); + + $response = $this->controller->index(ListType::SHARED, 2, 3); + $this->assertEquals($result, $response); + } + + public function testIndexForOther() { $feeds = [new Feed()]; @@ -533,6 +577,53 @@ class ItemControllerTest extends TestCase } + public function testNewItemsShared() + { + $feeds = [new Feed()]; + $result = [ + 'items' => [new Item()], + 'feeds' => $feeds, + 'newestItemId' => $this->newestItemId, + 'starred' => 3, + // 'shared' => 99 // TODO: uncomment when implemented + ]; + + $this->settings->expects($this->once()) + ->method('getUserValue') + ->with('user', $this->appName, 'showAll') + ->will($this->returnValue('1')); + + $this->feedService->expects($this->once()) + ->method('findAllForUser') + ->with('user') + ->will($this->returnValue($feeds)); + + $this->itemService->expects($this->once()) + ->method('newest') + ->with('user') + ->will($this->returnValue(Item::fromParams(['id' => $this->newestItemId]))); + + $this->itemService->expects($this->once()) + ->method('starred') + ->with('user') + ->will($this->returnValue([1, 2, 3])); + + // TODO: uncomment when implemented + // $this->itemService->expects($this->once()) + // ->method('shared') + // ->with($this->equalTo($this->user)) + // ->will($this->returnValue($result['shared'])); + + $this->itemService->expects($this->once()) + ->method('findAllSharedAfter') + ->with('user', 3, false) + ->will($this->returnValue($result['items'])); + + $response = $this->controller->newItems(ListType::SHARED, 2, 3); + $this->assertEquals($result, $response); + } + + public function testNewItemsOther() { $feeds = [new Feed()]; |