summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarco Nassabain <marco.nassabain@hotmail.com>2021-03-03 23:01:36 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 22:31:21 +0200
commit2ee5112760d721e441abee4ededfa5484269a3c9 (patch)
tree37b241472c1dbf424acf317a0a86c93bfd54d00b /tests
parent9bd27da9bac99a7780df8eb3845df566fb23b02a (diff)
🔥 Remove old share logic from tests & old tests
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Controller/FeedControllerTest.php12
-rw-r--r--tests/Unit/Controller/ItemControllerTest.php145
-rw-r--r--tests/Unit/Db/ItemMapperAfterTest.php139
-rw-r--r--tests/Unit/Db/ItemMapperPaginatedTest.php238
-rw-r--r--tests/Unit/Db/ItemMapperTest.php40
-rw-r--r--tests/Unit/Service/ItemServiceTest.php45
6 files changed, 51 insertions, 568 deletions
diff --git a/tests/Unit/Controller/FeedControllerTest.php b/tests/Unit/Controller/FeedControllerTest.php
index 2ea13b1ec..fde821088 100644
--- a/tests/Unit/Controller/FeedControllerTest.php
+++ b/tests/Unit/Controller/FeedControllerTest.php
@@ -137,8 +137,7 @@ class FeedControllerTest extends TestCase
'feeds' => [
['a feed'],
],
- 'starred' => 4,
- 'shared' => 3
+ 'starred' => 4
];
$this->feedService->expects($this->once())
->method('findAllForUser')
@@ -152,10 +151,6 @@ class FeedControllerTest extends TestCase
->method('starred')
->with($this->uid)
->will($this->returnValue([1, 2, 3, 4]));
- $this->itemService->expects($this->once())
- ->method('sharedWithUser')
- ->with($this->equalTo($this->uid))
- ->will($this->returnValue([0, 1, 2]));
$response = $this->class->index();
@@ -170,7 +165,6 @@ class FeedControllerTest extends TestCase
['a feed'],
],
'starred' => 2,
- 'shared' => 3,
'newestItemId' => 5
];
$this->feedService->expects($this->once())
@@ -185,10 +179,6 @@ class FeedControllerTest extends TestCase
->method('starred')
->with($this->uid)
->will($this->returnValue([1, 2]));
- $this->itemService->expects($this->once())
- ->method('sharedWithUser')
- ->with($this->equalTo($this->uid))
- ->will($this->returnValue([4, 5, 6]));
$response = $this->class->index();
diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php
index 6836cd119..8c10dad4b 100644
--- a/tests/Unit/Controller/ItemControllerTest.php
+++ b/tests/Unit/Controller/ItemControllerTest.php
@@ -258,8 +258,7 @@ class ItemControllerTest extends TestCase
'items' => [new Item()],
'feeds' => $feeds,
'newestItemId' => $this->newestItemId,
- 'starred' => 3,
- 'shared' => 2
+ 'starred' => 3
];
$this->itemsApiExpects(2, ListType::FEED, '0');
@@ -280,11 +279,6 @@ class ItemControllerTest extends TestCase
->will($this->returnValue([1, 2, 3]));
$this->itemService->expects($this->once())
- ->method('sharedWithUser')
- ->with('user')
- ->will($this->returnValue([4, 5]));
-
- $this->itemService->expects($this->once())
->method('findAllInFeedWithFilters')
->with('user', 2, 3, 0, false, false, [])
->will($this->returnValue($result['items']));
@@ -301,8 +295,7 @@ class ItemControllerTest extends TestCase
'items' => [new Item()],
'feeds' => $feeds,
'newestItemId' => $this->newestItemId,
- 'starred' => 3,
- 'shared' => 2
+ 'starred' => 3
];
$this->itemsApiExpects(2, ListType::FOLDER, '0');
@@ -323,11 +316,6 @@ class ItemControllerTest extends TestCase
->will($this->returnValue([1, 2, 3]));
$this->itemService->expects($this->once())
- ->method('sharedWithUser')
- ->with('user')
- ->will($this->returnValue([0, 1]));
-
- $this->itemService->expects($this->once())
->method('findAllInFolderWithFilters')
->with('user', 2, 3, 0, false, false, [])
->will($this->returnValue($result['items']));
@@ -337,49 +325,6 @@ class ItemControllerTest extends TestCase
}
- public function testIndexForShared()
- {
- $feeds = [new Feed()];
- $result = [
- 'items' => [new Item()],
- 'feeds' => $feeds,
- 'newestItemId' => $this->newestItemId,
- 'starred' => 3,
- 'shared' => 4
- ];
-
- $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]));
-
- $this->itemService->expects($this->once())
- ->method('sharedWithUser')
- ->with('user')
- ->will($this->returnValue([1, 2, 3, 4]));
-
- $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()];
@@ -387,8 +332,7 @@ class ItemControllerTest extends TestCase
'items' => [new Item()],
'feeds' => $feeds,
'newestItemId' => $this->newestItemId,
- 'starred' => 3,
- 'shared' => 4
+ 'starred' => 3
];
$this->itemsApiExpects(2, ListType::STARRED, '0');
@@ -413,11 +357,6 @@ 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);
}
@@ -430,8 +369,7 @@ class ItemControllerTest extends TestCase
'items' => [new Item()],
'feeds' => $feeds,
'newestItemId' => $this->newestItemId,
- 'starred' => 3,
- 'shared' => 2
+ 'starred' => 3
];
$this->itemsApiExpects(2, ListType::FEED, '0');
@@ -456,11 +394,6 @@ 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);
}
@@ -506,8 +439,7 @@ class ItemControllerTest extends TestCase
'items' => [new Item()],
'feeds' => $feeds,
'newestItemId' => $this->newestItemId,
- 'starred' => 3,
- 'shared' => 3
+ 'starred' => 3
];
$this->settings->expects($this->once())
@@ -531,11 +463,6 @@ class ItemControllerTest extends TestCase
->will($this->returnValue([1, 2, 3]));
$this->itemService->expects($this->once())
- ->method('sharedWithUser')
- ->with('user')
- ->will($this->returnValue([1, 2, 3]));
-
- $this->itemService->expects($this->once())
->method('findAllInFeedAfter')
->with('user', 2, 3, false)
->will($this->returnValue($result['items']));
@@ -552,8 +479,7 @@ class ItemControllerTest extends TestCase
'items' => [new Item()],
'feeds' => $feeds,
'newestItemId' => $this->newestItemId,
- 'starred' => 3,
- 'shared' => 2
+ 'starred' => 3
];
$this->settings->expects($this->once())
@@ -581,62 +507,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);
}
- public function testNewItemsShared()
- {
- $feeds = [new Feed()];
- $result = [
- 'items' => [new Item()],
- 'feeds' => $feeds,
- 'newestItemId' => $this->newestItemId,
- 'starred' => 3,
- 'shared' => 5
- ];
-
- $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]));
-
- $this->itemService->expects($this->once())
- ->method('sharedWithUser')
- ->with('user')
- ->will($this->returnValue([1, 2, 3, 4, 5]));
-
- $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()];
@@ -644,8 +519,7 @@ class ItemControllerTest extends TestCase
'items' => [new Item()],
'feeds' => $feeds,
'newestItemId' => $this->newestItemId,
- 'starred' => 3,
- 'shared' => 2
+ 'starred' => 3
];
$this->settings->expects($this->once())
@@ -673,11 +547,6 @@ 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);
}
diff --git a/tests/Unit/Db/ItemMapperAfterTest.php b/tests/Unit/Db/ItemMapperAfterTest.php
index 5c91fa00d..eccebbcf5 100644
--- a/tests/Unit/Db/ItemMapperAfterTest.php
+++ b/tests/Unit/Db/ItemMapperAfterTest.php
@@ -62,11 +62,10 @@ class ItemMapperAfterTest extends MapperTestUtility
->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
- $this->builder->expects($this->exactly(4))
+ $this->builder->expects($this->exactly(3))
->method('andWhere')
->withConsecutive(
['items.last_modified >= :updatedSince'],
- ['items.shared_by = \'\''],
['feeds.user_id = :userId'],
['feeds.id = :feedId'],
['feeds.deleted_at = 0']
@@ -128,11 +127,10 @@ class ItemMapperAfterTest extends MapperTestUtility
->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
- $this->builder->expects($this->exactly(5))
+ $this->builder->expects($this->exactly(4))
->method('andWhere')
->withConsecutive(
['items.last_modified >= :updatedSince'],
- ['items.shared_by = \'\''],
['feeds.user_id = :userId'],
['feeds.id = :feedId'],
['feeds.deleted_at = 0'],
@@ -203,11 +201,10 @@ class ItemMapperAfterTest extends MapperTestUtility
)
->will($this->returnSelf());
- $this->builder->expects($this->exactly(4))
+ $this->builder->expects($this->exactly(3))
->method('andWhere')
->withConsecutive(
['items.last_modified >= :updatedSince'],
- ['items.shared_by = \'\''],
['feeds.user_id = :userId'],
['feeds.deleted_at = 0'],
['folders.id = :folderId']
@@ -272,11 +269,10 @@ class ItemMapperAfterTest extends MapperTestUtility
)
->will($this->returnSelf());
- $this->builder->expects($this->exactly(5))
+ $this->builder->expects($this->exactly(4))
->method('andWhere')
->withConsecutive(
['items.last_modified >= :updatedSince'],
- ['items.shared_by = \'\''],
['feeds.user_id = :userId'],
['feeds.deleted_at = 0'],
['folders.id = :folderId'],
@@ -323,121 +319,6 @@ class ItemMapperAfterTest extends MapperTestUtility
$this->assertEquals([Item::fromRow(['id' => 4])], $result);
}
- public function testFindAllSharedAfter()
- {
- $this->db->expects($this->once())
- ->method('getQueryBuilder')
- ->willReturn($this->builder);
-
- $this->builder->expects($this->once())
- ->method('select')
- ->with('items.*')
- ->will($this->returnSelf());
-
- $this->builder->expects($this->once())
- ->method('from')
- ->with('news_items', 'items')
- ->will($this->returnSelf());
-
- $this->builder->expects($this->exactly(2))
- ->method('andWhere')
- ->withConsecutive(
- ['items.last_modified >= :updatedSince'],
- ['items.shared_with = :sharedWith']
- )
- ->will($this->returnSelf());
-
- $this->builder->expects($this->exactly(1))
- ->method('setParameters')
- ->with([
- 'updatedSince' => 1610903351,
- 'sharedWith' => 'jack',
- ])
- ->will($this->returnSelf());
-
- $this->builder->expects($this->once())
- ->method('orderBy')
- ->with('items.last_modified', 'DESC')
- ->will($this->returnSelf());
-
- $this->builder->expects($this->once())
- ->method('addOrderBy')
- ->with('items.id', 'DESC')
- ->willReturnSelf();
-
- $this->builder->expects($this->once())
- ->method('execute')
- ->will($this->returnValue($this->cursor));
-
- $this->cursor->expects($this->exactly(2))
- ->method('fetch')
- ->willReturnOnConsecutiveCalls(
- ['id' => 4],
- false
- );
-
- $result = $this->class->findAllSharedAfter('jack', 1610903351, false);
- $this->assertEquals([Item::fromRow(['id' => 4])], $result);
- }
-
- public function testFindAllSharedAfterHideRead()
- {
- $this->db->expects($this->once())
- ->method('getQueryBuilder')
- ->willReturn($this->builder);
-
- $this->builder->expects($this->once())
- ->method('select')
- ->with('items.*')
- ->will($this->returnSelf());
-
- $this->builder->expects($this->once())
- ->method('from')
- ->with('news_items', 'items')
- ->will($this->returnSelf());
-
- $this->builder->expects($this->exactly(3))
- ->method('andWhere')
- ->withConsecutive(
- ['items.last_modified >= :updatedSince'],
- ['items.shared_with = :sharedWith'],
- ['items.unread = 1']
- )
- ->will($this->returnSelf());
-
- $this->builder->expects($this->exactly(1))
- ->method('setParameters')
- ->with([
- 'updatedSince' => 1610903351,
- 'sharedWith' => 'jack'
- ])
- ->will($this->returnSelf());
-
- $this->builder->expects($this->once())
- ->method('orderBy')
- ->with('items.last_modified', 'DESC')
- ->will($this->returnSelf());
-
- $this->builder->expects($this->once())
- ->method('addOrderBy')
- ->with('items.id', 'DESC')
- ->willReturnSelf();
-
- $this->builder->expects($this->once())
- ->method('execute')
- ->will($this->returnValue($this->cursor));
-
- $this->cursor->expects($this->exactly(2))
- ->method('fetch')
- ->willReturnOnConsecutiveCalls(
- ['id' => 4],
- false
- );
-
- $result = $this->class->findAllSharedAfter('jack', 1610903351, true);
- $this->assertEquals([Item::fromRow(['id' => 4])], $result);
- }
-
public function testFindAllAfterUnread()
{
$this->db->expects($this->once())
@@ -464,7 +345,7 @@ class ItemMapperAfterTest extends MapperTestUtility
->withConsecutive(
['items.last_modified >= :updatedSince'],
['feeds.deleted_at = 0'],
- ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith'],
+ ['feeds.user_id = :userId'],
['items.unread = :unread']
)
->will($this->returnSelf());
@@ -474,7 +355,6 @@ class ItemMapperAfterTest extends MapperTestUtility
->with([
'updatedSince' => 1610903351,
'userId' => 'jack',
- 'sharedWith' => 'jack'
])
->will($this->returnSelf());
@@ -534,7 +414,7 @@ class ItemMapperAfterTest extends MapperTestUtility
->withConsecutive(
['items.last_modified >= :updatedSince'],
['feeds.deleted_at = 0'],
- ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith'],
+ ['feeds.user_id = :userId'],
['items.starred = :starred']
)
->will($this->returnSelf());
@@ -544,7 +424,6 @@ class ItemMapperAfterTest extends MapperTestUtility
->with([
'updatedSince' => 1610903351,
'userId' => 'jack',
- 'sharedWith' => 'jack'
])
->will($this->returnSelf());
@@ -604,7 +483,7 @@ class ItemMapperAfterTest extends MapperTestUtility
->withConsecutive(
['items.last_modified >= :updatedSince'],
['feeds.deleted_at = 0'],
- ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith']
+ ['feeds.user_id = :userId']
)
->will($this->returnSelf());
@@ -613,7 +492,6 @@ class ItemMapperAfterTest extends MapperTestUtility
->with([
'updatedSince' => 1610903351,
'userId' => 'jack',
- 'sharedWith' => 'jack'
])
->will($this->returnSelf());
@@ -671,7 +549,7 @@ class ItemMapperAfterTest extends MapperTestUtility
->withConsecutive(
['items.last_modified >= :updatedSince'],
['feeds.deleted_at = 0'],
- ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith']
+ ['feeds.user_id = :userId']
)
->will($this->returnSelf());
@@ -680,7 +558,6 @@ class ItemMapperAfterTest extends MapperTestUtility
->with([
'updatedSince' => 1610903351,
'userId' => 'jack',
- 'sharedWith' => 'jack'
])
->will($this->returnSelf());
diff --git a/tests/Unit/Db/ItemMapperPaginatedTest.php b/tests/Unit/Db/ItemMapperPaginatedTest.php
index f9ed9b6e5..e0625aa0c 100644
--- a/tests/Unit/Db/ItemMapperPaginatedTest.php
+++ b/tests/Unit/Db/ItemMapperPaginatedTest.php
@@ -70,14 +70,14 @@ class ItemMapperPaginatedTest extends MapperTestUtility
$this->builder->expects($this->exactly(3))
->method('andWhere')
->withConsecutive(
- ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith'],
+ ['feeds.user_id = :userId'],
['feeds.deleted_at = 0']
)
->will($this->returnSelf());
- $this->builder->expects($this->exactly(3))
+ $this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['sharedWith', 'jack'], ['offset', 10])
+ ->withConsecutive(['userId', 'jack'], ['offset', 10])
->will($this->returnSelf());
@@ -140,15 +140,15 @@ class ItemMapperPaginatedTest extends MapperTestUtility
$this->builder->expects($this->exactly(3))
->method('andWhere')
->withConsecutive(
- ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith'],
+ ['feeds.user_id = :userId'],
['feeds.deleted_at = 0'],
['items.id > :offset']
)
->will($this->returnSelf());
- $this->builder->expects($this->exactly(3))
+ $this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['sharedWith', 'jack'], ['offset', 10])
+ ->withConsecutive(['userId', 'jack'], ['offset', 10])
->will($this->returnSelf());
@@ -212,16 +212,16 @@ class ItemMapperPaginatedTest extends MapperTestUtility
$this->builder->expects($this->exactly(4))
->method('andWhere')
->withConsecutive(
- ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith'],
+ ['feeds.user_id = :userId'],
['feeds.deleted_at = 0'],
['items.id < :offset'],
['items.unread = :unread']
)
->will($this->returnSelf());
- $this->builder->expects($this->exactly(3))
+ $this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['sharedWith', 'jack'], ['offset', 10], ['unread', true])
+ ->withConsecutive(['userId', 'jack'], ['offset', 10], ['unread', true])
->will($this->returnSelf());
$this->builder->expects($this->exactly(1))
@@ -352,16 +352,16 @@ class ItemMapperPaginatedTest extends MapperTestUtility
$this->builder->expects($this->exactly(4))
->method('andWhere')
->withConsecutive(
- ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith'],
+ ['feeds.user_id = :userId'],
['feeds.deleted_at = 0'],
['items.id < :offset'],
['items.starred = :starred']
)
->will($this->returnSelf());
- $this->builder->expects($this->exactly(3))
+ $this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['sharedWith', 'jack'], ['offset', 10], ['starred', true])
+ ->withConsecutive(['userId', 'jack'], ['offset', 10], ['starred', true])
->will($this->returnSelf());
@@ -427,7 +427,7 @@ class ItemMapperPaginatedTest extends MapperTestUtility
$this->builder->expects($this->exactly(6))
->method('andWhere')
->withConsecutive(
- ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith'],
+ ['feeds.user_id = :userId'],
['feeds.deleted_at = 0'],
['items.search_index LIKE :term0'],
['items.search_index LIKE :term1'],
@@ -436,11 +436,10 @@ class ItemMapperPaginatedTest extends MapperTestUtility
)
->will($this->returnSelf());
- $this->builder->expects($this->exactly(5))
+ $this->builder->expects($this->exactly(4))
->method('setParameter')
->withConsecutive(
['userId', 'jack'],
- ['sharedWith', 'jack'],
['term0', '%key%'],
['term1', '%word%'],
['offset', 10],
@@ -506,13 +505,12 @@ class ItemMapperPaginatedTest extends MapperTestUtility
->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
->will($this->returnSelf());
- $this->builder->expects($this->exactly(4))
+ $this->builder->expects($this->exactly(3))
->method('andWhere')
->withConsecutive(
['feeds.deleted_at = 0'],
['feeds.user_id = :userId'],
['items.feed_id = :feedId'],
- ['items.shared_by = \'\''],
['items.id < :offset']
)
->will($this->returnSelf());
@@ -651,13 +649,12 @@ class ItemMapperPaginatedTest extends MapperTestUtility
->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
->will($this->returnSelf());
- $this->builder->expects($this->exactly(4))
+ $this->builder->expects($this->exactly(3))
->method('andWhere')
->withConsecutive(
['feeds.deleted_at = 0'],
['feeds.user_id = :userId'],
['items.feed_id = :feedId'],
- ['items.shared_by = \'\''],
['items.id > :offset']
)
->will($this->returnSelf());
@@ -723,13 +720,12 @@ class ItemMapperPaginatedTest extends MapperTestUtility
->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
->will($this->returnSelf());
- $this->builder->expects($this->exactly(5))
+ $this->builder->expects($this->exactly(4))
->method('andWhere')
->withConsecutive(
['feeds.deleted_at = 0'],
['feeds.user_id = :userId'],
['items.feed_id = :feedId'],
- ['items.shared_by = \'\''],
['items.id < :offset'],
['items.unread = :unread']
)
@@ -801,13 +797,12 @@ class ItemMapperPaginatedTest extends MapperTestUtility
->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
->will($this->returnSelf());
- $this->builder->expects($this->exactly(6))
+ $this->builder->expects($this->exactly(5))
->method('andWhere')
->withConsecutive(
['feeds.deleted_at = 0'],
['feeds.user_id = :userId'],
['items.feed_id = :feedId'],
- ['items.shared_by = \'\''],
['items.search_index LIKE :term0'],
['items.search_index LIKE :term1'],
['items.id < :offset']
@@ -900,7 +895,6 @@ class ItemMapperPaginatedTest extends MapperTestUtility
->withConsecutive(
['feeds.user_id = :userId'],
['feeds.deleted_at = 0'],
- ['items.shared_by = \'\''],
['x IS NULL'],
['items.id < :offset']
)
@@ -1069,7 +1063,6 @@ class ItemMapperPaginatedTest extends MapperTestUtility
->withConsecutive(
['feeds.user_id = :userId'],
['feeds.deleted_at = 0'],
- ['items.shared_by = \'\''],
['x IS NULL'],
['items.id < :offset'],
['items.unread = :unread']
@@ -1156,7 +1149,6 @@ class ItemMapperPaginatedTest extends MapperTestUtility
->withConsecutive(
['feeds.user_id = :userId'],
['feeds.deleted_at = 0'],
- ['items.shared_by = \'\''],
['x IS NULL'],
['items.id > :offset'],
['items.unread = :unread']
@@ -1246,7 +1238,6 @@ class ItemMapperPaginatedTest extends MapperTestUtility
->withConsecutive(
['feeds.user_id = :userId'],
['feeds.deleted_at = 0'],
- ['items.shared_by = \'\''],
['x = y'],
['items.search_index LIKE :term0'],
['items.search_index LIKE :term1'],
@@ -1295,197 +1286,4 @@ class ItemMapperPaginatedTest extends MapperTestUtility
$result = $this->class->findAllFolder('jack', 2, 10, 10, false, false, ['key', 'word']);
$this->assertEquals([Item::fromRow(['id' => 4])], $result);
}
-
- public function testFindAllSharedWithUser()
- {
- $this->db->expects($this->once())
- ->method('getQueryBuilder')
- ->willReturn($this->builder);
-
- $this->builder->expects($this->once())
- ->method('select')
- ->with('items.*')
- ->will($this->returnSelf());
-
- $this->builder->expects($this->once())
- ->method('from')
- ->with('news_items', 'items')
- ->will($this->returnSelf());
-
- $this->builder->expects($this->exactly(2))
- ->method('andWhere')
- ->withConsecutive(
- ['items.shared_with = :sharedWith'],
- ['items.id < :offset']
- )
- ->will($this->returnSelf());
-
- $this->builder->expects($this->exactly(2))
- ->method('setParameter')
- ->withConsecutive(
- ['sharedWith', 'jack'],
- ['offset', 10]
- )
- ->will($this->returnSelf());
-
- $this->builder->expects($this->exactly(1))
- ->method('setMaxResults')
- ->with(10)
- ->will($this->returnSelf());
-
- $this->builder->expects($this->once())
- ->method('orderBy')
- ->with('items.last_modified', 'DESC')
- ->will($this->returnSelf());
-
- $this->builder->expects($this->once())
- ->method('addOrderBy')
- ->with('items.id', 'DESC')
- ->willReturnSelf();
-
- $this->builder->expects($this->exactly(1))
- ->method('execute')
- ->will($this->returnValue($this->cursor));
-
- $this->cursor->expects($this->exactly(2))
- ->method('fetch')
- ->willReturnOnConsecutiveCalls(
- ['id' => 4],
- false
- );
-
- $result = $this->class->findAllSharedWithUser('jack', 10, 10, false, false, []);
- $this->assertEquals([Item::fromRow(['id' => 4])], $result);
- }
-
- public function testFindAllSharedWithUserHideRead()
- {
- $this->db->expects($this->once())
- ->method('getQueryBuilder')
- ->willReturn($this->builder);
-
- $this->builder->expects($this->once())
- ->method('select')
- ->with('items.*')
- ->will($this->returnSelf());
-
- $this->builder->expects($this->once())
- ->method('from')
- ->with('news_items', 'items')
- ->will($this->returnSelf());
-
- $this->builder->expects($this->exactly(3))
- ->method('andWhere')
- ->withConsecutive(
- ['items.shared_with = :sharedWith'],
- ['items.id < :offset'],
- ['items.unread = 1']
- )
- ->will($this->returnSelf());
-
- $this->builder->expects($this->exactly(2))
- ->method('setParameter')
- ->withConsecutive(['sharedWith', 'jack'], ['offset', 10])
- ->will($this->returnSelf());
-
- $this->builder->expects($this->exactly(1))
- ->method('setMaxResults')
- ->with(10)