summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWENDLING NICOLAS <nicolas.wendling2@etu.unistra.fr>2021-02-28 21:38:11 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 22:31:21 +0200
commit376f866a8393609451cfb21ab1c846c670103197 (patch)
tree244eed3b86e41697b6a91b3850b7a79020ca9b42 /tests
parentdd4617d3685fe0db59b8cd82848933fa2a118c5d (diff)
✅ Fix those tests -> ItemControllerTest:
- testIndexForFeed - testIndexForFolder - testIndexForShared - testIndexForOther - testIndexSearchFeed - testNewItemsFeed - testNewItemsFolder - testNewItemsShared - testNewItemsOther Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Controller/ItemControllerTest.php87
1 files changed, 53 insertions, 34 deletions
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);
}