summaryrefslogtreecommitdiffstats
path: root/tests/unit/db/FeedMapperTest.php
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-05 22:56:22 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-05 22:56:22 +0200
commit2d8f76d28f47bc3992c0e86c194fe51427805b54 (patch)
treed6bac7603c37f24c0e0bdf549c778ba4eb5b640d /tests/unit/db/FeedMapperTest.php
parent4560ab85567564e59647994331328d8949df6b5a (diff)
fix statusflag db query bugs and unittests
Diffstat (limited to 'tests/unit/db/FeedMapperTest.php')
-rw-r--r--tests/unit/db/FeedMapperTest.php35
1 files changed, 21 insertions, 14 deletions
diff --git a/tests/unit/db/FeedMapperTest.php b/tests/unit/db/FeedMapperTest.php
index 58ea8c4ed..1f8d08ef8 100644
--- a/tests/unit/db/FeedMapperTest.php
+++ b/tests/unit/db/FeedMapperTest.php
@@ -60,11 +60,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` & ?) = ? ' .
+ 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
+ StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`id` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
- $params = array(StatusFlag::UNREAD, StatusFlag::UNREAD, $id, $userId);
+ $params = array($id, $userId);
$this->setMapperResult($sql, $params, $rows);
$result = $this->mapper->find($id, $userId);
@@ -80,11 +81,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` & ?) = ? ' .
+ 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
+ StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`id` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
- $params = array(StatusFlag::UNREAD, StatusFlag::UNREAD, $id, $userId);
+ $params = array($id, $userId);
$this->setMapperResult($sql, $params);
$this->setExpectedException('\OCA\AppFramework\Db\DoesNotExistException');
@@ -103,11 +105,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` & ?) = ? ' .
+ 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
+ StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`id` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
- $params = array(StatusFlag::UNREAD, StatusFlag::UNREAD, $id, $userId);
+ $params = array($id, $userId);
$this->setMapperResult($sql, $params, $rows);
$this->setExpectedException('\OCA\AppFramework\Db\MultipleObjectsReturnedException');
@@ -140,12 +143,13 @@ 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` & ?) = ? ' .
+ 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
+ StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
$this->setMapperResult($sql,
- array(StatusFlag::UNREAD, StatusFlag::UNREAD, $userId), $rows);
+ array($userId), $rows);
$result = $this->mapper->findAllFromUser($userId);
$this->assertEquals($this->feeds, $result);
@@ -161,12 +165,13 @@ 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` & ?) = ? ' .
+ 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
+ StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`url_hash` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
$this->setMapperResult($sql,
- array(StatusFlag::UNREAD, StatusFlag::UNREAD, $urlHash, $this->user), $row);
+ array($urlHash, $this->user), $row);
$result = $this->mapper->findByUrlHash($urlHash, $this->user);
$this->assertEquals($this->feeds[0], $result);
@@ -179,12 +184,13 @@ 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` & ?) = ? ' .
+ 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
+ StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`url_hash` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
$this->setMapperResult($sql,
- array(StatusFlag::UNREAD, StatusFlag::UNREAD, $urlHash, $this->user));
+ array($urlHash, $this->user));
$this->setExpectedException('\OCA\AppFramework\Db\DoesNotExistException');
$result = $this->mapper->findByUrlHash($urlHash, $this->user);
@@ -201,12 +207,13 @@ 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` & ?) = ? ' .
+ 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
+ StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`url_hash` = ? ' .
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`';
$this->setMapperResult($sql,
- array(StatusFlag::UNREAD, StatusFlag::UNREAD, $urlHash, $this->user), $rows);
+ array($urlHash, $this->user), $rows);
$this->setExpectedException('\OCA\AppFramework\Db\MultipleObjectsReturnedException');
$result = $this->mapper->findByUrlHash($urlHash, $this->user);