summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDevlin Junker <devlin.junker@gmail.com>2022-11-09 21:52:11 -0800
committerBenjamin Brahmer <info@b-brahmer.de>2022-11-17 14:50:53 +0100
commitc6b4bcc00e5202e85388a0624d149e8b1df386f8 (patch)
tree7063a29710dfd0a363f3462fee8a0e8185488e15 /tests
parent760c44288256b104b662ade7a892a6ec0b898851 (diff)
upmerging master into vue-rewrite
Signed-off-by: Devlin Junker <devlin.junker@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Controller/AdminControllerTest.php156
-rw-r--r--tests/Unit/Db/ItemMapperTest.php14
-rw-r--r--tests/Unit/Db/ItemTest.php12
-rw-r--r--tests/Unit/Db/NewsMapperTest.php8
-rw-r--r--tests/Unit/Fetcher/FeedFetcherTest.php44
-rw-r--r--tests/Unit/Service/FeedServiceTest.php50
-rw-r--r--tests/Unit/Service/ItemServiceTest.php15
-rw-r--r--tests/api/feeds.bats145
-rw-r--r--tests/api/folders.bats97
-rw-r--r--tests/api/helpers/settings.bash5
-rw-r--r--tests/api/items.bats76
-rw-r--r--tests/command/explore.bats (renamed from tests/integration/explore.bats)0
-rw-r--r--tests/command/feeds.bats84
-rw-r--r--tests/command/folders.bats (renamed from tests/integration/folders.bats)8
-rw-r--r--tests/command/helpers/settings.bash4
-rw-r--r--tests/command/items.bats77
-rw-r--r--tests/command/opml.bats (renamed from tests/integration/opml.bats)8
-rw-r--r--tests/integration/feeds.bats116
-rw-r--r--tests/integration/helpers/settings.bash4
-rw-r--r--tests/integration/items.bats84
m---------tests/test_helper/bats-assert0
m---------tests/test_helper/bats-support0
-rw-r--r--tests/test_helper/feeds/Nextcloud.rss951
-rw-r--r--tests/test_helper/feeds/heise.xml1513
-rw-r--r--tests/test_helper/feeds/no_guid_feed.xml (renamed from tests/integration/feeds/no_guid_feed.xml)0
25 files changed, 3050 insertions, 421 deletions
diff --git a/tests/Unit/Controller/AdminControllerTest.php b/tests/Unit/Controller/AdminControllerTest.php
deleted file mode 100644
index a9d7bb127..000000000
--- a/tests/Unit/Controller/AdminControllerTest.php
+++ /dev/null
@@ -1,156 +0,0 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright 2012 Alessandro Cosentino
- * @copyright 2012-2014 Bernhard Posselt
- */
-
-namespace OCA\News\Tests\Unit\Controller;
-
-use OCA\News\Controller\AdminController;
-use OCA\News\Service\ItemService;
-use OCP\IConfig;
-use OCP\IRequest;
-use PHPUnit\Framework\TestCase;
-
-class AdminControllerTest extends TestCase
-{
- /**
- * @var string
- */
- private $appName;
-
- /**
- * @var \PHPUnit\Framework\MockObject\MockObject|IRequest
- */
- private $request;
-
- /**
- * @var AdminController
- */
- private $controller;
-
- /**
- * @var \PHPUnit\Framework\MockObject\MockObject|IConfig
- */
- private $config;
-
- /**
- * @var \PHPUnit\Framework\MockObject\MockObject|ItemService
- */
- private $itemService;
-
- /**
- * Gets run before each test
- */
- public function setUp(): void
- {
- $this->appName = 'news';
- $this->request = $this->getMockBuilder(IRequest::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->config = $this->getMockBuilder(IConfig::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->itemService = $this->getMockBuilder(ItemService::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->controller = new AdminController($this->request, $this->config, $this->itemService);
- }
-
- /**
- * Test \OCA\News\Controller\AdminController::index
- */
- public function testIndex()
- {
- $expected = [
- 'autoPurgeMinimumInterval' => 1,
- 'autoPurgeCount' => 2,
- 'maxRedirects' => 3,
- 'feedFetcherTimeout' => 4,
- 'useCronUpdates' => false,
- 'exploreUrl' => 'test',
- 'updateInterval' => 3601
- ];
- $map = [
- ['news','autoPurgeMinimumInterval', 60, 1],
- ['news','autoPurgeCount', 200, 2],
- ['news','maxRedirects', 10, 3],
- ['news','feedFetcherTimeout', 60, 4],
- ['news','useCronUpdates', true, false,],
- ['news','exploreUrl', '', 'test'],
- ['news','updateInterval', 3600, 3601]
- ];
- $this->config->expects($this->exactly(count($map)))
- ->method('getAppValue')
- ->will($this->returnValueMap($map));
-
- $response = $this->controller->index();
- $data = $response->getParams();
- $name = $response->getTemplateName();
- $type = $response->getRenderAs();
-
- $this->assertEquals($type, 'blank');
- $this->assertEquals($name, 'admin');
- $this->assertEquals($expected, $data);
- }
-
-
- public function testUpdate()
- {
- $expected = [
- 'autoPurgeMinimumInterval' => 1,
- 'autoPurgeCount' => 2,
- 'maxRedirects' => 3,
- 'feedFetcherTimeout' => 4,
- 'useCronUpdates' => false,
- 'exploreUrl' => 'test',
- 'updateInterval' => 3601
- ];
-
- $this->config->expects($this->exactly(count($expected)))
- ->method('setAppValue')
- ->withConsecutive(
- ['news','autoPurgeMinimumInterval', 1],
- ['news','autoPurgeCount', 2],
- ['news','maxRedirects', 3],
- ['news','feedFetcherTimeout', 4],
- ['news','useCronUpdates', false],
- ['news','exploreUrl', 'test'],
- ['news','updateInterval', 3601]
- );
-
- $map = [
- ['news','autoPurgeMinimumInterval', 60, 1],
- ['news','autoPurgeCount', 200, 2],
- ['news','maxRedirects', 10, 3],
- ['news','feedFetcherTimeout', 60, 4],
- ['news','useCronUpdates', true, false,],
- ['news','exploreUrl', '', 'test'],
- ['news','updateInterval', 3600, 3601]
- ];
- $this->config->expects($this->exactly(count($map)))
- ->method('getAppValue')
- ->will($this->returnValueMap($map));
-
- $response = $this->controller->update(
- $expected['autoPurgeMinimumInterval'],
- $expected['autoPurgeCount'],
- $expected['maxRedirects'],
- $expected['feedFetcherTimeout'],
- $expected['useCronUpdates'],
- $expected['exploreUrl'],
- $expected['updateInterval']
- );
-
- $this->assertEquals($expected, $response);
- }
-
-}
diff --git a/tests/Unit/Db/ItemMapperTest.php b/tests/Unit/Db/ItemMapperTest.php
index 7fc45018e..3a4a026d6 100644
--- a/tests/Unit/Db/ItemMapperTest.php
+++ b/tests/Unit/Db/ItemMapperTest.php
@@ -497,14 +497,14 @@ class ItemMapperTest extends MapperTestUtility
->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
- $selectbuilder->expects($this->exactly(2))
+ $selectbuilder->expects($this->exactly(3))
->method('andWhere')
- ->withConsecutive(['feeds.user_id = :userId'], ['items.id <= :maxItemId'])
+ ->withConsecutive(['feeds.user_id = :userId'], ['items.id <= :maxItemId'], ['items.unread = :unread'])
->will($this->returnSelf());
- $selectbuilder->expects($this->exactly(2))
+ $selectbuilder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'admin'], ['maxItemId', 4])
+ ->withConsecutive(['userId', 'admin'], ['maxItemId', 4], ['unread', true])
->will($this->returnSelf());
$selectbuilder->expects($this->exactly(1))
@@ -542,14 +542,14 @@ class ItemMapperTest extends MapperTestUtility
->with('unread', 'unread')
->will($this->returnSelf());
- $this->builder->expects($this->exactly(2))
+ $this->builder->expects($this->exactly(1))
->method('andWhere')
- ->withConsecutive(['id IN (:idList)'], ['unread != :unread'])
+ ->withConsecutive(['id IN (:idList)'])
->will($this->returnSelf());
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['unread', false], ['idList', [1, 2]])
+ ->withConsecutive(['idList', [1, 2]], ['unread', false])
->will($this->returnSelf());
$this->builder->expects($this->exactly(1))
diff --git a/tests/Unit/Db/ItemTest.php b/tests/Unit/Db/ItemTest.php
index 68b7b5ab8..11620b33c 100644
--- a/tests/Unit/Db/ItemTest.php
+++ b/tests/Unit/Db/ItemTest.php
@@ -317,6 +317,18 @@ class ItemTest extends TestCase
$this->assertEquals($expected, $item->getSearchIndex());
}
+ public function testSearchIndexNull()
+ {
+ $item = new Item();
+ $item->setBody('<a>somEth&auml;ng</a>');
+ $item->setUrl('http://link');
+ $item->setAuthor(null);
+ $item->setTitle('<a>t&auml;tle</a>');
+ $item->setCategories(['food', 'travel']);
+ $item->generateSearchIndex();
+ $expected = 'somethängtätlefoodtravelhttp://link';
+ $this->assertEquals($expected, $item->getSearchIndex());
+ }
public function testFromImport()
{
diff --git a/tests/Unit/Db/NewsMapperTest.php b/tests/Unit/Db/NewsMapperTest.php
index c7ce7342a..aa1be5989 100644
--- a/tests/Unit/Db/NewsMapperTest.php
+++ b/tests/Unit/Db/NewsMapperTest.php
@@ -169,7 +169,7 @@ class NewsMapperTest extends TestCase
->will($this->returnSelf());
$qb->expects($this->once())
- ->method('execute');
+ ->method('executeStatement');
$result = $this->class->purgeDeleted(null, null);
}
@@ -202,7 +202,7 @@ class NewsMapperTest extends TestCase
->will($this->returnSelf());
$qb->expects($this->once())
- ->method('execute');
+ ->method('executeStatement');
$result = $this->class->purgeDeleted('jack', null);
}
@@ -235,7 +235,7 @@ class NewsMapperTest extends TestCase
->will($this->returnSelf());
$qb->expects($this->once())
- ->method('execute');
+ ->method('executeStatement');
$result = $this->class->purgeDeleted(null, 1);
}
@@ -268,7 +268,7 @@ class NewsMapperTest extends TestCase
->will($this->returnSelf());
$qb->expects($this->once())
- ->method('execute');
+ ->method('executeStatement');
$result = $this->class->purgeDeleted('jack', 1);
}
diff --git a/tests/Unit/Fetcher/FeedFetcherTest.php b/tests/Unit/Fetcher/FeedFetcherTest.php
index 42f518453..af8066171 100644
--- a/tests/Unit/Fetcher/FeedFetcherTest.php
+++ b/tests/Unit/Fetcher/FeedFetcherTest.php
@@ -459,6 +459,40 @@ class FeedFetcherTest extends TestCase
}
/**
+ * Test if the fetch function fetches a feed that specifies a guid.
+ */
+ public function testFetchWithGuid()
+ {
+ $this->setUpReader($this->url);
+ $this->createItem();
+ $feed = $this->createFeed();
+ $this->mockIterator($this->feed_mock, [$this->item_mock]);
+ $result = $this->fetcher->fetch($this->url, false, null, null);
+ //Explicitly assert GUID value
+ $this->assertEquals(2, count($result));
+ $this->assertEquals(1, count($result[1]));
+ $resultItem = $result[1][0];
+ $this->assertEquals($this->guid, $resultItem->getGuid());
+ }
+
+ /**
+ * Test if the fetch function fetches a feed that does not specify a guid.
+ */
+ public function testFetchWithoutGuid()
+ {
+ $this->setUpReader($this->url);
+ $this->guid = null;
+ $this->createItem();
+ $feed = $this->createFeed();
+ $this->mockIterator($this->feed_mock, [$this->item_mock]);
+ $result = $this->fetcher->fetch($this->url, false, null, null);
+ //Explicitly assert GUID value
+ $this->assertEquals(2, count($result));
+ $this->assertEquals(1, count($result[1]));
+ $resultItem = $result[1][0];
+ $this->assertEquals($this->permalink, $resultItem->getGuid());
+ }
+ /**
* Mock an iteration option on an existing mock
*
* @param object $iteratorMock The mock to enhance
@@ -576,10 +610,10 @@ class FeedFetcherTest extends TestCase
$this->item_mock->expects($this->exactly(1))
->method('getLink')
->will($this->returnValue($this->permalink));
- $this->item_mock->expects($this->exactly(2))
+ $this->item_mock->expects($this->exactly(1))
->method('getTitle')
->will($this->returnValue($this->title));
- $this->item_mock->expects($this->exactly(2))
+ $this->item_mock->expects($this->exactly(1))
->method('getPublicId')
->will($this->returnValue($this->guid));
$this->item_mock->expects($this->exactly(1))
@@ -600,7 +634,6 @@ class FeedFetcherTest extends TestCase
$item->setUnread(true)
->setUrl($this->permalink)
->setTitle('my<\' title')
- ->setGuid($this->guid)
->setGuidHash($this->guid_hash)
->setBody($this->parsed_body)
->setRtl(false)
@@ -609,6 +642,11 @@ class FeedFetcherTest extends TestCase
->setAuthor(html_entity_decode($this->author->getName()))
->setCategoriesJson($this->categoriesJson);
+ // some tests deliberately omit this, so leave default value if the guid is to be ignored
+ if ($this->guid !== null) {
+ $item->setGuid($this->guid);
+ }
+
if ($enclosureType === 'audio/ogg' || $enclosureType === 'video/ogg') {
$media = $this->getMockbuilder(MediaInterface::class)->getMock();
$media->expects($this->once())
diff --git a/tests/Unit/Service/FeedServiceTest.php b/tests/Unit/Service/FeedServiceTest.php
index 9f4743777..bcc367f0c 100644
--- a/tests/Unit/Service/FeedServiceTest.php
+++ b/tests/Unit/Service/FeedServiceTest.php
@@ -68,11 +68,6 @@ class FeedServiceTest extends TestCase
private $time;
/**
- * @var int
- */
- private $autoPurgeMinimumInterval;
-
- /**
* @var \PHPUnit\Framework\MockObject\MockObject|\HTMLPurifier
*/
private $purifier;
@@ -98,7 +93,6 @@ class FeedServiceTest extends TestCase
->disableOriginalConstructor()
->getMock();
$this->time = 222;
- $this->autoPurgeMinimumInterval = 10;
$timeFactory = $this->getMockBuilder(Time::class)
->disableOriginalConstructor()
->getMock();
@@ -131,10 +125,6 @@ class FeedServiceTest extends TestCase
$config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
- $config->expects($this->any())
- ->method('getAppValue')
- ->with('news', 'autoPurgeMinimumInterval')
- ->will($this->returnValue($this->autoPurgeMinimumInterval));
$this->class = new FeedServiceV2(
$this->mapper,
@@ -165,21 +155,14 @@ class FeedServiceTest extends TestCase
public function testCreateDoesNotFindFeed()
{
- $ex = new ReadErrorException('hi');
$url = 'test';
- $this->mapper->expects($this->once())
- ->method('findByURL')
- ->with($this->uid, $url)
- ->willReturn(new Feed());
-
- $this->fetcher->expects($this->never())
+ $this->fetcher->expects($this->exactly(2))
->method('fetch')
->with($url)
- ->will($this->throwException($ex));
+ ->will($this->throwException(new ReadErrorException('There is no feed')));
- $this->expectException(ServiceConflictException::class);
- $this->expectExceptionMessage('Feed with this URL exists');
+ $this->expectException(ServiceNotFoundException::class);
$this->class->create($this->uid, $url, 1);
}
@@ -209,15 +192,16 @@ class FeedServiceTest extends TestCase
->method('findByURL')
->with($this->uid, $url)
->will($this->throwException(new DoesNotExistException('no')));
- $this->explorer->expects($this->once())
- ->method('discover')
- ->with($url)
- ->will($this->returnValue([]));
+ $this->explorer->expects($this->never())
+ ->method('discover')
+ ->with($url)
+ ->will($this->returnValue([]));
$this->fetcher->expects($this->once())
->method('fetch')
->with($url)
->will($this->returnValue($return));
+
$this->mapper->expects($this->once())
->method('insert')
->with($createdFeed)
@@ -268,7 +252,7 @@ class FeedServiceTest extends TestCase
->method('findByURL')
->with($this->uid, $url)
->will($this->throwException(new DoesNotExistException('no')));
- $this->explorer->expects($this->once())
+ $this->explorer->expects($this->never())
->method('discover')
->with($url)
->will($this->returnValue([]));
@@ -326,16 +310,19 @@ class FeedServiceTest extends TestCase
$this->mapper->expects($this->once())
->method('findByURL')
- ->with($this->uid, $url)
+ ->with($this->uid, 'http://discover.test')
->will($this->throwException(new DoesNotExistException('no')));
$this->explorer->expects($this->once())
->method('discover')
->with($url)
->will($this->returnValue(['http://discover.test']));
- $this->fetcher->expects($this->once())
+ $this->fetcher->expects($this->exactly(2))
->method('fetch')
- ->with('http://discover.test')
- ->will($this->returnValue($return));
+ ->withConsecutive(
+ ['http://test'],
+ ['http://discover.test']
+ )
+ ->willReturnOnConsecutiveCalls($this->throwException(new ReadErrorException('There is no feed')), $this->returnValue($return));
$this->mapper->expects($this->once())
->method('insert')
@@ -434,12 +421,12 @@ class FeedServiceTest extends TestCase
$url = 'http://test';
$folderId = 10;
- $this->fetcher->expects($this->once())
+ $this->fetcher->expects($this->exactly(2))
->method('fetch')
->with($url)
->will($this->throwException(new ReadErrorException('ERROR')));
- $this->mapper->expects($this->once())
+ $this->mapper->expects($this->never())
->method('findByURL')
->with($this->uid, $url)
->will($this->throwException(new DoesNotExistException('no')));
@@ -657,7 +644,6 @@ class FeedServiceTest extends TestCase
$feed2->setId(5);
$feeds = [$feed1, $feed2];
- $time = $this->time - $this->autoPurgeMinimumInterval;
$this->mapper->expects($this->exactly(1))
->method('purgeDeleted')
diff --git a/tests/Unit/Service/ItemServiceTest.php b/tests/Unit/Service/ItemServiceTest.php
index f91692cda..17a67674c 100644
--- a/tests/Unit/Service/ItemServiceTest.php
+++ b/tests/Unit/Service/ItemServiceTest.php
@@ -605,23 +605,24 @@ class ItemServiceTest extends TestCase
public function testPurgeOverThresholdNull()
{
- $this->config->expects($this->once())
+ $this->config->expects($this->exactly(2))
->method('getAppValue')
- ->with('news', 'autoPurgeCount', 200)
- ->will($this->returnValue(200));
-
+ ->withConsecutive(['news', 'autoPurgeCount', 200], ['news', 'purgeUnread', false])
+ ->willReturnOnConsecutiveCalls(200, false);
+
$this->mapper->expects($this->once())
->method('deleteOverThreshold')
- ->with(200);
+ ->with(200, false);
$this->class->purgeOverThreshold();
}
public function testPurgeOverThresholdSet()
{
- $this->config->expects($this->never())
+ $this->config->expects($this->once())
->method('getAppValue')
- ->with('news', 'autoPurgeCount', 200);
+ ->with('news', 'purgeUnread', false)
+ ->will($this->returnValue(false));
$this->mapper->expects($this->once())
->method('deleteOverThreshold')
diff --git a/tests/api/feeds.bats b/tests/api/feeds.bats
new file mode 100644
index 000000000..845a18eda
--- /dev/null
+++ b/tests/api/feeds.bats
@@ -0,0 +1,145 @@
+#!/usr/bin/env bats
+
+setup_file(){
+ load "helpers/settings"
+
+ if test -f "tests/api/helpers/settings-override.bash"; then
+ load "helpers/settings-override"
+ fi
+
+ export APP_PASSWORD=$(NC_PASS=${user} ./occ user:add-app-password ${user} --password-from-env | grep -Po '([A-Z|a-z|0-9]{72})')
+}
+
+teardown_file(){
+ http --ignore-stdin -b -a ${user}:${APP_PASSWORD} DELETE ${NC_HOST}/ocs/v2.php/core/apppassword OCS-APIRequest:true
+}
+
+setup() {
+ load "../test_helper/bats-support/load"
+ load "../test_helper/bats-assert/load"
+}
+
+TESTSUITE="Feeds"
+
+teardown() {
+ # delete all feeds
+ ID_LIST=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds | grep -Po '"id":\K([0-9]+)' | tr '\n' ' '))
+ for i in $ID_LIST; do
+ http --ignore-stdin -b -a ${user}:${APP_PASSWORD} DELETE ${BASE_URLv1}/feeds/$i > /dev/null
+ done
+
+ # delete all folders
+ ID_LIST=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/folders | grep -Po '"id":\K([0-9]+)' | tr '\n' ' '))
+ for i in $ID_LIST; do
+ http --ignore-stdin -b -a ${user}:${APP_PASSWORD} DELETE ${BASE_URLv1}/folders/$i > /dev/null
+ done
+}
+
+@test "[$TESTSUITE] Read empty" {
+ run http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds
+
+ assert_output --partial "\"feeds\":[]"
+ assert_output --partial "\"starredCount\":0"
+}
+
+@test "[$TESTSUITE] Create new" {
+ # run is not working here.
+ output=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$NC_FEED | jq '.feeds | .[0].url')
+
+ assert_output '"http://localhost:8090/Nextcloud.rss"'
+}
+
+@test "[$TESTSUITE] Create new inside folder" {
+ # create folder and store id
+ ID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/folders name=news-${BATS_SUITE_TEST_NUMBER} | grep -Po '"id":\K([0-9]+)')
+
+ # run is not working here.
+ output=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$NC_FEED folderId=$ID | jq '.feeds | .[0].folderId')
+
+ # check if ID matches
+ assert_output "$ID"
+}
+
+@test "[$TESTSUITE] Delete one" {
+ ID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$NC_FEED | grep -Po '"id":\K([0-9]+)')
+
+ run http --ignore-stdin -b -a ${user}:${APP_PASSWORD} DELETE ${BASE_URLv1}/feeds/$ID
+
+ assert_output "[]"
+}
+
+@test "[$TESTSUITE] Move feed to different folder" {
+ # create folders and store ids
+ FIRST_FOLDER_ID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/folders name=news-${BATS_SUITE_TEST_NUMBER} | grep -Po '"id":\K([0-9]+)')
+ SECCOND_FOLDER_ID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/folders name=news-${BATS_SUITE_TEST_NUMBER} | grep -Po '"id":\K([0-9]+)')
+
+ FEEDID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$NC_FEED folderId=$FIRST_FOLDER_ID | grep -Po '"id":\K([0-9]+)')
+
+ # move feed, returns nothing
+ http --ignore-stdin -b -a ${user}:${APP_PASSWORD} PUT ${BASE_URLv1}/feeds/$FEEDID/move folderId=$SECCOND_FOLDER_ID
+
+ # run is not working here.
+ output=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds | jq '.feeds | .[0].folderId')
+
+ # look for second folder id
+ assert_output "$SECCOND_FOLDER_ID"
+}
+
+@test "[$TESTSUITE] Move feed to root" {
+ # create folder and store id
+ FOLDER_ID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/folders name=news-${BATS_SUITE_TEST_NUMBER} | grep -Po '"id":\K([0-9]+)')
+
+ FEEDID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$NC_FEED folderId=$FOLDER_ID | grep -Po '"id":\K([0-9]+)')
+
+ # move feed to "null", returns nothing
+ http --ignore-stdin -b -a ${user}:${APP_PASSWORD} PUT ${BASE_URLv1}/feeds/$FEEDID/move folderId=null
+
+ # run is not working here.
+ output=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds | jq '.feeds | .[0].folderId')
+
+ # new "folder" should be null
+ assert_output null
+}
+
+@test "[$TESTSUITE] Rename feed" {
+ # create feed and store id
+ FEEDID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$NC_FEED | grep -Po '"id":\K([0-9]+)')
+
+ # rename feed, returns nothing
+ http --ignore-stdin -b -a ${user}:${APP_PASSWORD} PUT ${BASE_URLv1}/feeds/$FEEDID/rename feedTitle="Great Title"
+
+ # run is not working here.
+ output=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds | jq '.feeds | .[0].title')
+
+ # Check if title matches
+ assert_output '"Great Title"'
+}
+
+@test "[$TESTSUITE] Mark all items as read" {
+ # create feed and store id
+ FEEDID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$NC_FEED | grep -Po '"id":\K([0-9]+)')
+
+ ID_LIST=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items id=$FEEDID | grep -Po '"id":\K([0-9]+)' | tr '\n' ' '))
+
+ # get biggest item ID
+ max=${ID_LIST[0]}
+ for n in "${ID_LIST[@]}" ; do
+ ((n > max)) && max=$n
+ done
+
+ # mark all items