diff options
Diffstat (limited to 'tests/unit/db')
-rw-r--r-- | tests/unit/db/ItemMapperTest.php | 78 |
1 files changed, 55 insertions, 23 deletions
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; |