summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-03-22 16:08:19 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2013-03-22 16:08:19 +0100
commit91a327f5c687014fe20b531b9a42b98fe151d017 (patch)
treea5748f77c612f2b4af6fb36db0b72729c57c52b3 /tests
parent585667bdf4a06a7bcde1b7d2b9b42059135343dc (diff)
implemented feedRead
Diffstat (limited to 'tests')
-rw-r--r--tests/db/ItemMapperTest.php201
1 files changed, 109 insertions, 92 deletions
diff --git a/tests/db/ItemMapperTest.php b/tests/db/ItemMapperTest.php
index ea9b15815..9d16d6897 100644
--- a/tests/db/ItemMapperTest.php
+++ b/tests/db/ItemMapperTest.php
@@ -59,10 +59,23 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$this->rows = array(
array('id' => $this->items[0]->getId()),
array('id' => $this->items[1]->getId())
- );
-
+ );
+
+ $this->user = 'john';
}
+
+ private function makeFindAllFromFolderQuery($custom) {
+ return 'SELECT `*dbprefix*news_items`.* FROM `*dbprefix*news_items` ' .
+ 'JOIN `*dbprefix*news_feeds` ' .
+ 'ON `*dbprefix*news_feeds`.`id` = `*dbprefix*news_items`.`feed_id` ' .
+ 'WHERE `*dbprefix*news_feeds`.`user_id` = ? ' .
+ 'AND `*dbprefix*news_feeds`.`folder_id` = ? ' .
+ 'AND ((`*dbprefix*news_items`.`status` & ?) > 0) ' .
+ $custom;
+ }
+
+
public function testFind(){
$sql = 'SELECT `*dbprefix*news_items`.* FROM `*dbprefix*news_items` ' .
'JOIN `*dbprefix*news_feeds` ' .
@@ -77,7 +90,100 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
}
+
+ public function testGetStarredCount(){
+ $userId = 'john';
+ $row = array(
+ array('size' => 9)
+ );
+ $sql = 'SELECT COUNT(*) AS size FROM `*dbprefix*news_feeds` `feeds` ' .
+ 'JOIN `*dbprefix*news_items` `items` ' .
+ 'ON `items`.`feed_id` = `feeds`.`id` ' .
+ 'WHERE `feeds`.`user_id` = ? ' .
+ 'AND ((`items`.`status` & ?) > 0)';
+
+ $this->setMapperResult($sql, array($userId, StatusFlag::STARRED), $row);
+
+ $result = $this->mapper->starredCount($userId);
+ $this->assertEquals($row[0]['size'], $result);
+ }
+
+
+ public function testReadFeed(){
+ $sql = 'UPDATE `*dbprefix*news_feeds` `feeds` ' .
+ 'JOIN `*dbprefix*news_items` `items` ' .
+ 'ON `items`.`feed_id` = `feeds`.`id` ' .
+ 'SET `items`.`status` = (`items`.`status` & ?) ' .
+ 'WHERE `feeds`.`user_id` = ? ' .
+ 'AND `items`.`id` = ?';
+ $this->setMapperResult($sql, array(~StatusFlag::UNREAD, $this->user, 3));
+ $this->mapper->readFeed(3, $this->user);
+ }
+
+/*
+ public function testFindAllFromFolder() {
+ $sql = $this->makeFindAllFromFolderQuery('');
+
+ $status = 2;
+
+ $params = array($this->userId, $this->folderId, $status);
+ $this->setMapperResult($sql, $params, $this->rows);
+ $result = $this->mapper->findAllFromFolderByOffset($this->userId, $this->folderId, $status);
+ $this->assertEquals($this->items, $result);
+
+ }
+
+ public function testFindAllFromFolderByOffset() {
+ $sql = $this->makeFindAllFromFolderQuery('');
+
+ $status = 2;
+ $limit = 10;
+ $offset = 10;
+
+ $params = array($this->userId, $this->folderId, $status);
+ $this->setMapperResult($sql, $params, $this->rows);
+ $result = $this->mapper->findAllFromFolderByOffset($this->userId, $this->folderId, $status, $limit, $offset);
+ $this->assertEquals($this->items, $result);
+
+ }
+
+ public function testFindAllFromFolderByLastModified() {
+ $sql = $this->makeFindAllFromFolderQuery(' AND (`*dbprefix*news_items`.`last_modified` >= ?)');
+
+ $status = 2;
+ $lastModified = 100;
+
+ $params = array($this->userId, $this->folderId, $status, $lastModified);
+ $this->setMapperResult($sql, $params, $this->rows);
+ $result = $this->mapper->findAllFromFolderByLastMofified($this->userId, $this->folderId, $status, $lastModified);
+ $this->assertEquals($this->items, $result);
+
+ }*/
+
+}
+
+
+
+
+// TBD
+// }
+//
+// public function testFindAllFromFolderByLastModified() {
+// $userId = 'john';
+// $folderId = 3;
+// $lastModified = 123;
+//
+// $sql = 'SELECT `*dbprefix*news_items`.* FROM `*dbprefix*news_items` ' .
+// 'JOIN `*dbprefix*news_feeds` ' .
+// 'ON `*dbprefix*news_feeds`.`id` = `*dbprefix*news_items`.`feed_id` ' .
+// 'WHERE `*dbprefix*news_feeds`.`user_id` = ? ' .
+// 'AND `*dbprefix*news_feeds`.`folder_id` = ? ' .
+// 'AND `*dbprefix*news_items`.last_modified >= ? ';
+//
+// $this->setMapperResult($sql, array($userId, $folderId, $lastModified));
+// $result = $this->mapper->findAllFromFolderByLastMofified($userId, $folderId, $lastModified);
+// }
//
// public function testFindNotFound(){
// $sql = 'SELECT `*dbprefix*news_items`.* FROM `*dbprefix*news_items` ' .
@@ -144,93 +250,4 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
// $result = $this->mapper->findAllFromFeedByStatus($feedId, $userId, $status);
// $this->assertEquals($this->items, $result);
//
-// }
-
- private function makeFindAllFromFolderQuery($custom) {
- return 'SELECT `*dbprefix*news_items`.* FROM `*dbprefix*news_items` ' .
- 'JOIN `*dbprefix*news_feeds` ' .
- 'ON `*dbprefix*news_feeds`.`id` = `*dbprefix*news_items`.`feed_id` ' .
- 'WHERE `*dbprefix*news_feeds`.`user_id` = ? ' .
- 'AND `*dbprefix*news_feeds`.`folder_id` = ? ' .
- 'AND ((`*dbprefix*news_items`.`status` & ?) > 0) ' .
- $custom;
- }
-
- public function testFindAllFromFolder() {
- $sql = $this->makeFindAllFromFolderQuery('');
-
- $status = 2;
-
- $params = array($this->userId, $this->folderId, $status);
- $this->setMapperResult($sql, $params, $this->rows);
- $result = $this->mapper->findAllFromFolderByOffset($this->userId, $this->folderId, $status);
- $this->assertEquals($this->items, $result);
-
- }
-
- public function testFindAllFromFolderByOffset() {
- $sql = $this->makeFindAllFromFolderQuery('');
-
- $status = 2;
- $limit = 10;
- $offset = 10;
-
- $params = array($this->userId, $this->folderId, $status);
- $this->setMapperResult($sql, $params, $this->rows);
- $result = $this->mapper->findAllFromFolderByOffset($this->userId, $this->folderId, $status, $limit, $offset);
- $this->assertEquals($this->items, $result);
-
- }
-
- public function testFindAllFromFolderByLastModified() {
- $sql = $this->makeFindAllFromFolderQuery(' AND (`*dbprefix*news_items`.`last_modified` >= ?)');
-
- $status = 2;
- $lastModified = 100;
-
- $params = array($this->userId, $this->folderId, $status, $lastModified);
- $this->setMapperResult($sql, $params, $this->rows);
- $result = $this->mapper->findAllFromFolderByLastMofified($this->userId, $this->folderId, $status, $lastModified);
- $this->assertEquals($this->items, $result);
-
- }
-
-// }
-//
-// public function testFindAllFromFolderByLastModified() {
-// $userId = 'john';
-// $folderId = 3;
-// $lastModified = 123;
-//
-// $sql = 'SELECT `*dbprefix*news_items`.* FROM `*dbprefix*news_items` ' .
-// 'JOIN `*dbprefix*news_feeds` ' .
-// 'ON `*dbprefix*news_feeds`.`id` = `*dbprefix*news_items`.`feed_id` ' .
-// 'WHERE `*dbprefix*news_feeds`.`user_id` = ? ' .
-// 'AND `*dbprefix*news_feeds`.`folder_id` = ? ' .
-// 'AND `*dbprefix*news_items`.last_modified >= ? ';
-//
-// $this->setMapperResult($sql, array($userId, $folderId, $lastModified));
-// $result = $this->mapper->findAllFromFolderByLastMofified($userId, $folderId, $lastModified);
-// }
-
-
-
- public function testGetStarredCount(){
- $userId = 'john';
- $row = array(
- array('size' => 9)
- );
- $sql = 'SELECT COUNT(*) AS size FROM `*dbprefix*news_feeds` `feeds` ' .
- 'JOIN `*dbprefix*news_items` `items` ' .
- 'ON `items`.`feed_id` = `feeds`.`id`' .
- 'WHERE `feeds`.`user_id` = ? ' .
- 'AND ((`items`.`status` & ?) > 0)';
-
- $this->setMapperResult($sql, array($userId, StatusFlag::STARRED), $row);
-
- $result = $this->mapper->starredCount($userId);
- $this->assertEquals($row[0]['size'], $result);
- }
-
-
-} \ No newline at end of file
+// } \ No newline at end of file