From 376f866a8393609451cfb21ab1c846c670103197 Mon Sep 17 00:00:00 2001 From: WENDLING NICOLAS Date: Sun, 28 Feb 2021 21:38:11 +0100 Subject: =?UTF-8?q?=E2=9C=85=20Fix=20those=20tests=20->=20ItemControllerTe?= =?UTF-8?q?st:=20-=20=20testIndexForFeed=20-=20testIndexForFolder=20-=20te?= =?UTF-8?q?stIndexForShared=20-=20testIndexForOther=20-=20testIndexSearchF?= =?UTF-8?q?eed=20-=20testNewItemsFeed=20-=20testNewItemsFolder=20-=20testN?= =?UTF-8?q?ewItemsShared=20-=20testNewItemsOther?= 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 | 87 +++++++++++++++++----------- 1 file changed, 53 insertions(+), 34 deletions(-) (limited to 'tests') diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php index a9f43e95c..6836cd119 100644 --- a/tests/Unit/Controller/ItemControllerTest.php +++ b/tests/Unit/Controller/ItemControllerTest.php @@ -259,7 +259,7 @@ class ItemControllerTest extends TestCase 'feeds' => $feeds, 'newestItemId' => $this->newestItemId, 'starred' => 3, - // 'shared' => 99 // TODO: uncomment when implement shared + 'shared' => 2 ]; $this->itemsApiExpects(2, ListType::FEED, '0'); @@ -279,11 +279,10 @@ class ItemControllerTest extends TestCase ->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('sharedWithUser') + ->with('user') + ->will($this->returnValue([4, 5])); $this->itemService->expects($this->once()) ->method('findAllInFeedWithFilters') @@ -303,7 +302,7 @@ class ItemControllerTest extends TestCase 'feeds' => $feeds, 'newestItemId' => $this->newestItemId, 'starred' => 3, - // 'shared' => 99 // TODO: uncomment when implemented + 'shared' => 2 ]; $this->itemsApiExpects(2, ListType::FOLDER, '0'); @@ -323,11 +322,10 @@ class ItemControllerTest extends TestCase ->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('sharedWithUser') + ->with('user') + ->will($this->returnValue([0, 1])); $this->itemService->expects($this->once()) ->method('findAllInFolderWithFilters') @@ -347,7 +345,7 @@ class ItemControllerTest extends TestCase 'feeds' => $feeds, 'newestItemId' => $this->newestItemId, 'starred' => 3, - // 'shared' => 99 // TODO: uncomment when implemented + 'shared' => 4 ]; $this->itemsApiExpects(2, ListType::SHARED, '0'); @@ -367,11 +365,10 @@ class ItemControllerTest extends TestCase ->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('sharedWithUser') + ->with('user') + ->will($this->returnValue([1, 2, 3, 4])); $this->itemService->expects($this->once()) ->method('findAllSharedWithUserWithFilters') @@ -390,7 +387,8 @@ class ItemControllerTest extends TestCase 'items' => [new Item()], 'feeds' => $feeds, 'newestItemId' => $this->newestItemId, - 'starred' => 3 + 'starred' => 3, + 'shared' => 4 ]; $this->itemsApiExpects(2, ListType::STARRED, '0'); @@ -415,6 +413,11 @@ class ItemControllerTest extends TestCase ->with('user', 2, 3, 0, false, []) ->will($this->returnValue($result['items'])); + $this->itemService->expects($this->once()) + ->method('sharedWithUser') + ->with('user') + ->will($this->returnValue([1, 2, 3, 4])); + $response = $this->controller->index(ListType::STARRED, 2, 3); $this->assertEquals($result, $response); } @@ -427,7 +430,8 @@ class ItemControllerTest extends TestCase 'items' => [new Item()], 'feeds' => $feeds, 'newestItemId' => $this->newestItemId, - 'starred' => 3 + 'starred' => 3, + 'shared' => 2 ]; $this->itemsApiExpects(2, ListType::FEED, '0'); @@ -452,6 +456,11 @@ class ItemControllerTest extends TestCase ->with('user', 2, 3, 0, false, false, ['test', 'search']) ->will($this->returnValue($result['items'])); + $this->itemService->expects($this->once()) + ->method('sharedWithUser') + ->with('user') + ->will($this->returnValue([1, 2])); + $response = $this->controller->index(ListType::FEED, 2, 3, 0, null, null, 'test%20%20search%20'); $this->assertEquals($result, $response); } @@ -498,7 +507,7 @@ class ItemControllerTest extends TestCase 'feeds' => $feeds, 'newestItemId' => $this->newestItemId, 'starred' => 3, - // 'shared' => 99 // TODO: uncomment when implemented + 'shared' => 3 ]; $this->settings->expects($this->once()) @@ -521,11 +530,10 @@ class ItemControllerTest extends TestCase ->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('sharedWithUser') + ->with('user') + ->will($this->returnValue([1, 2, 3])); $this->itemService->expects($this->once()) ->method('findAllInFeedAfter') @@ -544,7 +552,8 @@ class ItemControllerTest extends TestCase 'items' => [new Item()], 'feeds' => $feeds, 'newestItemId' => $this->newestItemId, - 'starred' => 3 + 'starred' => 3, + 'shared' => 2 ]; $this->settings->expects($this->once()) @@ -572,6 +581,11 @@ class ItemControllerTest extends TestCase ->with('user', 2, 3, false) ->will($this->returnValue($result['items'])); + $this->itemService->expects($this->once()) + ->method('sharedWithUser') + ->with('user') + ->will($this->returnValue([1, 2])); + $response = $this->controller->newItems(ListType::FOLDER, 2, 3); $this->assertEquals($result, $response); } @@ -585,7 +599,7 @@ class ItemControllerTest extends TestCase 'feeds' => $feeds, 'newestItemId' => $this->newestItemId, 'starred' => 3, - // 'shared' => 99 // TODO: uncomment when implemented + 'shared' => 5 ]; $this->settings->expects($this->once()) @@ -608,11 +622,10 @@ class ItemControllerTest extends TestCase ->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('sharedWithUser') + ->with('user') + ->will($this->returnValue([1, 2, 3, 4, 5])); $this->itemService->expects($this->once()) ->method('findAllSharedAfter') @@ -631,7 +644,8 @@ class ItemControllerTest extends TestCase 'items' => [new Item()], 'feeds' => $feeds, 'newestItemId' => $this->newestItemId, - 'starred' => 3 + 'starred' => 3, + 'shared' => 2 ]; $this->settings->expects($this->once()) @@ -659,6 +673,11 @@ class ItemControllerTest extends TestCase ->with('user', 6, 3) ->will($this->returnValue($result['items'])); + $this->itemService->expects($this->once()) + ->method('sharedWithUser') + ->with('user') + ->will($this->returnValue([1, 2])); + $response = $this->controller->newItems(ListType::UNREAD, 2, 3); $this->assertEquals($result, $response); } -- cgit v1.2.3