summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-20 11:20:30 -0700
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-20 11:20:30 -0700
commit4d36b4415586aba4b7fcac11d4e99fd768d6d716 (patch)
tree9e8998129a5d62c182c46ab8fb36b69d8ef60e13
parent177a6af3d6ad18711e8195d6c140cc823f635aed (diff)
parentb4defde5663decee625ee326bc8947a6b7b38bd6 (diff)
Merge pull request #104 from owncloud/no-pubdate
Fix feed items without pubDate always getting marked as unread
-rw-r--r--businesslayer/feedbusinesslayer.php2
-rw-r--r--tests/unit/businesslayer/FeedBusinessLayerTest.php45
2 files changed, 46 insertions, 1 deletions
diff --git a/businesslayer/feedbusinesslayer.php b/businesslayer/feedbusinesslayer.php
index de8d79ebf..a543f352b 100644
--- a/businesslayer/feedbusinesslayer.php
+++ b/businesslayer/feedbusinesslayer.php
@@ -145,7 +145,7 @@ class FeedBusinessLayer extends BusinessLayer {
// if the pub_date changed because we sort by id on the
// client side since this is the only reliable way to do it
// to not get weird behaviour
- if($existing->getPubDate() !== (int)$item->getPubDate()){
+ if((int)$existing->getPubDate() !== (int)$item->getPubDate()){
// because the item is being replaced we need to keep
// status flags but we want the new entry to be unread
diff --git a/tests/unit/businesslayer/FeedBusinessLayerTest.php b/tests/unit/businesslayer/FeedBusinessLayerTest.php
index 2ceb82872..cd044161f 100644
--- a/tests/unit/businesslayer/FeedBusinessLayerTest.php
+++ b/tests/unit/businesslayer/FeedBusinessLayerTest.php
@@ -347,6 +347,51 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$this->assertEquals($return, $feed);
}
+ public function testUpdateUpdatesEntryNotWhenNoPubDate(){
+ $feed = new Feed();
+ $feed->setId(3);
+ $feed->getUrl('test');
+
+ $item = new Item();
+ $item->setGuidHash(md5('hi'));
+ $item->setPubDate(null);
+ $items = array(
+ $item
+ );
+
+ $item2 = new Item();
+ $item2->setPubDate(null);
+
+ $fetchReturn = array($feed, $items);
+
+ $this->mapper->expects($this->at(0))
+ ->method('find')
+ ->with($this->equalTo($feed->getId()),
+ $this->equalTo($this->user))
+ ->will($this->returnValue($feed));
+ $this->fetcher->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($fetchReturn));
+ $this->itemMapper->expects($this->once())
+ ->method('findByGuidHash')
+ ->with($this->equalTo($item->getGuidHash()),
+ $this->equalTo($feed->getId()),
+ $this->equalTo($this->user))
+ ->will($this->returnValue($item2));
+ $this->itemMapper->expects($this->never())
+ ->method('insert');
+ $this->itemMapper->expects($this->never())
+ ->method('delete');
+
+ $this->mapper->expects($this->at(1))
+ ->method('find')
+ ->with($feed->getId(), $this->user)
+ ->will($this->returnValue($feed));
+
+ $return = $this->businessLayer->update($feed->getId(), $this->user);
+
+ $this->assertEquals($return, $feed);
+ }
public function testUpdateUpdatesEntry(){
$feed = new Feed();