From 46cc0698637f34136365de017efd7ba5e8d7b441 Mon Sep 17 00:00:00 2001 From: Marco Nassabain Date: Sat, 27 Feb 2021 15:26:11 +0100 Subject: =?UTF-8?q?=E2=9C=85=20ItemControllerTest:=20added=20share=20tests?= =?UTF-8?q?=20(WIP)=20-=20testIndexForShared=20-=20testNewItemShared?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marco Nassabain --- tests/Unit/Controller/ItemControllerTest.php | 91 ++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) (limited to 'tests') 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()]; -- cgit v1.2.3