summaryrefslogtreecommitdiffstats
path: root/tests/unit/db/ItemMapperTest.php
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-05-09 12:57:35 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-05-09 12:57:35 +0200
commitb8b4dfb4969e1baf84a14fb65a5dc153b0f5fae4 (patch)
tree27e211e26f442efd72a7f34903953ad57b1a9b76 /tests/unit/db/ItemMapperTest.php
parentfe0de2ab84a88cb4c742f4f10fd43716934b7282 (diff)
only make one request for mark all read and mark folder read, fix #171, fix a bug that prevented readding of feeds when its folder was deleted, fix a bug that would not allow mark read for feeds when the app was started for the first time
Diffstat (limited to 'tests/unit/db/ItemMapperTest.php')
-rw-r--r--tests/unit/db/ItemMapperTest.php44
1 files changed, 32 insertions, 12 deletions
diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php
index 764042d36..6d0de6459 100644
--- a/tests/unit/db/ItemMapperTest.php
+++ b/tests/unit/db/ItemMapperTest.php
@@ -125,34 +125,54 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
}
- public function testReadFeed(){
+ public function testReadAll(){
$sql = 'UPDATE `*PREFIX*news_items` ' .
'SET `status` = `status` & ? ' .
- 'WHERE `feed_id` = ? ' .
- 'AND `id` <= ? ' .
- 'AND EXISTS (' .
- 'SELECT * FROM `*PREFIX*news_feeds` ' .
- 'WHERE `user_id` = ? ' .
- 'AND `id` = ? ) ';
- $params = array(~StatusFlag::UNREAD, 3, 6, $this->user, 3);
+ 'WHERE `id` IN (' .
+ 'SELECT `items`.`id` FROM `*PREFIX*news_items` `items` ' .
+ 'JOIN `*PREFIX*news_feeds` `feeds` ' .
+ 'ON `feeds`.`id` = `items`.`feed_id` '.
+ 'AND `items`.`id` <= ? ' .
+ 'AND `feeds`.`user_id` = ? ' .
+ ') ';
+ $params = array(~StatusFlag::UNREAD, 3, $this->user);
$this->setMapperResult($sql, $params);
- $this->mapper->readFeed(3, 6, $this->user);
+ $this->mapper->readAll(3, $this->user);
+ }
+
+
+ public function testReadFolder(){
+ $sql = 'UPDATE `*PREFIX*news_items` ' .
+ 'SET `status` = `status` & ? ' .
+ 'WHERE `id` IN (' .
+ 'SELECT `items`.`id` FROM `*PREFIX*news_items` `items` ' .
+ 'JOIN `*PREFIX*news_feeds` `feeds` ' .
+ 'ON `feeds`.`id` = `items`.`feed_id` '.
+ 'AND `feeds`.`folder_id` = ? ' .
+ 'AND `items`.`id` <= ? ' .
+ 'AND `feeds`.`user_id` = ? ' .
+ ') ';
+ $params = array(~StatusFlag::UNREAD, 3, 6, $this->user);
+ $this->setMapperResult($sql, $params);
+ $this->mapper->readFolder(3, 6, $this->user);
}
- public function testReadFeedShouldMarkAllAsReadWhenIdZero(){
+ public function testReadFeed(){
$sql = 'UPDATE `*PREFIX*news_items` ' .
'SET `status` = `status` & ? ' .
'WHERE `feed_id` = ? ' .
+ 'AND `id` <= ? ' .
'AND EXISTS (' .
'SELECT * FROM `*PREFIX*news_feeds` ' .
'WHERE `user_id` = ? ' .
'AND `id` = ? ) ';
- $params = array(~StatusFlag::UNREAD, 3,$this->user, 3);
+ $params = array(~StatusFlag::UNREAD, 3, 6, $this->user, 3);
$this->setMapperResult($sql, $params);
- $this->mapper->readFeed(3, 0, $this->user);
+ $this->mapper->readFeed(3, 6, $this->user);
}
+
public function testFindAllNew(){
$sql = 'AND `items`.`last_modified` >= ?';
$sql = $this->makeSelectQueryStatus($sql, $this->status);