diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Unit/Db/FeedMapperTest.php | 161 | ||||
-rw-r--r-- | tests/Unit/Db/FolderMapperTest.php | 160 | ||||
-rw-r--r-- | tests/Unit/Db/ItemMapperAfterTest.php | 20 | ||||
-rw-r--r-- | tests/Unit/Db/ItemMapperPaginatedTest.php | 18 | ||||
-rw-r--r-- | tests/Unit/Db/ItemMapperTest.php | 83 | ||||
-rw-r--r-- | tests/Unit/Db/MapperTestUtility.php | 1 | ||||
-rw-r--r-- | tests/integration/feeds.bats | 21 | ||||
-rw-r--r-- | tests/integration/folders.bats | 17 |
8 files changed, 389 insertions, 92 deletions
diff --git a/tests/Unit/Db/FeedMapperTest.php b/tests/Unit/Db/FeedMapperTest.php index 780bfbc38..ad2417b53 100644 --- a/tests/Unit/Db/FeedMapperTest.php +++ b/tests/Unit/Db/FeedMapperTest.php @@ -13,12 +13,15 @@ namespace OCA\News\Tests\Unit\Db; +use OC\DB\QueryBuilder\Parameter; +use OC\DB\ResultAdapter; use OCA\News\Db\Feed; use OCA\News\Db\FeedMapperV2; use OCA\News\Utility\Time; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\MultipleObjectsReturnedException; use OCP\DB\QueryBuilder\IFunctionBuilder; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryFunction; class FeedMapperTest extends MapperTestUtility @@ -457,39 +460,96 @@ class FeedMapperTest extends MapperTestUtility */ public function testRead() { - $this->db->expects($this->once()) + $selectbuilder = $this->getMockBuilder(IQueryBuilder::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->db->expects($this->exactly(2)) ->method('getQueryBuilder') - ->willReturn($this->builder); + ->willReturnOnConsecutiveCalls($selectbuilder, $this->builder); - $this->builder->expects($this->once()) - ->method('update') + $selectbuilder->expects($this->once()) + ->method('select') + ->with('items.id') + ->will($this->returnSelf()); + + $selectbuilder->expects($this->once()) + ->method('from') ->with('news_items', 'items') ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $selectbuilder->expects($this->once()) ->method('innerJoin') ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id') ->will($this->returnSelf()); + $selectbuilder->expects($this->exactly(2)) + ->method('andWhere') + ->withConsecutive(['feeds.user_id = :userId'], ['feeds.id = :feedId']) + ->will($this->returnSelf()); + + $selectbuilder->expects($this->exactly(2)) + ->method('setParameter') + ->withConsecutive(['userId', 'admin'], ['feedId', 1]) + ->will($this->returnSelf()); + + $selectbuilder->expects($this->exactly(1)) + ->method('getSQL') + ->will($this->returnValue('SQL QUERY')); + + $selectbuilder->expects($this->exactly(1)) + ->method('getParameters') + ->will($this->returnValue([])); + + $result = $this->getMockBuilder(ResultAdapter::class) + ->disableOriginalConstructor() + ->getMock(); + + $result->expects($this->once()) + ->method('fetchAll') + ->willReturn([['id' => 1], ['id' => 2]]); + + $this->db->expects($this->exactly(1)) + ->method('executeQuery') + ->with('SQL QUERY') + ->willReturn($result); + + $this->builder->expects($this->once()) + ->method('update') + ->with('news_items') + ->will($this->returnSelf()); + + $this->builder->expects($this->once()) + ->method('createParameter') + ->will($this->returnArgument(0)); + $this->builder->expects($this->once()) - ->method('setValue') - ->with('unread', 0) + ->method('set') + ->with('unread', 'unread') ->will($this->returnSelf()); $this->builder->expects($this->exactly(2)) ->method('andWhere') - ->withConsecutive(['feeds.user_id = :userId'], ['feeds.id = :feedId']) + ->withConsecutive(['id IN (:idList)'], ['unread != :unread']) ->will($this->returnSelf()); $this->builder->expects($this->exactly(2)) ->method('setParameter') - ->withConsecutive(['userId', 'admin'], ['feedId', 1]) + ->withConsecutive(['unread', false], ['idList', [1, 2]]) ->will($this->returnSelf()); $this->builder->expects($this->exactly(1)) ->method('getSQL') ->will($this->returnValue('QUERY')); + $this->builder->expects($this->exactly(1)) + ->method('getParameters') + ->will($this->returnValue([])); + + $this->builder->expects($this->exactly(1)) + ->method('getParameterTypes') + ->will($this->returnValue([])); + $this->db->expects($this->exactly(1)) ->method('executeUpdate') ->with('QUERY'); @@ -500,45 +560,102 @@ class FeedMapperTest extends MapperTestUtility /** * @covers \OCA\News\Db\FeedMapperV2::read */ - public function testReadWithMaxId() + public function testReadWithMaxID() { - $this->db->expects($this->once()) + $selectbuilder = $this->getMockBuilder(IQueryBuilder::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->db->expects($this->exactly(2)) ->method('getQueryBuilder') - ->willReturn($this->builder); + ->willReturnOnConsecutiveCalls($selectbuilder, $this->builder); - $this->builder->expects($this->once()) - ->method('update') + $selectbuilder->expects($this->once()) + ->method('select') + ->with('items.id') + ->will($this->returnSelf()); + + $selectbuilder->expects($this->once()) + ->method('from') ->with('news_items', 'items') ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $selectbuilder->expects($this->once()) ->method('innerJoin') ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id') ->will($this->returnSelf()); + $selectbuilder->expects($this->exactly(3)) + ->method('andWhere') + ->withConsecutive(['feeds.user_id = :userId'], ['feeds.id = :feedId'], ['items.id <= :maxItemId']) + ->will($this->returnSelf()); + + $selectbuilder->expects($this->exactly(3)) + ->method('setParameter') + ->withConsecutive(['userId', 'admin'], ['feedId', 1], ['maxItemId', 4]) + ->will($this->returnSelf()); + + $selectbuilder->expects($this->exactly(1)) + ->method('getSQL') + ->will($this->returnValue('SQL QUERY')); + + $selectbuilder->expects($this->exactly(1)) + ->method('getParameters') + ->will($this->returnValue([])); + + $result = $this->getMockBuilder(ResultAdapter::class) + ->disableOriginalConstructor() + ->getMock(); + + $result->expects($this->once()) + ->method('fetchAll') + ->willReturn([['id' => 1], ['id' => 2]]); + + $this->db->expects($this->exactly(1)) + ->method('executeQuery') + ->with('SQL QUERY') + ->willReturn($result); + + $this->builder->expects($this->once()) + ->method('createParameter') + ->will($this->returnArgument(0)); + + $this->builder->expects($this->once()) + ->method('update') + ->with('news_items') + ->will($this->returnSelf()); + $this->builder->expects($this->once()) - ->method('setValue') - ->with('unread', 0) + ->method('set') + ->with('unread', 'unread') ->will($this->returnSelf()); - $this->builder->expects($this->exactly(3)) + $this->builder->expects($this->exactly(2)) ->method('andWhere') - ->withConsecutive(['feeds.user_id = :userId'], ['feeds.id = :feedId'], ['items.id =< :maxItemId']) + ->withConsecutive(['id IN (:idList)'], ['unread != :unread']) ->will($this->returnSelf()); - $this->builder->expects($this->exactly(3)) + $this->builder->expects($this->exactly(2)) ->method('setParameter') - ->withConsecutive(['userId', 'admin'], ['feedId', 1], ['maxItemId', 4]) + ->withConsecutive(['unread', false], ['idList', [1, 2]]) ->will($this->returnSelf()); $this->builder->expects($this->exactly(1)) ->method('getSQL') ->will($this->returnValue('QUERY')); + $this->builder->expects($this->exactly(1)) + ->method('getParameters') + ->will($this->returnValue([])); + + $this->builder->expects($this->exactly(1)) + ->method('getParameterTypes') + ->will($this->returnValue([])); + $this->db->expects($this->exactly(1)) ->method('executeUpdate') ->with('QUERY'); $this->class->read('admin', 1, 4); } -}
\ No newline at end of file +} diff --git a/tests/Unit/Db/FolderMapperTest.php b/tests/Unit/Db/FolderMapperTest.php index 026c16bc6..ad44d618f 100644 --- a/tests/Unit/Db/FolderMapperTest.php +++ b/tests/Unit/Db/FolderMapperTest.php @@ -13,11 +13,14 @@ namespace OCA\News\Tests\Unit\Db; +use OC\DB\QueryBuilder\Parameter; +use OC\DB\ResultAdapter; use OCA\News\Db\Folder; use OCA\News\Db\FolderMapperV2; use OCA\News\Utility\Time; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\MultipleObjectsReturnedException; +use OCP\DB\QueryBuilder\IQueryBuilder; class FolderMapperTest extends MapperTestUtility { @@ -285,39 +288,96 @@ class FolderMapperTest extends MapperTestUtility */ public function testRead() { - $this->db->expects($this->once()) + $selectbuilder = $this->getMockBuilder(IQueryBuilder::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->db->expects($this->exactly(2)) ->method('getQueryBuilder') - ->willReturn($this->builder); + ->willReturnOnConsecutiveCalls($selectbuilder, $this->builder); - $this->builder->expects($this->once()) - ->method('update') + $selectbuilder->expects($this->once()) + ->method('select') + ->with('items.id') + ->will($this->returnSelf()); + + $selectbuilder->expects($this->once()) + ->method('from') ->with('news_items', 'items') ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $selectbuilder->expects($this->once()) ->method('innerJoin') ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id') ->will($this->returnSelf()); + $selectbuilder->expects($this->exactly(2)) + ->method('andWhere') + ->withConsecutive(['feeds.user_id = :userId'], ['feeds.folder_id = :folderId']) + ->will($this->returnSelf()); + + $selectbuilder->expects($this->exactly(2)) + ->method('setParameter') + ->withConsecutive(['userId', 'admin'], ['folderId', 1]) + ->will($this->returnSelf()); + + $selectbuilder->expects($this->exactly(1)) + ->method('getSQL') + ->will($this->returnValue('SQL QUERY')); + + $selectbuilder->expects($this->exactly(1)) + ->method('getParameters') + ->will($this->returnValue([])); + + $result = $this->getMockBuilder(ResultAdapter::class) + ->disableOriginalConstructor() + ->getMock(); + + $result->expects($this->once()) + ->method('fetchAll') + ->willReturn([['id' => 1], ['id' => 2]]); + + $this->db->expects($this->exactly(1)) + ->method('executeQuery') + ->with('SQL QUERY') + ->willReturn($result); + + $this->builder->expects($this->once()) + ->method('createParameter') + ->will($this->returnArgument(0)); + + $this->builder->expects($this->once()) + ->method('update') + ->with('news_items') + ->will($this->returnSelf()); + $this->builder->expects($this->once()) - ->method('setValue') - ->with('unread', 0) + ->method('set') + ->with('unread', 'unread') ->will($this->returnSelf()); $this->builder->expects($this->exactly(2)) ->method('andWhere') - ->withConsecutive(['feeds.user_id = :userId'], ['feeds.folder_id = :folderId']) + ->withConsecutive(['id IN (:idList)'], ['unread != :unread']) ->will($this->returnSelf()); $this->builder->expects($this->exactly(2)) ->method('setParameter') - ->withConsecutive(['userId', 'admin'], ['folderId', 1]) + ->withConsecutive(['unread', false], ['idList', [1, 2]]) ->will($this->returnSelf()); $this->builder->expects($this->exactly(1)) ->method('getSQL') ->will($this->returnValue('QUERY')); + $this->builder->expects($this->exactly(1)) + ->method('getParameters') + ->will($this->returnValue([])); + + $this->builder->expects($this->exactly(1)) + ->method('getParameterTypes') + ->will($this->returnValue([])); + $this->db->expects($this->exactly(1)) ->method('executeUpdate') ->with('QUERY'); @@ -330,43 +390,101 @@ class FolderMapperTest extends MapperTestUtility */ public function testReadWithMaxId() { - $this->db->expects($this->once()) + + $selectbuilder = $this->getMockBuilder(IQueryBuilder::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->db->expects($this->exactly(2)) ->method('getQueryBuilder') - ->willReturn($this->builder); + ->willReturnOnConsecutiveCalls($selectbuilder, $this->builder); - $this->builder->expects($this->once()) - ->method('update') + $selectbuilder->expects($this->once()) + ->method('select') + ->with('items.id') + ->will($this->returnSelf()); + + $selectbuilder->expects($this->once()) + ->method('from') ->with('news_items', 'items') ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $selectbuilder->expects($this->once()) ->method('innerJoin') ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id') ->will($this->returnSelf()); + $selectbuilder->expects($this->exactly(3)) + ->method('andWhere') + ->withConsecutive(['feeds.user_id = :userId'], ['feeds.folder_id = :folderId'], ['items.id <= :maxItemId']) + ->will($this->returnSelf()); + + $selectbuilder->expects($this->exactly(3)) + ->method('setParameter') + ->withConsecutive(['userId', 'admin'], ['folderId', 1], ['maxItemId', 4]) + ->will($this->returnSelf()); + + $selectbuilder->expects($this->exactly(1)) + ->method('getSQL') + ->will($this->returnValue('SQL QUERY')); + + $selectbuilder->expects($this->exactly(1)) + ->method('getParameters') + ->will($this->returnValue([])); + + $result = $this->getMockBuilder(ResultAdapter::class) + ->disableOriginalConstructor() + ->getMock(); + + $result->expects($this->once()) + ->method('fetchAll') + ->willReturn([['id' => 1], ['id' => 2]]); + + $this->db->expects($this->exactly(1)) + ->method('executeQuery') + ->with('SQL QUERY') + ->willReturn($result); + + $this->builder->expects($this->once()) + ->method('createParameter') + ->will($this->returnArgument(0)); + + $this->builder->expects($this->once()) + ->method('update') + ->with('news_items') + ->will($this->returnSelf()); + $this->builder->expects($this->once()) - ->method('setValue') - ->with('unread', 0) + ->method('set') + ->with('unread', 'unread') ->will($this->returnSelf()); - $this->builder->expects($this->exactly(3)) + $this->builder->expects($this->exactly(2)) ->method('andWhere') - ->withConsecutive(['feeds.user_id = :userId'], ['feeds.folder_id = :folderId'], ['items.id =< :maxItemId']) + ->withConsecutive(['id IN (:idList)'], ['unread != :unread']) ->will($this->returnSelf()); - $this->builder->expects($this->exactly(3)) + $this->builder->expects($this->exactly(2)) ->method('setParameter') - ->withConsecutive(['userId', 'admin'], ['folderId', 1], ['maxItemId', 4]) + ->withConsecutive(['unread', false], ['idList', [1, 2]]) ->will($this->returnSelf()); $this->builder->expects($this->exactly(1)) ->method('getSQL') ->will($this->returnValue('QUERY')); + $this->builder->expects($this->exactly(1)) + ->method('getParameters') + ->will($this->returnValue([])); + + $this->builder->expects($this->exactly(1)) + ->method('getParameterTypes') + ->will($this->returnValue([])); + $this->db->expects($this->exactly(1)) ->method('executeUpdate') ->with('QUERY'); $this->class->read('admin', 1, 4); } -}
\ No newline at end of file +} diff --git a/tests/Unit/Db/ItemMapperAfterTest.php b/tests/Unit/Db/ItemMapperAfterTest.php index 5c536e1bf..5b0475522 100644 --- a/tests/Unit/Db/ItemMapperAfterTest.php +++ b/tests/Unit/Db/ItemMapperAfterTest.php @@ -13,24 +13,10 @@ 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; use OCA\News\Db\Item; use OCA\News\Db\ItemMapperV2; -use OCA\News\Db\NewsMapperV2; use OCA\News\Service\Exceptions\ServiceValidationException; use OCA\News\Utility\Time; -use OCP\AppFramework\Db\DoesNotExistException; -use OCP\AppFramework\Db\MultipleObjectsReturnedException; -use OCP\DB\IResult; -use OCP\DB\QueryBuilder\IExpressionBuilder; -use OCP\DB\QueryBuilder\IFunctionBuilder; -use OCP\DB\QueryBuilder\IQueryBuilder; -use OCP\DB\QueryBuilder\IQueryFunction; -use OCP\IDBConnection; -use Test\TestCase; /** * Class ItemMapperTest @@ -40,8 +26,6 @@ use Test\TestCase; class ItemMapperAfterTest extends MapperTestUtility { - /** @var Time */ - private $time; /** @var ItemMapperV2 */ private $class; @@ -51,10 +35,10 @@ class ItemMapperAfterTest extends MapperTestUtility protected function setUp(): void { parent::setUp(); - $this->time = $this->getMockBuilder(Time::class) + $time = $this->getMockBuilder(Time::class) ->getMock(); - $this->class = new ItemMapperV2($this->db, $this->time); + $this->class = new ItemMapperV2($this->db, $time); } public function testFindAllInFeedAfter() diff --git a/tests/Unit/Db/ItemMapperPaginatedTest.php b/tests/Unit/Db/ItemMapperPaginatedTest.php index e242833fb..6bd6906d3 100644 --- a/tests/Unit/Db/ItemMapperPaginatedTest.php +++ b/tests/Unit/Db/ItemMapperPaginatedTest.php @@ -14,23 +14,11 @@ 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; use OCA\News\Db\Item; use OCA\News\Db\ItemMapperV2; -use OCA\News\Db\NewsMapperV2; use OCA\News\Service\Exceptions\ServiceValidationException; use OCA\News\Utility\Time; -use OCP\AppFramework\Db\DoesNotExistException; -use OCP\AppFramework\Db\MultipleObjectsReturnedException; -use OCP\DB\IResult; use OCP\DB\QueryBuilder\IExpressionBuilder; -use OCP\DB\QueryBuilder\IFunctionBuilder; -use OCP\DB\QueryBuilder\IQueryBuilder; -use OCP\DB\QueryBuilder\IQueryFunction; -use OCP\IDBConnection; -use Test\TestCase; /** * Class ItemMapperTest @@ -40,8 +28,6 @@ use Test\TestCase; class ItemMapperPaginatedTest extends MapperTestUtility { - /** @var Time */ - private $time; /** @var ItemMapperV2 */ private $class; @@ -51,10 +37,10 @@ class ItemMapperPaginatedTest extends MapperTestUtility protected function setUp(): void { parent::setUp(); - $this->time = $this->getMockBuilder(Time::class) + $time = $this->getMockBuilder(Time::class) ->getMock(); - $this->class = new ItemMapperV2($this->db, $this->time); + $this->class = new ItemMapperV2($this->db, $time); } public function testFindAllItemsInvalid() diff --git a/tests/Unit/Db/ItemMapperTest.php b/tests/Unit/Db/ItemMapperTest.php index 490f13e71..5cb42c3fa 100644 --- a/tests/Unit/Db/ItemMapperTest.php +++ b/tests/Unit/Db/ItemMapperTest.php @@ -14,6 +14,8 @@ namespace OCA\News\Tests\Unit\Db; use OC\DB\QueryBuilder\Literal; +use OC\DB\QueryBuilder\Parameter; +use OC\DB\ResultAdapter; use OCA\News\Db\Feed; use OCA\News\Db\FeedMapperV2; use OCA\News\Db\Folder; @@ -472,44 +474,101 @@ class ItemMapperTest extends MapperTestUtility public function testReadAll() { - $this->db->expects($this->once()) + $selectbuilder = $this->getMockBuilder(IQueryBuilder::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->db->expects($this->exactly(2)) ->method('getQueryBuilder') - ->willReturn($this->builder); + ->willReturnOnConsecutiveCalls($selectbuilder, $this->builder); - $this->builder->expects($this->once()) - ->method('update') + $selectbuilder->expects($this->once()) + ->method('select') + ->with('items.id') + ->will($this->returnSelf()); + + $selectbuilder->expects($this->once()) + ->method('from') ->with('news_items', 'items') ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $selectbuilder->expects($this->once()) ->method('innerJoin') ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id') ->will($this->returnSelf()); + $selectbuilder->expects($this->exactly(2)) + ->method('andWhere') + ->withConsecutive(['feeds.user_id = :userId'], ['items.id <= :maxItemId']) + ->will($this->returnSelf()); + + $selectbuilder->expects($this->exactly(2)) + ->method('setParameter') + ->withConsecutive(['userId', 'admin'], ['maxItemId', 4]) + ->will($this->returnSelf()); + + $selectbuilder->expects($this->exactly(1)) + ->method('getSQL') + ->will($this->returnValue('SQL QUERY')); + + $selectbuilder->expects($this->exactly(1)) + ->method('getParameters') + ->will($this->returnValue([])); + + $result = $this->getMockBuilder(ResultAdapter::class) + ->disableOriginalConstructor() + ->getMock(); + + $result->expects($this->once()) + ->method('fetchAll') + ->willReturn([['id' => 1], ['id' => 2]]); + + $this->db->expects($this->exactly(1)) + ->method('executeQuery') + ->with('SQL QUERY') + ->willReturn($result); + + $this->builder->expects($this->once()) + ->method('createParameter') + ->will($this->returnArgument(0)); + + $this->builder->expects($this->once()) + ->method('update') + ->with('news_items') + ->will($this->returnSelf()); + $this->builder->expects($this->once()) - ->method('setValue') - ->with('unread', 0) + ->method('set') + ->with('unread', 'unread') ->will($this->returnSelf()); $this->builder->expects($this->exactly(2)) ->method('andWhere') - ->withConsecutive(['items.id =< :maxItemId'], ['feeds.user_id = :userId']) + ->withConsecutive(['id IN (:idList)'], ['unread != :unread']) ->will($this->returnSelf()); $this->builder->expects($this->exactly(2)) ->method('setParameter') - ->withConsecutive(['maxItemId', 4], ['userId', 'jack']) + ->withConsecutive(['unread', false], ['idList', [1, 2]]) ->will($this->returnSelf()); $this->builder->expects($this->exactly(1)) ->method('getSQL') ->will($this->returnValue('QUERY')); - $this->db->expects($this->once()) + $this->builder->expects($this->exactly(1)) + ->method('getParameters') + ->will($this->returnValue([])); + + $this->builder->expects($this->exactly(1)) + ->method('getParameterTypes') + ->will($this->returnValue([])); + + $this->db->expects($this->exactly(1)) ->method('executeUpdate') ->with('QUERY'); - $this->class->readAll('jack', 4); + $this->class->readAll('admin', 4); } public function testPurgeDeletedEmpty() @@ -1055,4 +1114,4 @@ class ItemMapperTest extends MapperTestUtility $this->assertSame(10, $res); } -}
\ No newline at end of file +} diff --git a/tests/Unit/Db/MapperTestUtility.php b/tests/Unit/Db/MapperTestUtility.php index 4a875fde5..b5ef782c2 100644 --- a/tests/Unit/Db/MapperTestUtility.php +++ b/tests/Unit/Db/MapperTestUtility.php @@ -24,7 +24,6 @@ namespace OCA\News\Tests\Unit\Db; use Doctrine\DBAL\Driver\Statement; -use OC\DB\QueryBuilder\QueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; diff --git a/tests/integration/feeds.bats b/tests/integration/feeds.bats index d8f0aad8c..2701cbfa9 100644 --- a/tests/integration/feeds.bats +++ b/tests/integration/feeds.bats @@ -57,6 +57,25 @@ teardown() { fi } +@test "[$TESTSUITE] Read all" { + ./occ news:feed:add "$user" "$NC_FEED" --title "Something-${BATS_SUITE_TEST_NUMBER}" + + run ./occ news:feed:list "$user" + [ "$status" -eq 0 ] + + echo "$output" | grep "Something-${BATS_SUITE_TEST_NUMBER}" + + ID=$(./occ news:feed:list 'admin' | grep "Something-${BATS_SUITE_TEST_NUMBER}" -2 | head -1 | grep -oE '[0-9]*') + run ./occ news:feed:read "$user" "$ID" -v + [ "$status" -eq 0 ] + + if ! echo "$output" | grep "items as read"; then + ret_status=$? + echo "Feed not read" + return $ret_status + fi +} + @test "[$TESTSUITE] Delete all" { ./occ news:feed:add "$user" "$NC_FEED" --title "Something-${BATS_SUITE_TEST_NUMBER}" @@ -68,4 +87,4 @@ teardown() { ID=$(./occ news:feed:list 'admin' | grep "Something-${BATS_SUITE_TEST_NUMBER}" -2 | head -1 | grep -oE '[0-9]*') run ./occ news:feed:delete "$user" "$ID" [ "$status" -eq 0 ] -}
\ No newline at end of file +} diff --git a/tests/integration/folders.bats b/tests/integration/folders.bats index 9dde06861..48b15f05b 100644 --- a/tests/integration/folders.bats +++ b/tests/integration/folders.bats @@ -36,6 +36,21 @@ teardown() { fi } +@test "[$TESTSUITE] Read all" { + ./occ news:folder:add "$user" "Something-${BATS_SUITE_TEST_NUMBER}" + + ID=$(./occ news:folder:list 'admin' | grep "Something-${BATS_SUITE_TEST_NUMBER}" -1 | head -1 | grep -oE '[0-9]*') + + run ./occ news:folder:read "$user" "$ID" -v + [ "$status" -eq 0 ] + + if ! echo "$output" | grep "items as read"; then + ret_status=$? + echo "Folder not read" + return $ret_status + fi +} + @test "[$TESTSUITE] Delete all" { ID=$(./occ news:folder:add "$user" "Something-${BATS_SUITE_TEST_NUMBER}" | grep -oE '[0-9]*') @@ -46,4 +61,4 @@ t |