summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2021-02-16 21:17:10 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-02-20 13:57:09 +0100
commit4a107b3d53c4fe651ac704251b99e04a53cd587f (patch)
tree9700c89992f1ad739023d73fcd434250c323089e /tests
parent01e1db329ced43323654990828744d577cac4ba8 (diff)
General: Fix folder query
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Controller/FeedControllerTest.php14
-rw-r--r--tests/Unit/Controller/ItemControllerTest.php34
-rw-r--r--tests/Unit/Controller/PageControllerTest.php6
-rw-r--r--tests/Unit/Db/ItemMapperTest.php3
-rw-r--r--tests/Unit/Service/ItemServiceTest.php8
5 files changed, 33 insertions, 32 deletions
diff --git a/tests/Unit/Controller/FeedControllerTest.php b/tests/Unit/Controller/FeedControllerTest.php
index b8929d373..cf7bc501e 100644
--- a/tests/Unit/Controller/FeedControllerTest.php
+++ b/tests/Unit/Controller/FeedControllerTest.php
@@ -22,7 +22,7 @@ use OCA\News\Service\ItemServiceV2;
use OCP\AppFramework\Http;
use OCA\News\Db\Feed;
-use OCA\News\Db\FeedType;
+use OCA\News\Db\ListType;
use OCA\News\Service\Exceptions\ServiceNotFoundException;
use OCA\News\Service\Exceptions\ServiceConflictException;
use OCP\IConfig;
@@ -125,7 +125,7 @@ class FeedControllerTest extends TestCase
$this->exampleResult = [
'activeFeed' => [
'id' => 0,
- 'type' => FeedType::SUBSCRIPTIONS
+ 'type' => ListType::ALL_ITEMS
]
];
}
@@ -207,7 +207,7 @@ class FeedControllerTest extends TestCase
public function testActive()
{
$id = 3;
- $type = FeedType::STARRED;
+ $type = ListType::STARRED;
$result = [
'activeFeed' => [
'id' => $id,
@@ -226,7 +226,7 @@ class FeedControllerTest extends TestCase
public function testActiveFeed()
{
$id = 3;
- $type = FeedType::FEED;
+ $type = ListType::FEED;
$result = [
'activeFeed' => [
'id' => $id,
@@ -250,7 +250,7 @@ class FeedControllerTest extends TestCase
public function testActiveFeedDoesNotExist()
{
$id = 3;
- $type = FeedType::FEED;
+ $type = ListType::FEED;
$ex = new ServiceNotFoundException('hiu');
$result = $this->exampleResult;
@@ -269,7 +269,7 @@ class FeedControllerTest extends TestCase
public function testActiveFolder()
{
- $type = FeedType::FOLDER;
+ $type = ListType::FOLDER;
$folder = new Folder();
$folder->setId(3);
@@ -296,7 +296,7 @@ class FeedControllerTest extends TestCase
public function testActiveFolderDoesNotExist()
{
$id = 3;
- $type = FeedType::FOLDER;
+ $type = ListType::FOLDER;
$ex = new ServiceNotFoundException('hiu');
$result = $this->exampleResult;
diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php
index 546b39278..c64cd9330 100644
--- a/tests/Unit/Controller/ItemControllerTest.php
+++ b/tests/Unit/Controller/ItemControllerTest.php
@@ -20,7 +20,7 @@ use \OCP\AppFramework\Http;
use \OCA\News\Db\Item;
use \OCA\News\Db\Feed;
-use \OCA\News\Db\FeedType;
+use \OCA\News\Db\ListType;
use \OCA\News\Service\Exceptions\ServiceNotFoundException;
use OCP\IConfig;
use OCP\IRequest;
@@ -234,7 +234,7 @@ class ItemControllerTest extends TestCase
'starred' => 3
];
- $this->itemsApiExpects(2, FeedType::FEED, '0');
+ $this->itemsApiExpects(2, ListType::FEED, '0');
$this->feedService->expects($this->once())
->method('findAllForUser')
@@ -256,7 +256,7 @@ class ItemControllerTest extends TestCase
->with('user', 2, 3, 0, false, false, [])
->will($this->returnValue($result['items']));
- $response = $this->controller->index(FeedType::FEED, 2, 3);
+ $response = $this->controller->index(ListType::FEED, 2, 3);
$this->assertEquals($result, $response);
}
@@ -271,7 +271,7 @@ class ItemControllerTest extends TestCase
'starred' => 3
];
- $this->itemsApiExpects(2, FeedType::FOLDER, '0');
+ $this->itemsApiExpects(2, ListType::FOLDER, '0');
$this->feedService->expects($this->once())
->method('findAllForUser')
@@ -293,7 +293,7 @@ class ItemControllerTest extends TestCase
->with('user', 2, 3, 0, false, false, [])
->will($this->returnValue($result['items']));
- $response = $this->controller->index(FeedType::FOLDER, 2, 3);
+ $response = $this->controller->index(ListType::FOLDER, 2, 3);
$this->assertEquals($result, $response);
}
@@ -308,7 +308,7 @@ class ItemControllerTest extends TestCase
'starred' => 3
];
- $this->itemsApiExpects(2, FeedType::STARRED, '0');
+ $this->itemsApiExpects(2, ListType::STARRED, '0');
$this->feedService->expects($this->once())
->method('findAllForUser')
@@ -330,7 +330,7 @@ class ItemControllerTest extends TestCase
->with('user', 2, 3, 0, false, [])
->will($this->returnValue($result['items']));
- $response = $this->controller->index(FeedType::STARRED, 2, 3);
+ $response = $this->controller->index(ListType::STARRED, 2, 3);
$this->assertEquals($result, $response);
}
@@ -345,7 +345,7 @@ class ItemControllerTest extends TestCase
'starred' => 3
];
- $this->itemsApiExpects(2, FeedType::FEED, '0');
+ $this->itemsApiExpects(2, ListType::FEED, '0');
$this->feedService->expects($this->once())
->method('findAllForUser')
@@ -367,7 +367,7 @@ class ItemControllerTest extends TestCase
->with('user', 2, 3, 0, false, false, ['test', 'search'])
->will($this->returnValue($result['items']));
- $response = $this->controller->index(FeedType::FEED, 2, 3, 0, null, null, 'test%20%20search%20');
+ $response = $this->controller->index(ListType::FEED, 2, 3, 0, null, null, 'test%20%20search%20');
$this->assertEquals($result, $response);
}
@@ -376,7 +376,7 @@ class ItemControllerTest extends TestCase
{
$result = ['items' => [new Item()]];
- $this->itemsApiExpects(2, FeedType::FEED);
+ $this->itemsApiExpects(2, ListType::FEED);
$this->itemService->expects($this->once())
->method('findAllInFeedWithFilters')
@@ -386,21 +386,21 @@ class ItemControllerTest extends TestCase
$this->feedService->expects($this->never())
->method('findAllForUser');
- $response = $this->controller->index(FeedType::FEED, 2, 3, 10);
+ $response = $this->controller->index(ListType::FEED, 2, 3, 10);
$this->assertEquals($result, $response);
}
public function testGetItemsNoNewestItemsId()
{
- $this->itemsApiExpects(2, FeedType::FEED);
+ $this->itemsApiExpects(2, ListType::FEED);
$this->itemService->expects($this->once())
->method('newest')
->with('user')
->will($this->throwException(new ServiceNotFoundException('')));
- $response = $this->controller->index(FeedType::FEED, 2, 3);
+ $response = $this->controller->index(ListType::FEED, 2, 3);
$this->assertEquals([], $response);
}
@@ -440,7 +440,7 @@ class ItemControllerTest extends TestCase
->with('user', 2, 3, false)
->will($this->returnValue($result['items']));
- $response = $this->controller->newItems(FeedType::FEED, 2, 3);
+ $response = $this->controller->newItems(ListType::FEED, 2, 3);
$this->assertEquals($result, $response);
}
@@ -480,7 +480,7 @@ class ItemControllerTest extends TestCase
->with('user', 2, 3, false)
->will($this->returnValue($result['items']));
- $response = $this->controller->newItems(FeedType::FOLDER, 2, 3);
+ $response = $this->controller->newItems(ListType::FOLDER, 2, 3);
$this->assertEquals($result, $response);
}
@@ -520,7 +520,7 @@ class ItemControllerTest extends TestCase
->with('user', 6, 3)
->will($this->returnValue($result['items']));
- $response = $this->controller->newItems(FeedType::UNREAD, 2, 3);
+ $response = $this->controller->newItems(ListType::UNREAD, 2, 3);
$this->assertEquals($result, $response);
}
@@ -537,7 +537,7 @@ class ItemControllerTest extends TestCase
->with('user')
->will($this->throwException(new ServiceNotFoundException('')));
- $response = $this->controller->newItems(FeedType::FEED, 2, 3);
+ $response = $this->controller->newItems(ListType::FEED, 2, 3);
$this->assertEquals([], $response);
}
diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php
index 5f62bfe9f..4e2950479 100644
--- a/tests/Unit/Controller/PageControllerTest.php
+++ b/tests/Unit/Controller/PageControllerTest.php
@@ -15,7 +15,7 @@ namespace OCA\News\Tests\Unit\Controller;
use OC\L10N\L10N;
use OCA\News\Controller\PageController;
-use \OCA\News\Db\FeedType;
+use \OCA\News\Db\ListType;
use OCA\News\Explore\Exceptions\RecommendedSiteNotFoundException;
use OCA\News\Explore\RecommendedSites;
use OCA\News\Service\StatusService;
@@ -264,7 +264,7 @@ class PageControllerTest extends TestCase
->method('setUserValue')
->withConsecutive(
['becka', 'news', 'lastViewedFeedId', 0],
- ['becka', 'news', 'lastViewedFeedType', FeedType::EXPLORE]
+ ['becka', 'news', 'lastViewedFeedType', ListType::EXPLORE]
);
$this->recommended->expects($this->once())
@@ -284,7 +284,7 @@ class PageControllerTest extends TestCase
->method('setUserValue')
->withConsecutive(
['becka', 'news', 'lastViewedFeedId', 0],
- ['becka', 'news', 'lastViewedFeedType', FeedType::EXPLORE]
+ ['becka', 'news', 'lastViewedFeedType', ListType::EXPLORE]
);
$this->recommended->expects($this->once())
diff --git a/tests/Unit/Db/ItemMapperTest.php b/tests/Unit/Db/ItemMapperTest.php
index 878f8c59d..c1e946d2b 100644
--- a/tests/Unit/Db/ItemMapperTest.php
+++ b/tests/Unit/Db/ItemMapperTest.php
@@ -13,6 +13,7 @@
namespace OCA\News\Tests\Unit\Db;
+use OC\DB\QueryBuilder\Literal;
use OCA\News\Db\Feed;
use OCA\News\Db\FeedMapperV2;
use OCA\News\Db\Folder;
@@ -1691,7 +1692,7 @@ class ItemMapperTest extends MapperTestUtility
$expr->expects($this->once())
->method('eq')
- ->with('feeds.folder_id', 2)
+ ->with('feeds.folder_id', new Literal(2))
->will($this->returnValue('x = y'));
$this->db->expects($this->once())
diff --git a/tests/Unit/Service/ItemServiceTest.php b/tests/Unit/Service/ItemServiceTest.php
index e82d5eda7..f91692cda 100644
--- a/tests/Unit/Service/ItemServiceTest.php
+++ b/tests/Unit/Service/ItemServiceTest.php
@@ -21,7 +21,7 @@ use OCA\News\Service\ItemServiceV2;
use \OCP\AppFramework\Db\DoesNotExistException;
use \OCA\News\Db\Item;
-use \OCA\News\Db\FeedType;
+use \OCA\News\Db\ListType;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\IConfig;
@@ -133,7 +133,7 @@ class ItemServiceTest extends TestCase
$this->mapper->expects($this->never())
->method('findAllAfter');
- $result = $this->class->findAllAfter($this->user, 3, 20333);
+ $result = $this->class->findAllAfter($this->user, 5, 20333);
$this->assertEquals([], $result);
}
@@ -176,7 +176,7 @@ class ItemServiceTest extends TestCase
public function testFindAllItems()
{
- $type = FeedType::STARRED;
+ $type = ListType::STARRED;
$this->mapper->expects($this->once())
->method('findAllItems')
->with('jack', $type, 20, 5, true, [])
@@ -188,7 +188,7 @@ class ItemServiceTest extends TestCase
public function testFindAllSearch()
{
- $type = FeedType::STARRED;
+ $type = ListType::STARRED;
$search = ['test'];