From 3fc18156ae0b586e8de0c82949acfa6291317536 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 29 Apr 2013 13:25:04 +0200 Subject: go back to order by id, fix #138, use a newest item id to prevent marking items as read that the user didnt see yet fix #141, also update the starred count periodically --- tests/unit/db/ItemMapperTest.php | 78 ++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 23 deletions(-) (limited to 'tests/unit/db') diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php index ff5bb1f4c..764042d36 100644 --- a/tests/unit/db/ItemMapperTest.php +++ b/tests/unit/db/ItemMapperTest.php @@ -194,17 +194,28 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility { } - public function testFindAll(){ - $sql = 'AND `items`.`id` < ? ' . - 'ORDER BY `items`.`pub_date` DESC, `items`.`id` DESC '; + public function testFindAllFeed(){ + $sql = 'AND `items`.`feed_id` = ? ' . + 'AND `items`.`id` < ? ' . + 'ORDER BY `items`.`id` DESC '; $sql = $this->makeSelectQueryStatus($sql, $this->status); - $params = array($this->user, $this->newestItemId); - $this->setMapperResult($sql, $params, $this->rows, - $this->limit, $this->offset); + $params = array($this->user, $this->id, $this->offset); + $this->setMapperResult($sql, $params, $this->rows); + $result = $this->mapper->findAllFeed($this->id, $this->limit, + $this->offset, $this->status, $this->user); + + $this->assertEquals($this->items, $result); + } - $result = $this->mapper->findAll($this->limit, - $this->offset, $this->newestItemId, - $this->status, $this->user); + + public function testFindAllFeedOffsetZero(){ + $sql = 'AND `items`.`feed_id` = ? ' . + 'ORDER BY `items`.`id` DESC '; + $sql = $this->makeSelectQueryStatus($sql, $this->status); + $params = array($this->user, $this->id); + $this->setMapperResult($sql, $params, $this->rows); + $result = $this->mapper->findAllFeed($this->id, $this->limit, + 0, $this->status, $this->user); $this->assertEquals($this->items, $result); } @@ -213,37 +224,58 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility { public function testFindAllFolder(){ $sql = 'AND `feeds`.`folder_id` = ? ' . 'AND `items`.`id` < ? ' . - 'ORDER BY `items`.`pub_date` DESC, `items`.`id` DESC '; + 'ORDER BY `items`.`id` DESC '; $sql = $this->makeSelectQueryStatus($sql, $this->status); - $params = array($this->user, $this->id, $this->newestItemId); + $params = array($this->user, $this->id, + $this->offset); + $this->setMapperResult($sql, $params, $this->rows); + $result = $this->mapper->findAllFolder($this->id, $this->limit, + $this->offset, $this->status, $this->user); + + $this->assertEquals($this->items, $result); + } - $this->setMapperResult($sql, $params, $this->rows, - $this->limit, $this->offset); + public function testFindAllFolderOffsetZero(){ + $sql = 'AND `feeds`.`folder_id` = ? ' . + 'ORDER BY `items`.`id` DESC '; + $sql = $this->makeSelectQueryStatus($sql, $this->status); + $params = array($this->user, $this->id); + $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAllFolder($this->id, $this->limit, - $this->offset, $this->newestItemId, $this->status, $this->user); + 0, $this->status, $this->user); $this->assertEquals($this->items, $result); } - public function testFindAllFeed(){ - $sql = 'AND `items`.`feed_id` = ? ' . - 'AND `items`.`id` < ? ' . - 'ORDER BY `items`.`pub_date` DESC, `items`.`id` DESC '; + public function testFindAll(){ + $sql = 'AND `items`.`id` < ? ' . + 'ORDER BY `items`.`id` DESC '; $sql = $this->makeSelectQueryStatus($sql, $this->status); - $params = array($this->user, $this->id, $this->newestItemId); - $this->setMapperResult($sql, $params, $this->rows, $this->limit, - $this->offset); + $params = array($this->user, $this->offset); + $this->setMapperResult($sql, $params, $this->rows); + $result = $this->mapper->findAll($this->limit, + $this->offset, $this->status, $this->user); - $result = $this->mapper->findAllFeed($this->id, $this->limit, - $this->offset, $this->newestItemId, $this->status, $this->user); + $this->assertEquals($this->items, $result); + } + + + public function testFindAllOffsetZero(){ + $sql = 'ORDER BY `items`.`id` DESC '; + $sql = $this->makeSelectQueryStatus($sql, $this->status); + $params = array($this->user); + $this->setMapperResult($sql, $params, $this->rows); + $result = $this->mapper->findAll($this->limit, + 0, $this->status, $this->user); $this->assertEquals($this->items, $result); } + public function testFindByGuidHash(){ $hash = md5('test'); $feedId = 3; -- cgit v1.2.3