summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-04 17:21:43 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-04 17:21:43 +0200
commit1ffedced057ad7968629c974574b5f66adf01b48 (patch)
tree3e40d318ac3122f1dee6328094dff6b566b63c2c /tests
parentb723c12e4c3e0039d9785861d4ad204fd899ac52 (diff)
fixes mappers by using the correct status condition
Diffstat (limited to 'tests')
-rw-r--r--tests/db/FeedMapperTest.php32
-rw-r--r--tests/db/ItemMapperTest.php30
2 files changed, 36 insertions, 26 deletions
diff --git a/tests/db/FeedMapperTest.php b/tests/db/FeedMapperTest.php
index d7163be30..ebd8163ca 100644
--- a/tests/db/FeedMapperTest.php
+++ b/tests/db/FeedMapperTest.php
@@ -60,11 +60,11 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'FROM `*PREFIX*news_feeds` `feeds` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- 'AND (`items`.`status` & ?) > 0 ' .
+ 'AND (`items`.`status` & ?) = ? ' .
'WHERE `feeds`.`id` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
- $params = array(StatusFlag::UNREAD, $id, $userId);
+ $params = array(StatusFlag::UNREAD, StatusFlag::UNREAD, $id, $userId);
$this->setMapperResult($sql, $params, $rows);
$result = $this->mapper->find($id, $userId);
@@ -80,11 +80,11 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'FROM `*PREFIX*news_feeds` `feeds` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- 'AND (`items`.`status` & ?) > 0 ' .
+ 'AND (`items`.`status` & ?) = ? ' .
'WHERE `feeds`.`id` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
- $params = array(StatusFlag::UNREAD, $id, $userId);
+ $params = array(StatusFlag::UNREAD, StatusFlag::UNREAD, $id, $userId);
$this->setMapperResult($sql, $params);
$this->setExpectedException('\OCA\AppFramework\Db\DoesNotExistException');
@@ -103,11 +103,11 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'FROM `*PREFIX*news_feeds` `feeds` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- 'AND (`items`.`status` & ?) > 0 ' .
+ 'AND (`items`.`status` & ?) = ? ' .
'WHERE `feeds`.`id` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
- $params = array(StatusFlag::UNREAD, $id, $userId);
+ $params = array(StatusFlag::UNREAD, StatusFlag::UNREAD, $id, $userId);
$this->setMapperResult($sql, $params, $rows);
$this->setExpectedException('\OCA\AppFramework\Db\MultipleObjectsReturnedException');
@@ -140,11 +140,12 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'FROM `*PREFIX*news_feeds` `feeds` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- 'AND (`items`.`status` & ?) > 0 ' .
+ 'AND (`items`.`status` & ?) = ? ' .
'WHERE `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
- $this->setMapperResult($sql, array(StatusFlag::UNREAD, $userId), $rows);
+ $this->setMapperResult($sql,
+ array(StatusFlag::UNREAD, StatusFlag::UNREAD, $userId), $rows);
$result = $this->mapper->findAllFromUser($userId);
$this->assertEquals($this->feeds, $result);
@@ -160,11 +161,12 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'FROM `*PREFIX*news_feeds` `feeds` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- 'AND (`items`.`status` & ?) > 0 ' .
+ 'AND (`items`.`status` & ?) = ? ' .
'WHERE `feeds`.`url_hash` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
- $this->setMapperResult($sql, array(StatusFlag::UNREAD, $urlHash, $this->user), $row);
+ $this->setMapperResult($sql,
+ array(StatusFlag::UNREAD, StatusFlag::UNREAD, $urlHash, $this->user), $row);
$result = $this->mapper->findByUrlHash($urlHash, $this->user);
$this->assertEquals($this->feeds[0], $result);
@@ -177,11 +179,12 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'FROM `*PREFIX*news_feeds` `feeds` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- 'AND (`items`.`status` & ?) > 0 ' .
+ 'AND (`items`.`status` & ?) = ? ' .
'WHERE `feeds`.`url_hash` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
- $this->setMapperResult($sql, array(StatusFlag::UNREAD, $urlHash, $this->user));
+ $this->setMapperResult($sql,
+ array(StatusFlag::UNREAD, StatusFlag::UNREAD, $urlHash, $this->user));
$this->setExpectedException('\OCA\AppFramework\Db\DoesNotExistException');
$result = $this->mapper->findByUrlHash($urlHash, $this->user);
@@ -198,11 +201,12 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'FROM `*PREFIX*news_feeds` `feeds` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- 'AND (`items`.`status` & ?) > 0 ' .
+ 'AND (`items`.`status` & ?) = ? ' .
'WHERE `feeds`.`url_hash` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
- $this->setMapperResult($sql, array(StatusFlag::UNREAD, $urlHash, $this->user), $rows);
+ $this->setMapperResult($sql,
+ array(StatusFlag::UNREAD, StatusFlag::UNREAD, $urlHash, $this->user), $rows);
$this->setExpectedException('\OCA\AppFramework\Db\MultipleObjectsReturnedException');
$result = $this->mapper->findByUrlHash($urlHash, $this->user);
diff --git a/tests/db/ItemMapperTest.php b/tests/db/ItemMapperTest.php
index de9b2b4ac..470d0c82d 100644
--- a/tests/db/ItemMapperTest.php
+++ b/tests/db/ItemMapperTest.php
@@ -80,7 +80,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
private function makeSelectQueryStatus($prependTo) {
return $this->makeSelectQuery(
- 'AND ((`items`.`status` & ?) > 0) ' .
+ 'AND ((`items`.`status` & ?) = ?) ' .
$prependTo
);
}
@@ -105,9 +105,10 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'JOIN `*PREFIX*news_items` `items` ' .
'ON `items`.`feed_id` = `feeds`.`id` ' .
'AND `feeds`.`user_id` = ? ' .
- 'WHERE ((`items`.`status` & ?) > 0)';
+ 'WHERE ((`items`.`status` & ?) = ?)';
- $this->setMapperResult($sql, array($userId, StatusFlag::STARRED), $row);
+ $this->setMapperResult($sql, array($userId, StatusFlag::STARRED,
+ StatusFlag::STARRED), $row);
$result = $this->mapper->starredCount($userId);
$this->assertEquals($row[0]['size'], $result);
@@ -131,7 +132,8 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
public function testFindAllNew(){
$sql = 'AND `items`.`id` >= ?';
$sql = $this->makeSelectQueryStatus($sql);
- $params = array($this->user, $this->status, $this->updatedSince);
+ $params = array($this->user, $this->status, $this->status,
+ $this->updatedSince);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllNew($this->updatedSince,
@@ -145,7 +147,8 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$sql = 'AND `items`.`feed_id` = ? ' .
'AND `items`.`id` >= ?';
$sql = $this->makeSelectQueryStatus($sql);
- $params = array($this->user, $this->status, $this->id, $this->updatedSince);
+ $params = array($this->user, $this->status, $this->status, $this->id,
+ $this->updatedSince);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllNewFeed($this->id, $this->updatedSince,
@@ -160,7 +163,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'AND `items`.`id` >= ?';
$sql = $this->makeSelectQueryStatus($sql);
- $params = array($this->user, $this->status, $this->id,
+ $params = array($this->user, $this->status, $this->status, $this->id,
$this->updatedSince);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllNewFolder($this->id, $this->updatedSince,
@@ -175,7 +178,8 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'AND `items`.`id` > ? ' .
'ORDER BY `items`.`id` DESC ';
$sql = $this->makeSelectQueryStatus($sql);
- $params = array($this->user, $this->status, $this->id, $this->offset);
+ $params = array($this->user, $this->status, $this->status, $this->id,
+ $this->offset);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFeed($this->id, $this->limit,
$this->offset, $this->status, $this->user);
@@ -188,7 +192,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$sql = 'AND `items`.`feed_id` = ? ' .
'ORDER BY `items`.`id` DESC ';
$sql = $this->makeSelectQueryStatus($sql);
- $params = array($this->user, $this->status, $this->id);
+ $params = array($this->user, $this->status, $this->status, $this->id);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFeed($this->id, $this->limit,
0, $this->status, $this->user);
@@ -202,7 +206,8 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'AND `items`.`id` > ? ' .
'ORDER BY `items`.`id` DESC ';
$sql = $this->makeSelectQueryStatus($sql);
- $params = array($this->user, $this->status, $this->id, $this->offset);
+ $params = array($this->user, $this->status, $this->status, $this->id,
+ $this->offset);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFolder($this->id, $this->limit,
$this->offset, $this->status, $this->user);
@@ -215,7 +220,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$sql = 'AND `feeds`.`folder_id` = ? ' .
'ORDER BY `items`.`id` DESC ';
$sql = $this->makeSelectQueryStatus($sql);
- $params = array($this->user, $this->status, $this->id);
+ $params = array($this->user, $this->status, $this->status, $this->id);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFolder($this->id, $this->limit,
0, $this->status, $this->user);
@@ -228,7 +233,8 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$sql = 'AND `items`.`id` > ? ' .
'ORDER BY `items`.`id` DESC ';
$sql = $this->makeSelectQueryStatus($sql);
- $params = array($this->user, $this->status, $this->offset);
+ $params = array($this->user, $this->status, $this->status,
+ $this->offset);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAll($this->limit,
$this->offset, $this->status, $this->user);
@@ -240,7 +246,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
public function testFindAllOffsetZero(){
$sql = 'ORDER BY `items`.`id` DESC ';
$sql = $this->makeSelectQueryStatus($sql);
- $params = array($this->user, $this->status);
+ $params = array($this->user, $this->status, $this->status);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAll($this->limit,
0, $this->status, $this->user);