summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-06-22 15:11:34 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-06-22 15:11:34 +0200
commit20597eb1af744e6a7bf88d5b03204fd942a96d17 (patch)
treedaa4163a39f8c6051110358450bfc7af2a1b4c4a
parent7d1c2b2c2cab883c63b074cec87dcc8729b52d1b (diff)
also set last modified when marking feeds, folders, or all read, fix #256
-rw-r--r--businesslayer/itembusinesslayer.php9
-rw-r--r--db/itemmapper.php58
-rw-r--r--tests/unit/businesslayer/ItemBusinessLayerTest.php43
-rw-r--r--tests/unit/db/ItemMapperTest.php140
4 files changed, 132 insertions, 118 deletions
diff --git a/businesslayer/itembusinesslayer.php b/businesslayer/itembusinesslayer.php
index 065e0de30..4042e162c 100644
--- a/businesslayer/itembusinesslayer.php
+++ b/businesslayer/itembusinesslayer.php
@@ -161,7 +161,8 @@ class ItemBusinessLayer extends BusinessLayer {
* @param string $userId the name of the user
*/
public function readAll($highestItemId, $userId){
- $this->mapper->readAll($highestItemId, $userId);
+ $time = $this->timeFactory->getTime();
+ $this->mapper->readAll($highestItemId, $time, $userId);
}
@@ -173,7 +174,8 @@ class ItemBusinessLayer extends BusinessLayer {
* @param string $userId the name of the user
*/
public function readFolder($folderId, $highestItemId, $userId){
- $this->mapper->readFolder($folderId, $highestItemId, $userId);
+ $time = $this->timeFactory->getTime();
+ $this->mapper->readFolder($folderId, $highestItemId, $time, $userId);
}
@@ -185,7 +187,8 @@ class ItemBusinessLayer extends BusinessLayer {
* @param string $userId the name of the user
*/
public function readFeed($feedId, $highestItemId, $userId){
- $this->mapper->readFeed($feedId, $highestItemId, $userId);
+ $time = $this->timeFactory->getTime();
+ $this->mapper->readFeed($feedId, $highestItemId, $time, $userId);
}
diff --git a/db/itemmapper.php b/db/itemmapper.php
index 0f94b4301..512de4c88 100644
--- a/db/itemmapper.php
+++ b/db/itemmapper.php
@@ -34,7 +34,7 @@ class ItemMapper extends Mapper implements IMapper {
public function __construct(API $api){
parent::__construct($api, 'news_items');
}
-
+
protected function findAllRows($sql, $params, $limit=null, $offset=null) {
$result = $this->execute($sql, $params, $limit, $offset);
@@ -44,25 +44,25 @@ class ItemMapper extends Mapper implements IMapper {
while($row = $result->fetchRow()){
$item = new Item();
$item->fromRow($row);
-
+
array_push($items, $item);
}
return $items;
}
-
+
private function makeSelectQuery($prependTo){
return 'SELECT `items`.* FROM `*PREFIX*news_items` `items` '.
'JOIN `*PREFIX*news_feeds` `feeds` ' .
'ON `feeds`.`id` = `items`.`feed_id` '.
'AND `feeds`.`deleted_at` = 0 ' .
- 'AND `feeds`.`user_id` = ? ' .
+ 'AND `feeds`.`user_id` = ? ' .
$prependTo .
'LEFT OUTER JOIN `*PREFIX*news_folders` `folders` ' .
'ON `folders`.`id` = `feeds`.`folder_id` ' .
'WHERE `feeds`.`folder_id` = 0 ' .
- 'OR `folders`.`deleted_at` = 0 ' .
+ 'OR `folders`.`deleted_at` = 0 ' .
'ORDER BY `items`.`id` DESC';
}
@@ -81,22 +81,22 @@ class ItemMapper extends Mapper implements IMapper {
return $this->makeSelectQuery(
// WARNING: this is a desperate attempt at making this query work
- // because prepared statements dont work. This is a possible
+ // because prepared statements dont work. This is a possible
// SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
// think twice when changing this
'AND ((`items`.`status` & ' . $status . ') = ' . $status . ') ' .
$prependTo
);
}
-
+
public function find($id, $userId){
$sql = $this->makeSelectQuery('AND `items`.`id` = ? ');
$row = $this->findOneQuery($sql, array($userId, $id));
-
+
$item = new Item();
$item->fromRow($row);
-
+
return $item;
}
@@ -107,10 +107,10 @@ class ItemMapper extends Mapper implements IMapper {
'ON `items`.`feed_id` = `feeds`.`id` ' .
'AND `feeds`.`user_id` = ? ' .
// WARNING: this is a desperate attempt at making this query work
- // because prepared statements dont work. This is a possible
+ // because prepared statements dont work. This is a possible
// SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
// think twice when changing this
- 'WHERE ((`items`.`status` & ' . StatusFlag::STARRED . ') = ' .
+ 'WHERE ((`items`.`status` & ' . StatusFlag::STARRED . ') = ' .
StatusFlag::STARRED . ')';
$params = array($userId);
@@ -121,45 +121,49 @@ class ItemMapper extends Mapper implements IMapper {
}
- public function readAll($highestItemId, $userId) {
- $sql = 'UPDATE `*PREFIX*news_items` ' .
+ public function readAll($highestItemId, $time, $userId) {
+ $sql = 'UPDATE `*PREFIX*news_items` ' .
'SET `status` = `status` & ? ' .
+ 'AND `last_modified` = ? ' .
'WHERE `feed_id` IN (' .
'SELECT `id` FROM `*PREFIX*news_feeds` ' .
'WHERE `user_id` = ? ' .
') '.
'AND `id` <= ?';
- $params = array(~StatusFlag::UNREAD, $userId, $highestItemId);
+ $params = array(~StatusFlag::UNREAD, $time, $userId, $highestItemId);
$this->execute($sql, $params);
}
- public function readFolder($folderId, $highestItemId, $userId) {
- $sql = 'UPDATE `*PREFIX*news_items` ' .
+ public function readFolder($folderId, $highestItemId, $time, $userId) {
+ $sql = 'UPDATE `*PREFIX*news_items` ' .
'SET `status` = `status` & ? ' .
+ 'AND `last_modified` = ? ' .
'WHERE `feed_id` IN (' .
'SELECT `id` FROM `*PREFIX*news_feeds` ' .
'WHERE `folder_id` = ? ' .
'AND `user_id` = ? ' .
') '.
'AND `id` <= ?';
- $params = array(~StatusFlag::UNREAD, $folderId, $userId, $highestItemId);
+ $params = array(~StatusFlag::UNREAD, $time, $folderId, $userId,
+ $highestItemId);
$this->execute($sql, $params);
}
- public function readFeed($feedId, $highestItemId, $userId){
- $sql = 'UPDATE `*PREFIX*news_items` ' .
+ public function readFeed($feedId, $highestItemId, $time, $userId){
+ $sql = 'UPDATE `*PREFIX*news_items` ' .
'SET `status` = `status` & ? ' .
+ 'AND `last_modified` = ? ' .
'WHERE `feed_id` = ? ' .
'AND `id` <= ? ' .
'AND EXISTS (' .
'SELECT * FROM `*PREFIX*news_feeds` ' .
'WHERE `user_id` = ? ' .
'AND `id` = ? ) ';
- $params = array(~StatusFlag::UNREAD, $feedId, $highestItemId, $userId,
- $feedId);
-
+ $params = array(~StatusFlag::UNREAD, $time, $feedId, $highestItemId,
+ $userId, $feedId);
+
$this->execute($sql, $params);
}
@@ -231,15 +235,15 @@ class ItemMapper extends Mapper implements IMapper {
'AND `items`.`guid_hash` = ? ' .
'AND `feeds`.`id` = ? ');
$row = $this->findOneQuery($sql, array($userId, $guidHash, $feedId));
-
+
$item = new Item();
$item->fromRow($row);
-
+
return $item;
}
- /**
+ /**
* Delete all items for feeds that have over $threshold unread and not
* starred items
*/
@@ -254,9 +258,9 @@ class ItemMapper extends Mapper implements IMapper {
$result = $this->execute($sql, $params);
while($row = $result->fetchRow()) {
-
+
$limit = $threshold - $row['size'];
-
+
if($limit > 0) {
$params = array($status, $row['feed_id']);
diff --git a/tests/unit/businesslayer/ItemBusinessLayerTest.php b/tests/unit/businesslayer/ItemBusinessLayerTest.php
index 54b7bc5fc..2b9745b52 100644
--- a/tests/unit/businesslayer/ItemBusinessLayerTest.php
+++ b/tests/unit/businesslayer/ItemBusinessLayerTest.php
@@ -67,24 +67,24 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
->method('typeToStatus')
->will($this->returnValue($this->status));
$this->threshold = 2;
- $this->itemBusinessLayer = new ItemBusinessLayer($this->mapper,
+ $this->itemBusinessLayer = new ItemBusinessLayer($this->mapper,
$statusFlag, $timeFactory, $this->threshold);
$this->user = 'jack';
$response = 'hi';
$this->id = 3;
$this->updatedSince = 20333;
- $this->showAll = true;
+ $this->showAll = true;
$this->offset = 5;
$this->limit = 20;
$this->newestItemId = 4;
}
-
+
public function testFindAllNewFeed(){
$type = FeedType::FEED;
$this->mapper->expects($this->once())
->method('findAllNewFeed')
- ->with($this->equalTo($this->id),
+ ->with($this->equalTo($this->id),
$this->equalTo($this->updatedSince),
$this->equalTo($this->status),
$this->equalTo($this->user))
@@ -101,7 +101,7 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$type = FeedType::FOLDER;
$this->mapper->expects($this->once())
->method('findAllNewFolder')
- ->with($this->equalTo($this->id),
+ ->with($this->equalTo($this->id),
$this->equalTo($this->updatedSince),
$this->equalTo($this->status),
$this->equalTo($this->user))
@@ -134,7 +134,7 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$type = FeedType::FEED;
$this->mapper->expects($this->once())
->method('findAllFeed')
- ->with($this->equalTo($this->id),
+ ->with($this->equalTo($this->id),
$this->equalTo($this->limit),
$this->equalTo($this->offset),
$this->equalTo($this->status),
@@ -142,7 +142,7 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
->will($this->returnValue($this->response));
$result = $this->itemBusinessLayer->findAll(
- $this->id, $type, $this->limit,
+ $this->id, $type, $this->limit,
$this->offset, $this->showAll,
$this->user);
$this->assertEquals($this->response, $result);
@@ -153,7 +153,7 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$type = FeedType::FOLDER;
$this->mapper->expects($this->once())
->method('findAllFolder')
- ->with($this->equalTo($this->id),
+ ->with($this->equalTo($this->id),
$this->equalTo($this->limit),
$this->equalTo($this->offset),
$this->equalTo($this->status),
@@ -161,7 +161,7 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
->will($this->returnValue($this->response));
$result = $this->itemBusinessLayer->findAll(
- $this->id, $type, $this->limit,
+ $this->id, $type, $this->limit,
$this->offset, $this->showAll,
$this->user);
$this->assertEquals($this->response, $result);
@@ -179,7 +179,7 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
->will($this->returnValue($this->response));
$result = $this->itemBusinessLayer->findAll(
- $this->id, $type, $this->limit,
+ $this->id, $type, $this->limit,
$this->offset, $this->showAll,
$this->user);
$this->assertEquals($this->response, $result);
@@ -204,7 +204,7 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$this->mapper->expects($this->once())
->method('findByGuidHash')
- ->with(
+ ->with(
$this->equalTo($guidHash),
$this->equalTo($feedId),
$this->equalTo($this->user))
@@ -231,7 +231,7 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$expectedItem->setStatus(128);
$expectedItem->setUnread();
$expectedItem->setId($itemId);
- $expectedItem->setLastModified($this->time);
+ $expectedItem->setLastModified($this->time);
$this->mapper->expects($this->once())
->method('find')
@@ -261,10 +261,11 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
public function testReadAll(){
$highestItemId = 6;
-
+
$this->mapper->expects($this->once())
->method('readAll')
- ->with($this->equalTo($highestItemId),
+ ->with($this->equalTo($highestItemId),
+ $this->equalTo($this->time),
$this->equalTo($this->user));
$this->itemBusinessLayer->readAll($highestItemId, $this->user);
@@ -274,11 +275,12 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
public function testReadFolder(){
$folderId = 3;
$highestItemId = 6;
-
+
$this->mapper->expects($this->once())
->method('readFolder')
- ->with($this->equalTo($folderId),
- $this->equalTo($highestItemId),
+ ->with($this->equalTo($folderId),
+ $this->equalTo($highestItemId),
+ $this->equalTo($this->time),
$this->equalTo($this->user));
$this->itemBusinessLayer->readFolder($folderId, $highestItemId, $this->user);
@@ -288,11 +290,12 @@ class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
public function testReadFeed(){
$feedId = 3;
$highestItemId = 6;
-
+
$this->mapper->expects($this->once())
->method('readFeed')
- ->with($this->equalTo($feedId),
- $this->equalTo($highestItemId),
+ ->with($this->equalTo($feedId),
+ $this->equalTo($highestItemId),
+ $this->equalTo($this->time),
$this->equalTo($this->user));
$this->itemBusinessLayer->readFeed($feedId, $highestItemId, $this->user);
diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php
index 8b427923c..c88f27403 100644
--- a/tests/unit/db/ItemMapperTest.php
+++ b/tests/unit/db/ItemMapperTest.php
@@ -39,13 +39,13 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
private $updatedSince;
private $status;
-
+
public function setUp()
{
$this->beforeEach();
-
+
$this->mapper = new ItemMapper($this->api);
-
+
// create mock items
$item1 = new Item();
$item2 = new Item();
@@ -54,42 +54,42 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$item1,
$item2
);
-
+
$this->userId = 'john';
$this->id = 3;
$this->folderId = 2;
-
+
$this->row = array(
array('id' => $this->items[0]->getId()),
- );
-
- $this->rows = array(
- array('id' => $this->items[0]->getId()),
- array('id' => $this->items[1]->getId())
- );
-
- $this->user = 'john';
- $this->limit = 10;
- $this->offset = 3;
- $this->id = 11;
- $this->status = 333;
- $this->updatedSince = 323;
- $this->newestItemId = 2;
+ );
+
+ $this->rows = array(
+ array('id' => $this->items[0]->getId()),
+ array('id' => $this->items[1]->getId())
+ );
+
+ $this->user = 'john';
+ $this->limit = 10;
+ $this->offset = 3;
+ $this->id = 11;
+ $this->status = 333;
+ $this->updatedSince = 323;
+ $this->newestItemId = 2;
}
-
+
private function makeSelectQuery($prependTo){
return 'SELECT `items`.* FROM `*PREFIX*news_items` `items` '.
'JOIN `*PREFIX*news_feeds` `feeds` ' .
'ON `feeds`.`id` = `items`.`feed_id` '.
'AND `feeds`.`deleted_at` = 0 ' .
- 'AND `feeds`.`user_id` = ? ' .
+ 'AND `feeds`.`user_id` = ? ' .
$prependTo .
'LEFT OUTER JOIN `*PREFIX*news_folders` `folders` ' .
'ON `folders`.`id` = `feeds`.`folder_id` ' .
'WHERE `feeds`.`folder_id` = 0 ' .
- 'OR `folders`.`deleted_at` = 0 ' .
+ 'OR `folders`.`deleted_at` = 0 ' .
'ORDER BY `items`.`id` DESC';
}
@@ -105,14 +105,14 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
public function testFind(){
$sql = $this->makeSelectQuery('AND `items`.`id` = ? ');
-
+
$this->setMapperResult($sql, array($this->userId, $this->id), $this->row);
-
+
$result = $this->mapper->find($this->id, $this->userId);
$this->assertEquals($this->items[0], $result);
}
-
+
public function testGetStarredCount(){
$userId = 'john';
$row = array(
@@ -124,55 +124,59 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'AND `feeds`.`user_id` = ? ' .
'WHERE ((`items`.`status` & ' . StatusFlag::STARRED . ') = '
. StatusFlag::STARRED . ')';
-
+
$this->setMapperResult($sql, array($userId), $row);
-
+
$result = $this->mapper->starredCount($userId);
$this->assertEquals($row[0]['size'], $result);
}
public function testReadAll(){
- $sql = 'UPDATE `*PREFIX*news_items` ' .
+ $sql = 'UPDATE `*PREFIX*news_items` ' .
'SET `status` = `status` & ? ' .
- 'WHERE `feed_id` IN (' .
- 'SELECT `id` FROM `*PREFIX*news_feeds` ' .
- 'WHERE `user_id` = ? ' .
- ') '.
- 'AND `id` <= ?';
- $params = array(~StatusFlag::UNREAD, $this->user, 3);
+ 'AND `last_modified` = ? ' .
+ 'WHERE `feed_id` IN (' .
+ 'SELECT `id` FROM `*PREFIX*news_feeds` ' .
+ 'WHERE `user_id` = ? ' .
+ ') '.
+ 'AND `id` <= ?';
+ $params = array(~StatusFlag::UNREAD, $this->updatedSince, $this->user, 3);
$this->setMapperResult($sql, $params);
- $this->mapper->readAll(3, $this->user);
- }
+ $this->mapper->readAll(3, $this->updatedSince, $this->user);
+ }
public function testReadFolder(){
- $sql = 'UPDATE `*PREFIX*news_items` ' .
+ $sql = 'UPDATE `*PREFIX*news_items` ' .
'SET `status` = `status` & ? ' .
- 'WHERE `feed_id` IN (' .
- 'SELECT `id` FROM `*PREFIX*news_feeds` ' .
- 'WHERE `folder_id` = ? ' .
- 'AND `user_id` = ? ' .
- ') '.
- 'AND `id` <= ?';
- $params = array(~StatusFlag::UNREAD, 3, $this->user, 6);
+ 'AND `last_modified` = ? ' .
+ 'WHERE `feed_id` IN (' .
+ 'SELECT `id` FROM `*PREFIX*news_feeds` ' .
+ 'WHERE `folder_id` = ? ' .
+ 'AND `user_id` = ? ' .
+ ') '.
+ 'AND `id` <= ?';
+ $params = array(~StatusFlag::UNREAD, $this->updatedSince, 3, $this->user, 6);
$this->setMapperResult($sql, $params);
- $this->mapper->readFolder(3, 6, $this->user);
+ $this->mapper->readFolder(3, 6, $this->updatedSince, $this->user);
}
public function testReadFeed(){
- $sql = 'UPDATE `*PREFIX*news_items` ' .
+ $sql = 'UPDATE `*PREFIX*news_items` ' .
'SET `status` = `status` & ? ' .
+ 'AND `last_modified` = ? ' .
'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);
+ $params = array(~StatusFlag::UNREAD, $this->updatedSince, 3, 6,
+ $this->user, 3);
$this->setMapperResult($sql, $params);
- $this->mapper->readFeed(3, 6, $this->user);
+ $this->mapper->readFeed(3, 6, $this->updatedSince, $this->user);
}
@@ -182,7 +186,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$params = array($this->user, $this->updatedSince);
$this->setMapperResult($sql, $params, $this->rows);
- $result = $this->mapper->findAllNew($this->updatedSince,
+ $result = $this->mapper->findAllNew($this->updatedSince,
$this->status, $this->user);
$this->assertEquals($this->items, $result);
@@ -196,7 +200,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$params = array($this->user, $this->id, $this->updatedSince);
$this->setMapperResult($sql, $params, $this->rows);
- $result = $this->mapper->findAllNewFolder($this->id, $this->updatedSince,
+ $result = $this->mapper->findAllNewFolder($this->id, $this->updatedSince,
$this->status, $this->user);
$this->assertEquals($this->items, $result);
@@ -210,7 +214,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$params = array($this->user, $this->id, $this->updatedSince);
$this->setMapperResult($sql, $params, $this->rows);
- $result = $this->mapper->findAllNewFeed($this->id, $this->updatedSince,
+ $result = $this->mapper->findAllNewFeed($this->id, $this->updatedSince,
$this->status, $this->user);
$this->assertEquals($this->items, $result);
@@ -223,7 +227,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$sql = $this->makeSelectQueryStatus($sql, $this->status);
$params = array($this->user, $this->id, $this->offset);
$this->setMapperResult($sql, $params, $this->rows);
- $result = $this->mapper->findAllFeed($this->id, $this->limit,
+ $result = $this->mapper->findAllFeed($this->id, $this->limit,
$this->offset, $this->status, $this->user);
$this->assertEquals($this->items, $result);
@@ -235,7 +239,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$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,
+ $result = $this->mapper->findAllFeed($this->id, $this->limit,
0, $this->status, $this->user);
$this->assertEquals($this->items, $result);
@@ -246,10 +250,10 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$sql = 'AND `feeds`.`folder_id` = ? ' .
'AND `items`.`id` < ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = array($this->user, $this->id,
+ $params = array($this->user, $this->id,
$this->offset);
$this->setMapperResult($sql, $params, $this->rows);
- $result = $this->mapper->findAllFolder($this->id, $this->limit,
+ $result = $this->mapper->findAllFolder($this->id, $this->limit,
$this->offset, $this->status, $this->user);
$this->assertEquals($this->items, $result);
@@ -261,7 +265,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$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,
+ $result = $this->mapper->findAllFolder($this->id, $this->limit,
0, $this->status, $this->user);
$this->assertEquals($this->items, $result);
@@ -273,7 +277,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$sql = $this->makeSelectQueryStatus($sql, $this->status);
$params = array($this->user, $this->offset);
$this->setMapperResult($sql, $params, $this->rows);
- $result = $this->mapper->findAll($this->limit,
+ $result = $this->mapper->findAll($this->limit,
$this->offset, $this->status, $this->user);
$this->assertEquals($this->items, $result);
@@ -284,7 +288,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$sql = $this->makeSelectQueryStatus('', $this->status);
$params = array($this->user);
$this->setMapperResult($sql, $params, $this->rows);
- $result = $this->mapper->findAll($this->limit,
+ $result = $this->mapper->findAll($this->limit,
0, $this->status, $this->user);
$this->assertEquals($this->items, $result);
@@ -299,9 +303,9 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$sql = $this->makeSelectQuery(
'AND `items`.`guid_hash` = ? ' .
'AND `feeds`.`id` = ? ');
-
+
$this->setMapperResult($sql, array($this->userId, $hash, $feedId), $this->row);
-
+
$result = $this->mapper->findByGuidHash($hash, $feedId, $this->userId);
$this->assertEquals($this->items[0], $result);
}
@@ -335,7 +339,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'HAVING COUNT(*) > ?';
$params1 = array($status, $threshold);
-
+
$row = array('feed_id' => 30, 'size' => 9);
$sql2 = 'DELETE FROM `*PREFIX*news_items` `items` ' .
@@ -344,8 +348,8 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
'ORDER BY `items`.`id` ASC';
$params2 = array($status, 30);
-
- $pdoResult = $this->getMock('Result',
+
+ $pdoResult = $this->getMock('Result',
array('fetchRow'));
$pdoResult->expects($this->at(0))
@@ -354,8 +358,8 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$pdoResult->expects($this->at(1))
->method('fetchRow')
->will($this->returnValue(false));
-
- $query = $this->getMock('Query',
+
+ $query = $this->getMock('Query',
array('execute'));
$query->expects($this->at(0))
->method('execute')
@@ -367,7 +371,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
->with($this->equalTo($sql1))
->will(($this->returnValue($query)));
- $query2 = $this->getMock('Query',
+ $query2 = $this->getMock('Query',
array('execute'));
$query2->expects($this->at(0))
->method('execute')
@@ -391,7 +395,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$rows = array(array('max_id' => 3));
$this->setMapperResult($sql, $params, $rows);
-
+
$result = $this->mapper->getNewestItemId($this->user);
$this->assertEquals(3, $result);
}
@@ -411,4 +415,4 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$result = $this->mapper->getNewestItemId($this->user);
}
-} \ No newline at end of file
+}