diff options
-rw-r--r-- | businesslayer/feedbusinesslayer.php | 2 | ||||
-rw-r--r-- | tests/unit/businesslayer/FeedBusinessLayerTest.php | 46 |
2 files changed, 47 insertions, 1 deletions
diff --git a/businesslayer/feedbusinesslayer.php b/businesslayer/feedbusinesslayer.php index ec6d7283a..52009529e 100644 --- a/businesslayer/feedbusinesslayer.php +++ b/businesslayer/feedbusinesslayer.php @@ -138,7 +138,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() !== $item->getPubDate()){ + if($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 b17a19136..0b147c837 100644 --- a/tests/unit/businesslayer/FeedBusinessLayerTest.php +++ b/tests/unit/businesslayer/FeedBusinessLayerTest.php @@ -292,6 +292,52 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility { } + public function testUpdateUpdatesEntryNotWhenPubDateUnkown(){ + $feed = new Feed(); + $feed->setId(3); + $feed->getUrl('test'); + + $item = new Item(); + $item->setGuidHash(md5('hi')); + $item->setPubDate(false); + $items = array( + $item + ); + + $item2 = new Item(); + $item2->setPubDate(0); + + $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(); |